xref: /freebsd/contrib/pjdfstest/tests/mkdir/00.t (revision 531c2d7af3cd2e64eec94aa1b19c4b2f16fce515)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/00.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="mkdir creates directories"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10echo "1..36"
11
12n0=`namegen`
13n1=`namegen`
14
15expect 0 mkdir ${n1} 0755
16cdir=`pwd`
17cd ${n1}
18
19# POSIX: The file permission bits of the new directory shall be initialized from
20# mode. These file permission bits of the mode argument shall be modified by the
21# process' file creation mask.
22expect 0 mkdir ${n0} 0755
23expect dir,0755 lstat ${n0} type,mode
24expect 0 rmdir ${n0}
25expect 0 mkdir ${n0} 0151
26expect dir,0151 lstat ${n0} type,mode
27expect 0 rmdir ${n0}
28expect 0 -U 077 mkdir ${n0} 0151
29expect dir,0100 lstat ${n0} type,mode
30expect 0 rmdir ${n0}
31expect 0 -U 070 mkdir ${n0} 0345
32expect dir,0305 lstat ${n0} type,mode
33expect 0 rmdir ${n0}
34expect 0 -U 0501 mkdir ${n0} 0345
35expect dir,0244 lstat ${n0} type,mode
36expect 0 rmdir ${n0}
37
38# POSIX: The directory's user ID shall be set to the process' effective user ID.
39# The directory's group ID shall be set to the group ID of the parent directory
40# or to the effective group ID of the process.
41expect 0 chown . 65535 65535
42expect 0 -u 65535 -g 65535 mkdir ${n0} 0755
43expect 65535,65535 lstat ${n0} uid,gid
44expect 0 rmdir ${n0}
45expect 0 -u 65535 -g 65534 mkdir ${n0} 0755
46expect "65535,6553[45]" lstat ${n0} uid,gid
47expect 0 rmdir ${n0}
48expect 0 chmod . 0777
49expect 0 -u 65534 -g 65533 mkdir ${n0} 0755
50expect "65534,6553[35]" lstat ${n0} uid,gid
51expect 0 rmdir ${n0}
52
53# POSIX: Upon successful completion, mkdir() shall mark for update the st_atime,
54# st_ctime, and st_mtime fields of the directory. Also, the st_ctime and
55# st_mtime fields of the directory that contains the new entry shall be marked
56# for update.
57expect 0 chown . 0 0
58time=`${fstest} stat . ctime`
59sleep 1
60expect 0 mkdir ${n0} 0755
61atime=`${fstest} stat ${n0} atime`
62test_check $time -lt $atime
63mtime=`${fstest} stat ${n0} mtime`
64test_check $time -lt $mtime
65ctime=`${fstest} stat ${n0} ctime`
66test_check $time -lt $ctime
67mtime=`${fstest} stat . mtime`
68test_check $time -lt $mtime
69ctime=`${fstest} stat . ctime`
70test_check $time -lt $ctime
71expect 0 rmdir ${n0}
72
73cd ${cdir}
74expect 0 rmdir ${n1}
75