xref: /freebsd/contrib/pjdfstest/tests/mkfifo/00.t (revision a90b9d0159070121c221b966469c3e36d912bf82)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/00.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="mkfifo creates fifo files"
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 FIFO shall be initialized from
20# mode. The file permission bits of the mode argument shall be modified by the
21# process' file creation mask.
22expect 0 mkfifo ${n0} 0755
23expect fifo,0755 lstat ${n0} type,mode
24expect 0 unlink ${n0}
25expect 0 mkfifo ${n0} 0151
26expect fifo,0151 lstat ${n0} type,mode
27expect 0 unlink ${n0}
28expect 0 -U 077 mkfifo ${n0} 0151
29expect fifo,0100 lstat ${n0} type,mode
30expect 0 unlink ${n0}
31expect 0 -U 070 mkfifo ${n0} 0345
32expect fifo,0305 lstat ${n0} type,mode
33expect 0 unlink ${n0}
34expect 0 -U 0501 mkfifo ${n0} 0345
35expect fifo,0244 lstat ${n0} type,mode
36expect 0 unlink ${n0}
37
38# POSIX: The FIFO's user ID shall be set to the process' effective user ID.
39# The FIFO's group ID shall be set to the group ID of the parent directory or to
40# the effective group ID of the process.
41expect 0 chown . 65535 65535
42expect 0 -u 65535 -g 65535 mkfifo ${n0} 0755
43expect 65535,65535 lstat ${n0} uid,gid
44expect 0 unlink ${n0}
45expect 0 -u 65535 -g 65534 mkfifo ${n0} 0755
46expect "65535,6553[45]" lstat ${n0} uid,gid
47expect 0 unlink ${n0}
48expect 0 chmod . 0777
49expect 0 -u 65534 -g 65533 mkfifo ${n0} 0755
50expect "65534,6553[35]" lstat ${n0} uid,gid
51expect 0 unlink ${n0}
52
53# POSIX: Upon successful completion, mkfifo() shall mark for update the
54# st_atime, st_ctime, and st_mtime fields of the file. 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 mkfifo ${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 unlink ${n0}
72
73cd ${cdir}
74expect 0 rmdir ${n1}
75