2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc. All Rights Reserved.
7 # Test the statx system call
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
16 trap "_cleanup; exit \$status" 0 1 2 3 15
22 rm -rf $TEST_DIR/$seq-*
25 # get standard environment, filters and checks
29 # remove previous $seqres.full before test
32 # real QA test starts here
34 # Modify as appropriate.
37 _require_test_program "stat_test"
38 _require_test_program "af_unix"
43 function check_stat () {
44 $here/src/stat_test $* || echo stat_test failed
47 function create_af_unix () {
48 $here/src/af_unix $* || echo af_unix failed
51 ###############################################################################
53 # Check statx'ing of various types of object
55 # After each object is created, barring the first, we check that the creation
56 # time and the change time of the new object as same as or later than the
57 # corresponding timestamps on the previous object created.
59 ###############################################################################
60 echo "Test statx on a fifo"
61 mkfifo -m 0600 $TEST_DIR/$seq-fifo
62 check_stat $TEST_DIR/$seq-fifo \
70 echo "Test statx on a chardev"
71 mknod -m 0600 $TEST_DIR/$seq-null c 1 3
72 check_stat $TEST_DIR/$seq-null \
74 ref=$TEST_DIR/$seq-fifo \
83 echo "Test statx on a directory"
84 mkdir $TEST_DIR/$seq-dir
85 check_stat $TEST_DIR/$seq-dir \
87 ref=$TEST_DIR/$seq-null \
95 echo "Test statx on a blockdev"
96 mknod -m 0600 $TEST_DIR/$seq-loopy b 7 123
97 check_stat $TEST_DIR/$seq-loopy \
99 ref=$TEST_DIR/$seq-dir \
108 echo "Test statx on a file"
109 dd if=/dev/zero of=$TEST_DIR/$seq-file bs=1024 count=20
110 check_stat $TEST_DIR/$seq-file \
112 ref=$TEST_DIR/$seq-loopy \
121 echo "Test statx on a symlink"
122 ln -s $TEST_DIR/$seq-nowhere $TEST_DIR/$seq-symlink
123 check_stat $TEST_DIR/$seq-symlink \
125 ref=$TEST_DIR/$seq-file \
133 echo "Test statx on an AF_UNIX socket"
134 create_af_unix $TEST_DIR/$seq-sock
135 check_stat $TEST_DIR/$seq-sock \
137 ref=$TEST_DIR/$seq-symlink \
146 # Test hard link creation. Make sure that the file's ctime is now same as or
147 # later than the creation time of the socket, but that the file's creation time
148 # still lies somewhere between those of the directory and the socket.
150 echo "Test a hard link to a file"
151 ln $TEST_DIR/$seq-file $TEST_DIR/$seq-link
152 check_stat $TEST_DIR/$seq-link \
153 ref=$TEST_DIR/$seq-dir \
155 ref=$TEST_DIR/$seq-sock \
159 ref=$TEST_DIR/$seq-file \
163 # Done. We leave the success determination to the output comparator.