xref: /freebsd/contrib/pjdfstest/tests/utimensat/05.t (revision 81ad6265)
1#! /bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD$
4
5desc="utimensat can follow symlinks"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10require "utimensat"
11
12echo "1..16"
13
14n0=`namegen`
15n1=`namegen`
16n2=`namegen`
17DATE1=1900000000 #Sun Mar 17 11:46:40 MDT 2030
18DATE2=1950000000 #Fri Oct 17 04:40:00 MDT 2031
19DATE3=1960000000 #Mon Feb  9 21:26:40 MST 2032
20DATE4=1970000000 #Fri Jun  4 16:13:20 MDT 2032
21DATE5=1980000000 #Tue Sep 28 10:00:00 MDT 2032
22DATE6=1990000000 #Sat Jan 22 02:46:40 MST 2033
23
24expect 0 mkdir ${n1} 0755
25cdir=`pwd`
26cd ${n1}
27
28
29create_file regular ${n0}
30ln -s ${n0} ${n2}
31expect 0 open . O_RDONLY : utimensat 0 ${n0} $DATE1 0 $DATE2 0 0
32
33expect 0 open . O_RDONLY : utimensat 0 ${n2} $DATE3 0 $DATE4 0 AT_SYMLINK_NOFOLLOW
34expect $DATE1 lstat ${n0} atime
35expect $DATE2 lstat ${n0} mtime
36expect $DATE3 lstat ${n2} atime
37expect $DATE4 lstat ${n2} mtime
38
39expect 0 open . O_RDONLY : utimensat 0 ${n2} $DATE5 0 $DATE6 0 0
40expect $DATE5 lstat ${n0} atime
41expect $DATE6 lstat ${n0} mtime
42# If atime is disabled on the current mount, then ${n2}'s atime should still be
43# $DATE3.  However, if atime is enabled, then ${n2}'s atime will be the current
44# system time.  For this test, it's sufficient to simply check that it didn't
45# get set to DATE5
46test_check "$DATE5" -ne `"$fstest" lstat ${n2} atime`
47expect $DATE4 lstat ${n2} mtime
48
49expect 0 unlink ${n0}
50expect 0 unlink ${n2}
51
52cd ${cdir}
53expect 0 rmdir ${n1}
54