fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 467
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test No. 467
6 #
7 # Check open by file handle.
8 # This is a variant of test generic/426 that tests with less
9 # files and more use cases:
10 # - open directory by file handle
11 # - verify content integrity of file after opening by file handle
12 # - open by file handle of unlinked open files
13 # - open by file handle of renamed files
14 #
15 . ./common/preamble
16 _begin_fstest auto quick exportfs
17
18 # Import common functions.
19 . ./common/filter
20
21 # real QA test starts here
22
23 # Modify as appropriate.
24 _supported_fs generic
25 _require_test
26 # _require_exportfs already requires open_by_handle, but let's not count on it
27 _require_test_program "open_by_handle"
28 _require_exportfs
29
30 NUMFILES=10
31 testdir=$TEST_DIR/$seq-dir
32
33 # Create test dir and non-empty test files
34 create_test_files()
35 {
36         local dir=$1
37         local opt=$2
38
39         rm -rf $dir
40         $here/src/open_by_handle -cwp $dir $NUMFILES
41 }
42
43 # Test encode/decode file handles
44 test_file_handles()
45 {
46         local dir=$1
47         local opt=$2
48
49         echo test_file_handles $* | _filter_test_dir
50         $here/src/open_by_handle $opt $dir $NUMFILES
51 }
52
53 # Check stale handles to deleted files/dir
54 create_test_files $testdir
55 test_file_handles $testdir -dp
56
57 # Check non-stale handles to linked files/dir
58 create_test_files $testdir
59 test_file_handles $testdir -rp
60
61 # Check non-stale handles to unlinked open files
62 create_test_files $testdir
63 test_file_handles $testdir -dkr
64
65 # Check non-stale handles to files that were hardlinked and original deleted
66 create_test_files $testdir
67 test_file_handles $testdir -lr
68 test_file_handles $testdir -ur
69
70 # Check non-stale file handles of renamed files
71 create_test_files $testdir
72 test_file_handles $testdir -mr
73
74 # Check non-stale file handles after rename of parent
75 create_test_files $testdir
76 rm -rf $testdir.renamed
77 mv $testdir $testdir.renamed/
78 test_file_handles $testdir.renamed -rp
79
80 # Check non-stale file handles after move to new parent
81 create_test_files $testdir
82 rm -rf $testdir.new
83 mkdir -p $testdir.new
84 mv $testdir/* $testdir.new/
85 test_file_handles $testdir.new -rp
86
87 status=0
88 exit