generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 606
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test 606
6 #
7 # By the following cases, verify if statx() can query S_DAX flag
8 # on regular file correctly.
9 # 1) With dax=always option, FS_XFLAG_DAX is ignored and S_DAX flag
10 #    always exists on regular file.
11 # 2) With dax=inode option, setting/clearing FS_XFLAG_DAX can change
12 #    S_DAX flag on regular file.
13 # 3) With dax=never option, FS_XFLAG_DAX is ignored and S_DAX flag
14 #    never exists on regular file.
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=1        # failure is the default!
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 _supported_fs generic
39 _supported_os Linux
40 _require_scratch_dax_mountopt "dax=always"
41 _require_dax_iflag
42 _require_xfs_io_command "statx" "-r"
43
44 PARENT_DIR=$SCRATCH_MNT/testdir
45 TEST_FILE=$PARENT_DIR/testfile
46
47 test_s_dax()
48 {
49         local dax_option=$1
50         local exp_s_dax1=$2
51         local exp_s_dax2=$3
52
53         # Mount with specified dax option
54         _scratch_mount "$dax_option"
55
56         # Prepare directory
57         mkdir -p $PARENT_DIR
58
59         rm -f $TEST_FILE
60         $XFS_IO_PROG -c "chattr +x" $PARENT_DIR
61         touch $TEST_FILE
62         # Check if setting FS_XFLAG_DAX changes S_DAX flag
63         _check_s_dax $TEST_FILE $exp_s_dax1
64
65         rm -f $TEST_FILE
66         $XFS_IO_PROG -c "chattr -x" $PARENT_DIR
67         touch $TEST_FILE
68         # Check if clearing FS_XFLAG_DAX changes S_DAX flag
69         _check_s_dax $TEST_FILE $exp_s_dax2
70
71         _scratch_unmount
72 }
73
74 do_tests()
75 {
76         _scratch_mkfs >> $seqres.full 2>&1
77
78         # Mount with specified dax option
79         test_s_dax "-o dax=always" 1 1
80         test_s_dax "-o dax=never" 0 0
81         test_s_dax "-o dax=inode" 1 0
82         # Mount without dax option
83         export MOUNT_OPTIONS=""
84         test_s_dax "" 1 0
85 }
86
87 do_tests
88
89 # success, all done
90 echo "Silence is golden"
91 status=0
92 exit