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