generic/exportfs: golden output is not silent
[xfstests-dev.git] / tests / generic / 467
1 #! /bin/bash
2 # FS QA Test No. 467
3 #
4 # Check open by file handle.
5 # This is a variant of test generic/426 that tests with less
6 # files and more use cases:
7 # - open directory by file handle
8 # - verify content integrity of file after opening by file handle
9 # - open by file handle of unlinked open files
10 # - open by file handle of renamed files
11 #
12 #-----------------------------------------------------------------------
13 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
14 # Author: Amir Goldstein <amir73il@gmail.com>
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 _cleanup()
41 {
42         cd /
43         rm -f $tmp.*
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # real QA test starts here
51
52 # Modify as appropriate.
53 _supported_fs generic
54 _supported_os Linux
55 _require_test
56 # _require_exportfs already requires open_by_handle, but let's not count on it
57 _require_test_program "open_by_handle"
58 _require_exportfs
59
60 NUMFILES=10
61 testdir=$TEST_DIR/$seq-dir
62
63 # Create test dir and non-empty test files
64 create_test_files()
65 {
66         local dir=$1
67         local opt=$2
68
69         rm -rf $dir
70         $here/src/open_by_handle -cwp $dir $NUMFILES
71 }
72
73 # Test encode/decode file handles
74 test_file_handles()
75 {
76         local dir=$1
77         local opt=$2
78
79         echo test_file_handles $* | _filter_test_dir
80         $here/src/open_by_handle $opt $dir $NUMFILES
81 }
82
83 # Check stale handles to deleted files/dir
84 create_test_files $testdir
85 test_file_handles $testdir -dp
86
87 # Check non-stale handles to linked files/dir
88 create_test_files $testdir
89 test_file_handles $testdir -rp
90
91 # Check non-stale handles to unlinked open files
92 create_test_files $testdir
93 test_file_handles $testdir -dkr
94
95 # Check non-stale handles to files that were hardlinked and original deleted
96 create_test_files $testdir
97 test_file_handles $testdir -lr
98 test_file_handles $testdir -ur
99
100 # Check non-stale file handles of renamed files
101 create_test_files $testdir
102 test_file_handles $testdir -mr
103
104 # Check non-stale file handles after rename of parent
105 create_test_files $testdir
106 rm -rf $testdir.renamed
107 mv $testdir $testdir.renamed/
108 test_file_handles $testdir.renamed -rp
109
110 # Check non-stale file handles after move to new parent
111 create_test_files $testdir
112 rm -rf $testdir.new
113 mkdir -p $testdir.new
114 mv $testdir/* $testdir.new/
115 test_file_handles $testdir.new -rp
116
117 status=0
118 exit