generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 508
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Huawei.  All Rights Reserved.
4 #
5 # FS QA Test 508
6 #
7 # This testcase is trying to test recovery flow of generic filesystem, it needs
8 # creation time support on specified filesystem.
9 # With below steps, once the file is created, creation time attribute should be
10 # valid on the file, after we fsync that file, it expects creation time can be
11 # recovered after sudden power-cuts.
12 # 1. touch testfile;
13 # 1.1 sync (optional)
14 # 2. xfs_io -f testfile -c "fsync";
15 # 3. godown;
16 # 4. umount;
17 # 5. mount;
18 # 6. check creation time
19 #
20 seq=`basename $0`
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
23
24 here=`pwd`
25 tmp=/tmp/$$
26 status=1        # failure is the default!
27 trap "_cleanup; exit \$status" 0 1 2 3 15
28
29 _cleanup()
30 {
31         cd /
32         rm -f $tmp.*
33 }
34
35 # get standard environment, filters and checks
36 . ./common/rc
37 . ./common/filter
38
39 # remove previous $seqres.full before test
40 rm -f $seqres.full
41
42 # real QA test starts here
43 _supported_fs generic
44 _supported_os Linux
45
46 _require_test_lsattr
47 _require_statx
48 _require_xfs_io_command "statx" "-v"
49
50 _require_scratch
51 _require_scratch_shutdown
52 _require_scratch_btime
53
54 _scratch_mkfs >/dev/null 2>&1
55 _require_metadata_journaling $SCRATCH_DEV
56
57 testfile=$SCRATCH_MNT/testfile
58
59 do_check()
60 {
61         _scratch_mount
62
63         touch $testfile
64
65         if [ "$1" == "sync" ]; then
66                 sync
67         fi
68
69         before=`$XFS_IO_PROG -f $testfile -c "statx -v" | grep btime`
70
71         $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
72
73         _scratch_shutdown | tee -a $seqres.full
74         _scratch_cycle_mount
75
76         after=`$XFS_IO_PROG -f $testfile -c "statx -v" | grep btime`
77
78         # check inode's creation time
79         if [ "$before" != "$after" ]; then
80                 echo "Before: $before"
81                 echo "After : $after"
82         fi
83         echo "Before: $before" >> $seqres.full
84         echo "After : $after" >> $seqres.full
85
86         rm -f $testfile
87         _scratch_unmount
88 }
89
90 echo "Silence is golden"
91
92 do_check
93 do_check sync
94
95 status=0
96 exit