fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / generic / 477
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test No. 477
6 #
7 # Check open by file handle after cycle mount.
8 #
9 # This test uses load and store of file handles from a temp file to test
10 # decoding file handles after cycle mount and after directory renames.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32
33 # Modify as appropriate.
34 _supported_fs generic
35 _require_test
36 # _require_exportfs already requires open_by_handle, but let's not count on it
37 _require_test_program "open_by_handle"
38 _require_exportfs
39
40 NUMFILES=10
41 testroot=$TEST_DIR/$seq-dir
42 testdir=$testroot/testdir
43
44 # Create test dir and test files, encode file handles and store to tmp file
45 create_test_files()
46 {
47         rm -rf $testdir
48         mkdir -p $testdir
49         $here/src/open_by_handle -cwp -o $tmp.handles_file $testdir $NUMFILES
50 }
51
52 # Decode file handles loaded from tmp file
53 test_file_handles()
54 {
55         local opt=$1
56         local when=$2
57
58         echo test_file_handles after $when
59         $here/src/open_by_handle $opt -i $tmp.handles_file $TEST_DIR $NUMFILES
60 }
61
62 # Decode file handles of files/dir after cycle mount
63 create_test_files
64 _test_cycle_mount
65 test_file_handles -rp "cycle mount"
66
67 # Decode file handles of files/dir after rename of parent and cycle mount
68 create_test_files $testdir
69 rm -rf $testdir.renamed
70 mv $testdir $testdir.renamed/
71 _test_cycle_mount
72 test_file_handles -rp "rename parent"
73
74 # Decode file handles of files/dir after rename of grandparent and cycle mount
75 create_test_files $testdir
76 rm -rf $testroot.renamed
77 mv $testroot $testroot.renamed/
78 _test_cycle_mount
79 test_file_handles -rp "rename grandparent"
80
81 # Decode file handles of files/dir after move to new parent and cycle mount
82 create_test_files $testdir
83 rm -rf $testdir.new
84 mkdir -p $testdir.new
85 mv $testdir/* $testdir.new/
86 _test_cycle_mount
87 test_file_handles -r "move to new parent"
88
89 status=0
90 exit