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