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