generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 455
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Facebook. All Rights Reserved.
4 #
5 # FS QA Test No. 455
6 #
7 # Run fsx with log writes to verify power fail safeness.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 status=1        # failure is the default!
15
16 _cleanup()
17 {
18         _log_writes_cleanup
19 }
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 # get standard environment, filters and checks
23 . ./common/rc
24 . ./common/filter
25 . ./common/dmlogwrites
26
27 # real QA test starts here
28 _supported_fs generic
29 _supported_os Linux
30 _require_test
31 _require_scratch_nocheck
32 _require_log_writes
33
34 rm -f $seqres.full
35
36 check_files()
37 {
38         local name=$1
39
40         # Now look for our files
41         for i in $(find $SANITY_DIR -type f | grep $name | grep mark); do
42                 local filename=$(basename $i)
43                 local mark="${filename##*.}"
44                 echo "checking $filename" >> $seqres.full
45                 _log_writes_replay_log $filename $SCRATCH_DEV
46                 _scratch_mount
47                 local expected_md5=$(_md5_checksum $i)
48                 local md5=$(_md5_checksum $SCRATCH_MNT/$name)
49                 [ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
50                 _scratch_unmount
51                 _check_scratch_fs
52         done
53 }
54
55 SANITY_DIR=$TEST_DIR/fsxtests
56 rm -rf $SANITY_DIR
57 mkdir $SANITY_DIR
58
59 # Create the log
60 _log_writes_init $SCRATCH_DEV
61
62 _log_writes_mkfs >> $seqres.full 2>&1
63
64 # Log writes emulates discard support, turn it on for maximum crying.
65 _log_writes_mount -o discard
66
67 NUM_FILES=4
68 NUM_OPS=200
69 FSX_OPTS="-N $NUM_OPS -d -P $SANITY_DIR -i $LOGWRITES_DMDEV"
70 # Set random seeds for fsx runs (0 for timestamp + pid)
71 # When test failure is detected, check the seed values printed
72 # by fsx processes to $seqres.full and set them in this array
73 # to repeat the same fsx runs
74 seeds=(0 0 0 0)
75 # Run fsx for a while
76 for j in `seq 0 $((NUM_FILES-1))`; do
77         run_check $here/ltp/fsx $FSX_OPTS -S ${seeds[$j]} -j $j $SCRATCH_MNT/testfile$j &
78 done
79 wait
80
81 test_md5=()
82 for j in `seq 0 $((NUM_FILES-1))`; do
83         test_md5[$j]=$(_md5_checksum $SCRATCH_MNT/testfile$j)
84 done
85
86 # Unmount the scratch dir and tear down the log writes target
87 _log_writes_mark last
88 _log_writes_unmount
89 _log_writes_mark end
90 _log_writes_remove
91 _check_scratch_fs
92
93 # check pre umount
94 echo "checking pre umount" >> $seqres.full
95 _log_writes_replay_log last $SCRATCH_DEV
96 _scratch_mount
97 _scratch_unmount
98 _check_scratch_fs
99
100 for j in `seq 0 $((NUM_FILES-1))`; do
101         check_files testfile$j
102 done
103
104 # Check the end
105 echo "checking post umount" >> $seqres.full
106 _log_writes_replay_log end $SCRATCH_DEV
107 _scratch_mount
108 for j in `seq 0 $((NUM_FILES-1))`; do
109         md5=$(_md5_checksum $SCRATCH_MNT/testfile$j)
110         [ "${md5}" != "${test_md5[$j]}" ] && _fail "testfile$j end md5sum mismatched"
111 done
112 _scratch_unmount
113 _check_scratch_fs
114
115 echo "Silence is golden"
116 status=0
117 exit