2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc. All Rights Reserved.
7 # Test the statx system call
10 _begin_fstest auto quick
12 # Override the default cleanup function.
17 rm -rf $TEST_DIR/$seq-*
20 # Import common functions.
23 # real QA test starts here
25 # Modify as appropriate.
28 _require_test_program "stat_test"
29 _require_test_program "af_unix"
34 function check_stat () {
35 $here/src/stat_test $* || echo stat_test failed
38 function create_af_unix () {
39 $here/src/af_unix $* || echo af_unix failed
42 ###############################################################################
44 # Check statx'ing of various types of object
46 # After each object is created, barring the first, we check that the creation
47 # time and the change time of the new object as same as or later than the
48 # corresponding timestamps on the previous object created.
50 ###############################################################################
51 echo "Test statx on a fifo"
52 mkfifo -m 0600 $TEST_DIR/$seq-fifo
53 check_stat $TEST_DIR/$seq-fifo \
61 echo "Test statx on a chardev"
62 mknod -m 0600 $TEST_DIR/$seq-null c 1 3
63 check_stat $TEST_DIR/$seq-null \
65 ref=$TEST_DIR/$seq-fifo \
74 echo "Test statx on a directory"
75 mkdir $TEST_DIR/$seq-dir
76 check_stat $TEST_DIR/$seq-dir \
78 ref=$TEST_DIR/$seq-null \
86 echo "Test statx on a blockdev"
87 mknod -m 0600 $TEST_DIR/$seq-loopy b 7 123
88 check_stat $TEST_DIR/$seq-loopy \
90 ref=$TEST_DIR/$seq-dir \
99 echo "Test statx on a file"
100 dd if=/dev/zero of=$TEST_DIR/$seq-file bs=1024 count=20
101 check_stat $TEST_DIR/$seq-file \
103 ref=$TEST_DIR/$seq-loopy \
112 echo "Test statx on a symlink"
113 target=$TEST_DIR/$seq-nowhere
114 ln -s $target $TEST_DIR/$seq-symlink
115 check_stat $TEST_DIR/$seq-symlink \
117 ref=$TEST_DIR/$seq-file \
121 stx_size=${#target} \
126 echo "Test statx on an AF_UNIX socket"
127 create_af_unix $TEST_DIR/$seq-sock
128 check_stat $TEST_DIR/$seq-sock \
130 ref=$TEST_DIR/$seq-symlink \
139 # Test hard link creation. Make sure that the file's ctime is now same as or
140 # later than the creation time of the socket, but that the file's creation time
141 # still lies somewhere between those of the directory and the socket.
143 echo "Test a hard link to a file"
144 ln $TEST_DIR/$seq-file $TEST_DIR/$seq-link
145 check_stat $TEST_DIR/$seq-link \
146 ref=$TEST_DIR/$seq-dir \
148 ref=$TEST_DIR/$seq-sock \
152 ref=$TEST_DIR/$seq-file \
156 # Done. We leave the success determination to the output comparator.