misc: move exit status into trap handler
[xfstests-dev.git] / tests / generic / 547
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 547
6 #
7 # Run fsstress, fsync every file and directory, simulate a power failure and
8 # then verify that all files and directories exist, with the same data and
9 # metadata they had before the power failure.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         _cleanup_flakey
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/dmflakey
29
30 # real QA test starts here
31 _supported_fs generic
32 _require_test
33 _require_scratch
34 _require_fssum
35 _require_dm_target flakey
36
37 rm -f $seqres.full
38
39 fssum_files_dir=$TEST_DIR/generic-test-$seq
40 rm -fr $fssum_files_dir
41 mkdir $fssum_files_dir
42
43 _scratch_mkfs >>$seqres.full 2>&1
44 _require_metadata_journaling $SCRATCH_DEV
45 _init_flakey
46 _mount_flakey
47
48 mkdir $SCRATCH_MNT/test
49 args=`_scale_fsstress_args -p 4 -n 100 $FSSTRESS_AVOID -d $SCRATCH_MNT/test`
50 args="$args -f mknod=0 -f symlink=0"
51 echo "Running fsstress with arguments: $args" >>$seqres.full
52 $FSSTRESS_PROG $args >>$seqres.full
53
54 # Fsync every file and directory.
55 find $SCRATCH_MNT/test \( -type f -o -type d \) -exec $XFS_IO_PROG -c fsync {} \;
56
57 # Compute a digest of the filesystem (using the test directory only, to skip
58 # fs specific directories such as "lost+found" on ext4 for example).
59 $FSSUM_PROG -A -f -w $fssum_files_dir/fs_digest $SCRATCH_MNT/test
60
61 # Simulate a power failure and mount the filesystem to check that all files and
62 # directories exist and have all data and metadata preserved.
63 _flakey_drop_and_remount
64
65 # Compute a new digest and compare it to the one we created previously, they
66 # must match.
67 $FSSUM_PROG -r $fssum_files_dir/fs_digest $SCRATCH_MNT/test
68
69 _unmount_flakey
70
71 status=0
72 exit