xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / generic / 474
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Chengguang Xu <cgxu519@icloud.com>
4 #
5 # FS QA Test 474
6 #
7 # Inspired by syncfs bug of overlayfs which does not sync dirty inodes in
8 # underlying filesystem.
9 #
10 # Create a small file then run syncfs and shutdown filesystem(or underlying
11 # filesystem of overlayfs) to check syncfs result.
12 #
13 # Test will be skipped if filesystem(or underlying filesystem of overlayfs)
14 # does not support shutdown.
15 #
16 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 here=`pwd`
21 tmp=/tmp/$$
22 status=0
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27         cd /
28         rm -f $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34
35 # remove previous $seqres.full before test
36 rm -f $seqres.full
37
38 # real QA test starts here
39
40 _supported_fs generic
41 _require_fssum
42 _require_scratch
43 _require_scratch_shutdown
44 _require_xfs_io_command "syncfs"
45
46 _scratch_mkfs >/dev/null 2>&1
47 _scratch_mount
48
49 # Background writeback will flush dirty inode by dirty ratio and dirty time
50 # period(default 30 seconds), in order to avoid interference from it,
51 # run sync before test to make all dirty inodes clean, and it also
52 # accelerates syncfs on testing filesystem so that test case can finish
53 # in 30 seconds.
54
55 sync
56
57 # Large fs has a huge size .use_space file, will take long time on running
58 # fssum $SCRATCH_MNT. So change the target path to a sub-dir of $SCRATCH_MNT.
59 localdir=$SCRATCH_MNT/dir
60 mkdir $localdir
61 $XFS_IO_PROG -f -c "pwrite 0 4K" $localdir/testfile >/dev/null 2>&1
62
63 # fssum used for comparing checksum of test file(data & metedata),
64 # exclude checking about atime, block structure, open error.
65 $FSSUM_PROG -ugomAcdES -f -w $tmp.fssum $localdir
66 $XFS_IO_PROG -c "syncfs" $localdir/testfile >/dev/null 2>&1
67 _scratch_shutdown
68 _scratch_cycle_mount
69 $FSSUM_PROG -r $tmp.fssum $localdir
70
71 exit