fstests: move test group info to test files
[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 . ./common/preamble
17 _begin_fstest auto attr quick dax
18
19 # Import common functions.
20 . ./common/filter
21
22 _supported_fs generic
23 _require_scratch_dax_mountopt "dax=always"
24 _require_dax_iflag
25 _require_xfs_io_command "statx" "-r"
26
27 PARENT_DIR=$SCRATCH_MNT/testdir
28 TEST_FILE=$PARENT_DIR/testfile
29
30 test_s_dax()
31 {
32         local dax_option=$1
33         local exp_s_dax1=$2
34         local exp_s_dax2=$3
35
36         # Mount with specified dax option
37         _scratch_mount "$dax_option"
38
39         # Prepare directory
40         mkdir -p $PARENT_DIR
41
42         rm -f $TEST_FILE
43         $XFS_IO_PROG -c "chattr +x" $PARENT_DIR
44         touch $TEST_FILE
45         # Check if setting FS_XFLAG_DAX changes S_DAX flag
46         _check_s_dax $TEST_FILE $exp_s_dax1
47
48         rm -f $TEST_FILE
49         $XFS_IO_PROG -c "chattr -x" $PARENT_DIR
50         touch $TEST_FILE
51         # Check if clearing FS_XFLAG_DAX changes S_DAX flag
52         _check_s_dax $TEST_FILE $exp_s_dax2
53
54         _scratch_unmount
55 }
56
57 do_tests()
58 {
59         _scratch_mkfs >> $seqres.full 2>&1
60
61         # Mount with specified dax option
62         test_s_dax "-o dax=always" 1 1
63         test_s_dax "-o dax=never" 0 0
64         test_s_dax "-o dax=inode" 1 0
65         # Mount without dax option
66         export MOUNT_OPTIONS=""
67         test_s_dax "" 1 0
68 }
69
70 do_tests
71
72 # success, all done
73 echo "Silence is golden"
74 status=0
75 exit