generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 423
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 423
6 #
7 # Test the statx system call
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22         rm -rf $TEST_DIR/$seq-*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33
34 # Modify as appropriate.
35 _supported_fs generic
36 _supported_os Linux
37 _require_test
38 _require_test_program "stat_test"
39 _require_test_program "af_unix"
40 _require_statx
41 _require_symlinks
42 _require_mknod
43
44 function check_stat () {
45         $here/src/stat_test $* || echo stat_test failed
46 }
47
48 function create_af_unix () {
49         $here/src/af_unix $* || echo af_unix failed
50 }
51
52 ###############################################################################
53 #
54 # Check statx'ing of various types of object
55 #
56 # After each object is created, barring the first, we check that the creation
57 # time and the change time of the new object as same as or later than the
58 # corresponding timestamps on the previous object created.
59 #
60 ###############################################################################
61 echo "Test statx on a fifo"
62 mkfifo -m 0600 $TEST_DIR/$seq-fifo
63 check_stat $TEST_DIR/$seq-fifo \
64            ts_order \
65            stx_type=fifo \
66            stx_mode=0600 \
67            stx_rdev_major=0 \
68            stx_rdev_minor=0 \
69            stx_nlink=1
70
71 echo "Test statx on a chardev"
72 mknod -m 0600 $TEST_DIR/$seq-null c 1 3
73 check_stat $TEST_DIR/$seq-null \
74            ts_order \
75            ref=$TEST_DIR/$seq-fifo \
76            ts=B,b \
77            ts=M,m \
78            stx_type=char \
79            stx_mode=0600 \
80            stx_rdev_major=1 \
81            stx_rdev_minor=3 \
82            stx_nlink=1
83
84 echo "Test statx on a directory"
85 mkdir $TEST_DIR/$seq-dir
86 check_stat $TEST_DIR/$seq-dir \
87            ts_order \
88            ref=$TEST_DIR/$seq-null \
89            ts=B,b \
90            ts=M,m \
91            stx_type=dir \
92            stx_mode=0755 \
93            stx_rdev_major=0 \
94            stx_rdev_minor=0
95
96 echo "Test statx on a blockdev"
97 mknod -m 0600 $TEST_DIR/$seq-loopy b 7 123
98 check_stat $TEST_DIR/$seq-loopy \
99            ts_order \
100            ref=$TEST_DIR/$seq-dir \
101            ts=B,b \
102            ts=M,m \
103            stx_type=block \
104            stx_mode=0600 \
105            stx_rdev_major=7 \
106            stx_rdev_minor=123 \
107            stx_nlink=1
108
109 echo "Test statx on a file"
110 dd if=/dev/zero of=$TEST_DIR/$seq-file bs=1024 count=20
111 check_stat $TEST_DIR/$seq-file \
112            ts_order \
113            ref=$TEST_DIR/$seq-loopy \
114            ts=B,b \
115            ts=M,m \
116            stx_type=file \
117            stx_size=20480 \
118            stx_rdev_major=0 \
119            stx_rdev_minor=0 \
120            stx_nlink=1
121
122 echo "Test statx on a symlink"
123 ln -s $TEST_DIR/$seq-nowhere $TEST_DIR/$seq-symlink
124 check_stat $TEST_DIR/$seq-symlink \
125            ts_order \
126            ref=$TEST_DIR/$seq-file \
127            ts=B,b \
128            ts=M,m \
129            stx_type=sym \
130            stx_rdev_major=0 \
131            stx_rdev_minor=0 \
132            stx_nlink=1
133
134 echo "Test statx on an AF_UNIX socket"
135 create_af_unix $TEST_DIR/$seq-sock
136 check_stat $TEST_DIR/$seq-sock \
137            ts_order \
138            ref=$TEST_DIR/$seq-symlink \
139            ts=B,b \
140            ts=M,m \
141            stx_type=sock \
142            stx_rdev_major=0 \
143            stx_rdev_minor=0 \
144            stx_nlink=1
145
146 #
147 # Test hard link creation.  Make sure that the file's ctime is now same as or
148 # later than the creation time of the socket, but that the file's creation time
149 # still lies somewhere between those of the directory and the socket.
150 #
151 echo "Test a hard link to a file"
152 ln $TEST_DIR/$seq-file $TEST_DIR/$seq-link
153 check_stat $TEST_DIR/$seq-link \
154            ref=$TEST_DIR/$seq-dir \
155            ts=B,b \
156            ref=$TEST_DIR/$seq-sock \
157            ts=b,B \
158            ts=B,c \
159            ts=C,c \
160            ref=$TEST_DIR/$seq-file \
161            cmp_ref \
162            stx_nlink=2
163
164 # Done.  We leave the success determination to the output comparator.
165 status=0
166 exit