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.
38 _require_test_program "stat_test"
39 _require_test_program "af_unix"
42 function check_stat () {
43 $here/src/stat_test $* || echo stat_test failed
46 function create_af_unix () {
47 $here/src/af_unix $* || echo af_unix failed
50 ###############################################################################
52 # Check statx'ing of various types of object
54 # After each object is created, barring the first, we check that the creation
55 # time and the change time of the new object as same as or later than the
56 # corresponding timestamps on the previous object created.
58 ###############################################################################
59 echo "Test statx on a fifo"
60 mkfifo -m 0600 $TEST_DIR/$seq-fifo
61 check_stat $TEST_DIR/$seq-fifo \
69 echo "Test statx on a chardev"
70 mknod -m 0600 $TEST_DIR/$seq-null c 1 3
71 check_stat $TEST_DIR/$seq-null \
73 ref=$TEST_DIR/$seq-fifo \
82 echo "Test statx on a directory"
83 mkdir $TEST_DIR/$seq-dir
84 check_stat $TEST_DIR/$seq-dir \
86 ref=$TEST_DIR/$seq-null \
94 echo "Test statx on a blockdev"
95 mknod -m 0600 $TEST_DIR/$seq-loopy b 7 123
96 check_stat $TEST_DIR/$seq-loopy \
98 ref=$TEST_DIR/$seq-dir \
107 echo "Test statx on a file"
108 dd if=/dev/zero of=$TEST_DIR/$seq-file bs=1024 count=20
109 check_stat $TEST_DIR/$seq-file \
111 ref=$TEST_DIR/$seq-loopy \
120 echo "Test statx on a symlink"
121 ln -s $TEST_DIR/$seq-nowhere $TEST_DIR/$seq-symlink
122 check_stat $TEST_DIR/$seq-symlink \
124 ref=$TEST_DIR/$seq-file \
132 echo "Test statx on an AF_UNIX socket"
133 create_af_unix $TEST_DIR/$seq-sock
134 check_stat $TEST_DIR/$seq-sock \
136 ref=$TEST_DIR/$seq-symlink \
145 # Test hard link creation. Make sure that the file's ctime is now same as or
146 # later than the creation time of the socket, but that the file's creation time
147 # still lies somewhere between those of the directory and the socket.
149 echo "Test a hard link to a file"
150 ln $TEST_DIR/$seq-file $TEST_DIR/$seq-link
151 check_stat $TEST_DIR/$seq-link \
152 ref=$TEST_DIR/$seq-dir \
154 ref=$TEST_DIR/$seq-sock \
158 ref=$TEST_DIR/$seq-file \
162 # Done. We leave the success determination to the output comparator.