summaryrefslogtreecommitdiff
path: root/tests/generic/426
blob: 45e4a6d83bab691db2aa68f480b4455bf8dcde08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
#
# FS QA Test No. 426
#
# Check stale handles pointing to unlinked files
# and non-stale handles pointing to linked files
#
. ./common/preamble
_begin_fstest auto quick exportfs

# Import common functions.
. ./common/filter

# real QA test starts here

# Modify as appropriate.
_supported_fs generic
_require_test
# _require_exportfs already requires open_by_handle, but let's not count on it
_require_test_program "open_by_handle"
_require_exportfs

NUMFILES=1024
testdir=$TEST_DIR/$seq-dir
mkdir -p $testdir

# Create empty test files in test dir
create_test_files()
{
	local dir=$1

	mkdir -p $dir
	rm -f $dir/*
	$here/src/open_by_handle -c $dir $NUMFILES
}

# Test encode/decode file handles
test_file_handles()
{
	local dir=$1
	local opt=$2

	echo test_file_handles $* | _filter_test_dir
	$here/src/open_by_handle $opt $dir $NUMFILES
}

# Check stale handles to deleted files
create_test_files $testdir
test_file_handles $testdir -d

# Check non-stale handles to linked files
create_test_files $testdir
test_file_handles $testdir

# Check non-stale handles to files that were hardlinked and original deleted
create_test_files $testdir
test_file_handles $testdir -l
test_file_handles $testdir -u

status=0
exit