xref: /freebsd/contrib/pjdfstest/tests/utimensat/02.t (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1#! /bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD$
4
5desc="utimensat with UTIME_OMIT will leave the time unchanged"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10require "utimensat"
11
12echo "1..10"
13
14n0=`namegen`
15n1=`namegen`
16DATE1=1900000000 #Sun Mar 17 11:46:40 MDT 2030
17DATE2=1950000000 #Fri Oct 17 04:40:00 MDT 2031
18
19expect 0 mkdir ${n1} 0755
20cdir=`pwd`
21cd ${n1}
22
23create_file regular ${n0}
24orig_mtime=`$fstest lstat ${n0} mtime`
25expect 0 open . O_RDONLY : utimensat 0 ${n0} $DATE1 0 0 UTIME_OMIT 0
26expect $DATE1 lstat ${n0} atime
27expect $orig_mtime lstat ${n0} mtime
28
29expect 0 open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_OMIT $DATE2 0 0
30expect $DATE1 lstat ${n0} atime
31expect $DATE2 lstat ${n0} mtime
32expect 0 unlink ${n0}
33
34cd ${cdir}
35expect 0 rmdir ${n1}
36