blob: 2af99f5a0dcc46a2134b1d6f67856708d074161d [file] [log] [blame]
subrata_modak27439682008-06-06 08:44:40 +00001#!/bin/sh
2#
3# Automated tests for utimensat()
4#
5# Copyright (C) 2008, Linux Foundation
6# Written by Michael Kerrisk <mtk.manpages@gmail.com>
7# Licensed under GPLv2 or later
8#
9# Not (yet) included in this automated test set:
10# * AT_SYMLINK_NOFOLLOW in flags: If pathname specifies a symbolic link,
11# then update the timestamps of the link, rather than the file to which
12# it refers.
13# * Setting of nanosecond components of timestamps (support for
14# nanosecond timestamps is file-system-dependent)
15# * "Updated file timestamps are set to the greatest value supported
16# by the file system that is not greater than the specified time."
17# (i.e., if we set timestamp to {0, 999999999}, then the setting
18# is rounded down, rather than up, to unit of timestamp resolution.
19# * Privileged processes should be able to bypass permission checks.
20# (except when file is marked with the "Immutable" EFA).
21
22#=====================================================================
23
subrata_modak8e1b00f2008-06-28 19:23:04 +000024export TCID=utimensat01
25export TST_TOTAL=99
26export TST_COUNT=0
Cui Bixuanac1a51b2015-04-24 09:28:26 +080027. test.sh
subrata_modak27439682008-06-06 08:44:40 +000028
Xiao Yangec566f02017-01-19 15:32:15 +080029if tst_kvcmp -lt "2.6.22"; then
Cui Bixuanac1a51b2015-04-24 09:28:26 +080030 tst_brkm TCONF "System kernel version is less than 2.6.22,cannot execute test"
subrata_modak27439682008-06-06 08:44:40 +000031fi
32
subrata_modak2d3d90c2009-07-10 09:49:34 +000033RESULT_FILE=$TMPDIR/utimensat.result
subrata_modak27439682008-06-06 08:44:40 +000034
subrata_modak2d3d90c2009-07-10 09:49:34 +000035TEST_DIR=$TMPDIR/utimensat_tests
subrata_modak27439682008-06-06 08:44:40 +000036FILE=$TEST_DIR/utimensat.test_file
37
38TEST_PROG=utimensat01
39
subrata_modak8e1b00f2008-06-28 19:23:04 +000040if [ ! -f $LTPROOT/testcases/bin/$TEST_PROG ]; then
Cui Bixuanac1a51b2015-04-24 09:28:26 +080041 tst_brkm TWARN "$LTPROOT/testcases/bin/$TEST_PROG is missing (please check install)"
subrata_modak8e1b00f2008-06-28 19:23:04 +000042fi
43
subrata_modak27439682008-06-06 08:44:40 +000044# Summary counters of all test results
45
46test_num=0
47failed_cnt=0
48passed_cnt=0
49failed_list=""
50
51#=====================================================================
52
subrata_modak74f83db2008-10-21 06:55:17 +000053setup_file()
subrata_modak27439682008-06-06 08:44:40 +000054{
55# $1 is test file pathname
56# $2 is owner for test file (chown(1))
57# $3 is permissions for test file (chmod(1))
58# $4 is "ext2" extended file attributes for test file (chattr(1))
59
60 FILE=$1
61
yaberauneya0d5ca4f2010-02-06 08:34:00 +000062 # Make sure any old version of file is deleted
subrata_modak27439682008-06-06 08:44:40 +000063
64 if test -e $FILE; then
Subrata Modak76ec9752010-06-02 18:15:19 +053065 sudo $s_arg chattr -ai $FILE || return $?
66 sudo $s_arg rm -f $FILE || return $?
subrata_modak27439682008-06-06 08:44:40 +000067 fi
68
69 # Create file and make atime and mtime zero.
70
Garrett Cooperaf936972012-07-16 11:34:09 -070071 sudo $s_arg -u $test_user touch $FILE || return $?
subrata_modak27439682008-06-06 08:44:40 +000072 if ! $TEST_PROG -q $FILE 0 0 0 0 > $RESULT_FILE; then
73 echo "Failed to set up test file $FILE" 1>&2
74 exit 1
75 fi
76
77 read res atime mtime < $RESULT_FILE
78 if test "X$res" != "XSUCCESS" ||
79 test $atime -ne 0 || test $mtime != 0; then
80 echo "Failed to set correct times on test file $FILE" 1>&2
81 exit 1
82 fi
83
84 # Set owner, permissions, and EFAs for file.
85
86 if test -n "$2"; then
Subrata Modak76ec9752010-06-02 18:15:19 +053087 sudo $s_arg chown $2 $FILE || return $?
subrata_modak27439682008-06-06 08:44:40 +000088 fi
subrata_modakedfd5f52009-04-06 05:23:01 +000089
Subrata Modak76ec9752010-06-02 18:15:19 +053090 sudo $s_arg chmod $3 $FILE || return $?
subrata_modak27439682008-06-06 08:44:40 +000091
92 if test -n "$4"; then
Subrata Modak76ec9752010-06-02 18:15:19 +053093 sudo $s_arg chattr $4 $FILE || return $?
subrata_modak27439682008-06-06 08:44:40 +000094 fi
95
96 # Display file setup, for visual verification
97
98 ls -l $FILE | awk '{ printf "Owner=%s; perms=%s; ", $3, $1}'
Subrata Modak76ec9752010-06-02 18:15:19 +053099 if ! sudo $s_arg lsattr -l $FILE | sed 's/, /,/g' | awk '{print "EFAs=" $2}'
Garrett Cooper2aa40f72010-02-18 23:43:02 -0800100 then
101 return $?
102 fi
103
subrata_modak27439682008-06-06 08:44:40 +0000104}
105
subrata_modak74f83db2008-10-21 06:55:17 +0000106test_failed()
subrata_modak27439682008-06-06 08:44:40 +0000107{
Cui Bixuanac1a51b2015-04-24 09:28:26 +0800108 tst_resm TFAIL "FAILED test $test_num"
subrata_modak27439682008-06-06 08:44:40 +0000109
110 failed_cnt=$(expr $failed_cnt + 1)
111 failed_list="$failed_list $test_num"
112}
113
subrata_modak74f83db2008-10-21 06:55:17 +0000114check_result()
subrata_modak27439682008-06-06 08:44:40 +0000115{
116 STATUS=$1 # Exit status from test program
117 EXPECTED_RESULT=$2 # SUCCESS / EACCES / EPERM / EINVAL
118 EXPECT_ATIME_CHANGED=$3 # Should be 'y' or 'n' (only for SUCCESS)
119 EXPECT_MTIME_CHANGED=$4 # Should be 'y' or 'n' (only for SUCCESS)
120
121 test_num=$(expr $test_num + 1)
122
123 # If our test setup failed, stop immediately
124
125 if test $STATUS -gt 1; then
126 echo "FAILED (bad test setup)"
127 exit 1
128 fi
129
130 read res atime mtime < $RESULT_FILE
yaberauneya0d5ca4f2010-02-06 08:34:00 +0000131
subrata_modak27439682008-06-06 08:44:40 +0000132 echo "EXPECTED: $EXPECTED_RESULT $EXPECT_ATIME_CHANGED "\
133 "$EXPECT_MTIME_CHANGED"
134 echo "RESULT: $res $atime $mtime"
135
136 if test "$res" != "$EXPECTED_RESULT"; then
137 test_failed
138 return
139 fi
subrata_modakedfd5f52009-04-06 05:23:01 +0000140
subrata_modak27439682008-06-06 08:44:40 +0000141 passed=1
142
143 # If the test program exited successfully, then check that atime and
144 # and mtime were updated / not updated, as expected.
145
146 if test $EXPECTED_RESULT = "SUCCESS"; then
147 if test $EXPECT_ATIME_CHANGED = "y"; then
148 if test $atime -eq 0; then
149 echo "atime should have changed, but did not"
150 passed=0
151 fi
152 else
153 if test $atime -ne 0; then
154 echo "atime should not have changed, but did"
155 passed=0
156 fi
157 fi
subrata_modakedfd5f52009-04-06 05:23:01 +0000158
subrata_modak27439682008-06-06 08:44:40 +0000159 if test $EXPECT_MTIME_CHANGED = "y"; then
160 if test $mtime -eq 0; then
161 echo "mtime should have changed, but did not"
162 passed=0
163 fi
164 else
165 if test $mtime -ne 0; then
166 echo "mtime should not have changed, but did"
167 passed=0
168 fi
169 fi
subrata_modakedfd5f52009-04-06 05:23:01 +0000170
subrata_modak27439682008-06-06 08:44:40 +0000171 if test $passed -eq 0; then
172 test_failed
173 return
174 fi
175 fi
176
177 passed_cnt=$(expr $passed_cnt + 1)
Cui Bixuanac1a51b2015-04-24 09:28:26 +0800178 tst_resm TPASS "PASSED test $test_num"
subrata_modak27439682008-06-06 08:44:40 +0000179}
180
subrata_modak74f83db2008-10-21 06:55:17 +0000181run_test()
subrata_modak27439682008-06-06 08:44:40 +0000182{
183 # By default, we do three types of test:
184 # a) pathname (pathname != NULL)
185 # b) readable file descriptor (pathname == NULL, dirfd opened O_RDONLY)
186 # c) writable file descriptor (pathname == NULL, dirfd opened O_RDWR).
subrata_modak63412062009-09-16 15:02:10 +0000187 # For this case we also include O_APPEND in open flags, since that
subrata_modak27439682008-06-06 08:44:40 +0000188 # is needed if testing with a file that has the Append-only
189 # attribute enabled.
190
191 # -R says don't do tests with readable file descriptor
192 # -W says don't do tests with writable file descriptor
193
194 OPTIND=1
195
196 do_read_fd_test=1
197 do_write_fd_test=1
198 while getopts "RW" opt; do
199 case "$opt" in
200 R) do_read_fd_test=0
201 ;;
202 W) do_write_fd_test=0
203 ;;
204 *) echo "run_test: bad usage"
205 exit 1
206 ;;
207 esac
208 done
209 shift `expr $OPTIND - 1`
210
211 echo "Pathname test"
212 setup_file $FILE "$1" "$2" "$3"
subrata_modak168472e2008-12-17 06:40:32 +0000213 cp $LTPROOT/testcases/bin/$TEST_PROG ./
214 CMD="./$TEST_PROG -q $FILE $4"
subrata_modak27439682008-06-06 08:44:40 +0000215 echo "$CMD"
Garrett Cooperaf936972012-07-16 11:34:09 -0700216 sudo $s_arg -u $test_user $CMD > $RESULT_FILE
subrata_modak27439682008-06-06 08:44:40 +0000217 check_result $? $5 $6 $7
218 echo
219
220 if test $do_read_fd_test -ne 0; then
221 echo "Readable file descriptor (futimens(3)) test"
222 setup_file $FILE "$1" "$2" "$3"
subrata_modak168472e2008-12-17 06:40:32 +0000223 CMD="./$TEST_PROG -q -d $FILE NULL $4"
subrata_modak27439682008-06-06 08:44:40 +0000224 echo "$CMD"
Garrett Cooperaf936972012-07-16 11:34:09 -0700225 sudo $s_arg -u $test_user $CMD > $RESULT_FILE
subrata_modak27439682008-06-06 08:44:40 +0000226 check_result $? $5 $6 $7
227 echo
228 fi
229
230 # Can't do the writable file descriptor test for immutable files
subrata_modakedfd5f52009-04-06 05:23:01 +0000231 # (even root can't open an immutable file for writing)
subrata_modak27439682008-06-06 08:44:40 +0000232
233 if test $do_write_fd_test -ne 0; then
234 echo "Writable file descriptor (futimens(3)) test"
235 setup_file $FILE "$1" "$2" "$3"
subrata_modak168472e2008-12-17 06:40:32 +0000236 CMD="./$TEST_PROG -q -w -d $FILE NULL $4"
subrata_modak27439682008-06-06 08:44:40 +0000237 echo "$CMD"
Garrett Cooperaf936972012-07-16 11:34:09 -0700238 sudo $s_arg -u $test_user $CMD > $RESULT_FILE
subrata_modak27439682008-06-06 08:44:40 +0000239 check_result $? $5 $6 $7
240 echo
241 fi
242
Subrata Modak76ec9752010-06-02 18:15:19 +0530243 sudo $s_arg chattr -ai $FILE
244 sudo $s_arg rm -f $FILE
245}
246
subrata_modak27439682008-06-06 08:44:40 +0000247#=====================================================================
248
Garrett Cooperaf936972012-07-16 11:34:09 -0700249# Since some automated testing systems have no tty while testing,
250# comment this line in /etc/sudoers to avoid the error message:
251# `sudo: sorry, you must have a tty to run sudo'
252# Use trap to restore this line after program terminates.
253sudoers=/etc/sudoers
254if [ ! -r $sudoers ]; then
Cui Bixuanac1a51b2015-04-24 09:28:26 +0800255 tst_brkm TBROK "can't read $sudoers"
Garrett Cooperaf936972012-07-16 11:34:09 -0700256fi
257pattern="[[:space:]]*Defaults[[:space:]]*requiretty.*"
258if grep -q "^${pattern}" $sudoers; then
259 tst_resm TINFO "Comment requiretty in $sudoers for automated testing systems"
Shuang Qiu6d59a512013-04-16 16:09:51 +0800260 if ! sed -r -i.$$ -e "s/^($pattern)/#\1/" $sudoers; then
Cui Bixuanac1a51b2015-04-24 09:28:26 +0800261 tst_brkm TBROK "failed to mangle $sudoers properly"
Garrett Cooperaf936972012-07-16 11:34:09 -0700262 fi
Garrett Cooper383956b2012-07-16 11:40:23 -0700263 trap 'trap "" EXIT; restore_sudoers' EXIT
Garrett Cooperaf936972012-07-16 11:34:09 -0700264fi
265
Garrett Cooper383956b2012-07-16 11:40:23 -0700266restore_sudoers()
Garrett Cooperaf936972012-07-16 11:34:09 -0700267{
268 tst_resm TINFO "Restore requiretty in $sudoers"
269 mv /etc/sudoers.$$ /etc/sudoers
270}
271
272test_user=nobody
Subrata Modak76ec9752010-06-02 18:15:19 +0530273echo "test sudo for -n option, non-interactive"
Garrett Cooperaf936972012-07-16 11:34:09 -0700274if sudo -h | grep -q -- -n; then
Subrata Modak76ec9752010-06-02 18:15:19 +0530275 s_arg="-n"
276 echo "sudo supports -n"
277else
278 s_arg=
279 echo "sudo does not support -n"
280fi
Garrett Cooperaf936972012-07-16 11:34:09 -0700281
282if ! sudo $s_arg true; then
Cui Bixuanac1a51b2015-04-24 09:28:26 +0800283 tst_brkm TBROK "sudo cannot be run by user non-interactively"
Garrett Cooperaf936972012-07-16 11:34:09 -0700284fi
285if test ! -f $sudoers
Subrata Modak76ec9752010-06-02 18:15:19 +0530286then
Garrett Cooperaf936972012-07-16 11:34:09 -0700287 echo "root ALL=(ALL) ALL" > $sudoers || exit
Subrata Modak76ec9752010-06-02 18:15:19 +0530288 chmod 440 $sudoers
Garrett Cooper383956b2012-07-16 11:40:23 -0700289 trap 'trap "" EXIT; nuke_sudoers' EXIT
Subrata Modak76ec9752010-06-02 18:15:19 +0530290fi
291
Garrett Cooper383956b2012-07-16 11:40:23 -0700292nuke_sudoers()
293{
294 sudo rm -f $sudoers
295}
296
Garrett Cooperaf936972012-07-16 11:34:09 -0700297sudo $s_arg -u $test_user mkdir -p $TEST_DIR
Cui Bixuan9af831c2015-04-29 08:53:40 +0800298
299# Make sure chattr command is supported
300touch $TEST_DIR/tmp_file
301chattr +a $TEST_DIR/tmp_file
302if [ $? -ne 0 ] ; then
303 rm -rf $TEST_DIR
304 tst_brkm TCONF "chattr not supported"
305fi
Cyril Hrubis467f1602016-04-26 13:16:57 +0200306chattr -a $TEST_DIR/tmp_file
Cui Bixuan9af831c2015-04-29 08:53:40 +0800307
yaberauneya0d5ca4f2010-02-06 08:34:00 +0000308cd $TEST_DIR
subrata_modak168472e2008-12-17 06:40:32 +0000309chown root $LTPROOT/testcases/bin/$TEST_PROG
310chmod ugo+x,u+s $LTPROOT/testcases/bin/$TEST_PROG
subrata_modak27439682008-06-06 08:44:40 +0000311
312#=====================================================================
313
314
315echo "============================================================"
316
subrata_modakedfd5f52009-04-06 05:23:01 +0000317echo
subrata_modak27439682008-06-06 08:44:40 +0000318echo "Testing read-only file, owned by self"
subrata_modakedfd5f52009-04-06 05:23:01 +0000319echo
subrata_modak27439682008-06-06 08:44:40 +0000320
321echo "***** Testing times==NULL case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700322run_test -W "" 400 "" "" SUCCESS y y
subrata_modak27439682008-06-06 08:44:40 +0000323
324echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700325run_test -W "" 400 "" "0 n 0 n" SUCCESS y y
subrata_modak27439682008-06-06 08:44:40 +0000326
327echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700328run_test -W "" 400 "" "0 o 0 o" SUCCESS n n
subrata_modak27439682008-06-06 08:44:40 +0000329
330echo "***** Testing times=={ UTIME_NOW, UTIME_OMIT } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700331run_test -W "" 400 "" "0 n 0 o" SUCCESS y n
subrata_modak27439682008-06-06 08:44:40 +0000332
333echo "***** Testing times=={ UTIME_OMIT, UTIME_NOW } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700334run_test -W "" 400 "" "0 o 0 n" SUCCESS n y
subrata_modak27439682008-06-06 08:44:40 +0000335
336echo "***** Testing times=={ x, y } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700337run_test -W "" 400 "" "1 1 1 1" SUCCESS y y
subrata_modak27439682008-06-06 08:44:40 +0000338
339echo "============================================================"
340
subrata_modakedfd5f52009-04-06 05:23:01 +0000341echo
subrata_modak27439682008-06-06 08:44:40 +0000342echo "Testing read-only file, not owned by self"
subrata_modakedfd5f52009-04-06 05:23:01 +0000343echo
subrata_modak27439682008-06-06 08:44:40 +0000344
345echo "***** Testing times==NULL case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700346run_test -RW root 400 "" "" EACCES
subrata_modak27439682008-06-06 08:44:40 +0000347
348echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700349run_test -RW root 400 "" "0 n 0 n" EACCES
subrata_modak27439682008-06-06 08:44:40 +0000350
351echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700352run_test -RW root 400 "" "0 o 0 o" SUCCESS n n
subrata_modak27439682008-06-06 08:44:40 +0000353
354echo "***** Testing times=={ UTIME_NOW, UTIME_OMIT } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700355run_test -RW root 400 "" "0 n 0 o" EPERM
subrata_modak27439682008-06-06 08:44:40 +0000356
357echo "***** Testing times=={ UTIME_OMIT, UTIME_NOW } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700358run_test -RW root 400 "" "0 o 0 n" EPERM
subrata_modak27439682008-06-06 08:44:40 +0000359
360echo "***** Testing times=={ x, y } case *****"
Garrett Coopere0a89f92010-07-21 02:15:21 -0700361run_test -RW root 400 "" "1 1 1 1" EPERM
subrata_modak27439682008-06-06 08:44:40 +0000362
363echo "============================================================"
364
subrata_modakedfd5f52009-04-06 05:23:01 +0000365echo
subrata_modak27439682008-06-06 08:44:40 +0000366echo "Testing writable file, not owned by self"
subrata_modakedfd5f52009-04-06 05:23:01 +0000367echo
subrata_modak27439682008-06-06 08:44:40 +0000368
369echo "***** Testing times==NULL case *****"
370run_test root 666 "" "" SUCCESS y y
371
372echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
373run_test root 666 "" "0 n 0 n" SUCCESS y y
374
375echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
376run_test root 666 "" "0 o 0 o" SUCCESS n n
377
378echo "***** Testing times=={ UTIME_NOW, UTIME_OMIT } case *****"
379run_test root 666 "" "0 n 0 o" EPERM
380
381echo "***** Testing times=={ UTIME_OMIT, UTIME_NOW } case *****"
382run_test root 666 "" "0 o 0 n" EPERM
383
384echo "***** Testing times=={ x, y } case *****"
385run_test root 666 "" "1 1 1 1" EPERM
386
387echo "============================================================"
388
subrata_modakedfd5f52009-04-06 05:23:01 +0000389echo
subrata_modak27439682008-06-06 08:44:40 +0000390echo "Testing append-only file, owned by self"
subrata_modakedfd5f52009-04-06 05:23:01 +0000391echo
subrata_modak27439682008-06-06 08:44:40 +0000392
393echo "***** Testing times==NULL case *****"
394run_test "" 600 "+a" "" SUCCESS y y
395
396echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
397run_test "" 600 "+a" "0 n 0 n" SUCCESS y y
398
399echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
400run_test "" 600 "+a" "0 o 0 o" SUCCESS n n
401
402echo "***** Testing times=={ UTIME_NOW, UTIME_OMIT } case *****"
403run_test "" 600 "+a" "0 n 0 o" EPERM
404
405echo "***** Testing times=={ UTIME_OMIT, UTIME_NOW } case *****"
406run_test "" 600 "+a" "0 o 0 n" EPERM
407
408echo "***** Testing times=={ x, y } case *****"
409run_test "" 600 "+a" "1 1 1 1" EPERM
410
411echo "============================================================"
412
subrata_modakedfd5f52009-04-06 05:23:01 +0000413echo
subrata_modak27439682008-06-06 08:44:40 +0000414echo "Testing immutable file, owned by self"
subrata_modakedfd5f52009-04-06 05:23:01 +0000415echo
subrata_modak27439682008-06-06 08:44:40 +0000416
417echo "***** Testing times==NULL case *****"
Jan Stancek7c344052017-01-16 15:33:52 +0100418run_test -W "" 600 "+i" "" EACCES
subrata_modak27439682008-06-06 08:44:40 +0000419
420echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
Jan Stancek7c344052017-01-16 15:33:52 +0100421run_test -W "" 600 "+i" "0 n 0 n" EACCES
subrata_modak27439682008-06-06 08:44:40 +0000422
423echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
424run_test -W "" 600 "+i" "0 o 0 o" SUCCESS n n
425
426echo "***** Testing times=={ UTIME_NOW, UTIME_OMIT } case *****"
427run_test -W "" 600 "+i" "0 n 0 o" EPERM
428
429echo "***** Testing times=={ UTIME_OMIT, UTIME_NOW } case *****"
430run_test -W "" 600 "+i" "0 o 0 n" EPERM
431
432echo "***** Testing times=={ x, y } case *****"
433run_test -W "" 600 "+i" "1 1 1 1" EPERM
434
435echo "============================================================"
436
437# Immutable+append-only should have same results as immutable
438
subrata_modakedfd5f52009-04-06 05:23:01 +0000439echo
subrata_modak27439682008-06-06 08:44:40 +0000440echo "Testing immutable append-only file, owned by self"
subrata_modakedfd5f52009-04-06 05:23:01 +0000441echo
subrata_modak27439682008-06-06 08:44:40 +0000442
443echo "***** Testing times==NULL case *****"
Jan Stancek7c344052017-01-16 15:33:52 +0100444run_test -W "" 600 "+ai" "" EACCES
subrata_modak27439682008-06-06 08:44:40 +0000445
446echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
Jan Stancek7c344052017-01-16 15:33:52 +0100447run_test -W "" 600 "+ai" "0 n 0 n" EACCES
subrata_modak27439682008-06-06 08:44:40 +0000448
449echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
450run_test -W "" 600 "+ai" "0 o 0 o" SUCCESS n n
451
452echo "***** Testing times=={ UTIME_NOW, UTIME_OMIT } case *****"
453run_test -W "" 600 "+ai" "0 n 0 o" EPERM
454
455echo "***** Testing times=={ UTIME_OMIT, UTIME_NOW } case *****"
456run_test -W "" 600 "+ai" "0 o 0 n" EPERM
457
458echo "***** Testing times=={ x, y } case *****"
459run_test -W "" 600 "+ai" "1 1 1 1" EPERM
460
461echo "============================================================"
462
subrata_modakedfd5f52009-04-06 05:23:01 +0000463echo
subrata_modak27439682008-06-06 08:44:40 +0000464
465# EINVAL should result, if pathname is NULL, dirfd is not
466# AT_FDCWD, and flags contains AT_SYMLINK_NOFOLLOW.
467
468echo "***** Testing pathname==NULL, dirfd!=AT_FDCWD, flags has" \
469 "AT_SYMLINK_NOFOLLOW *****"
470setup_file $FILE "" 600 ""
471CMD="$TEST_PROG -q -n -d $FILE NULL $4"
472echo "$CMD"
473$CMD > $RESULT_FILE
474check_result $? EINVAL
475echo
476
477echo "============================================================"
478
subrata_modakedfd5f52009-04-06 05:23:01 +0000479echo
subrata_modak27439682008-06-06 08:44:40 +0000480
481# If UTIME_NOW / UTIME_OMIT in tv_nsec field, the tv_sec should
482# be ignored.
483
484echo "tv_sec should be ignored if tv_nsec is UTIME_OMIT or UTIME_NOW"
485
486echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
487run_test -RW "" 600 "" "1 n 1 n" SUCCESS y y
488
489echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
490run_test -RW "" 600 "" "1 o 1 o" SUCCESS n n
491
492echo "============================================================"
493
subrata_modakedfd5f52009-04-06 05:23:01 +0000494echo
subrata_modak27439682008-06-06 08:44:40 +0000495
Rishikesh K Rajakadf53e62010-04-16 08:44:17 +0530496rm -rf "$TEST_DIR"
subrata_modak27439682008-06-06 08:44:40 +0000497uname -a
498date
499echo "Total tests: $test_num; passed: $passed_cnt; failed: $failed_cnt"
500if test $failed_cnt -gt 0; then
501 echo "Failed tests: $failed_list"
subrata_modak27439682008-06-06 08:44:40 +0000502fi
503
Cui Bixuanac1a51b2015-04-24 09:28:26 +0800504tst_exit