00.t revision 271295
1157873Simp#!/bin/sh 2157873Simp# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/00.t 211352 2010-08-15 21:24:17Z pjd $ 3157873Simp 4157873Simpdesc="unlink removes regular files, symbolic links, fifos and sockets" 5157873Simp 6157873Simpdir=`dirname $0` 7157873Simp. ${dir}/../misc.sh 8157873Simp 9157873Simpecho "1..112" 10157873Simp 11157873Simpn0=`namegen` 12157873Simpn1=`namegen` 13157873Simpn2=`namegen` 14157873Simp 15157873Simpexpect 0 mkdir ${n2} 0755 16157873Simpcdir=`pwd` 17157873Simpcd ${n2} 18157873Simp 19157873Simpexpect 0 create ${n0} 0644 20157873Simpexpect regular lstat ${n0} type 21157873Simpexpect 0 unlink ${n0} 22157873Simpexpect ENOENT lstat ${n0} type 23157873Simp 24157873Simpexpect 0 symlink ${n1} ${n0} 25157873Simpexpect symlink lstat ${n0} type 26157873Simpexpect 0 unlink ${n0} 27157873Simpexpect ENOENT lstat ${n0} type 28157873Simp 29157873Simpexpect 0 mkfifo ${n0} 0644 30157873Simpexpect fifo lstat ${n0} type 31157873Simpexpect 0 unlink ${n0} 32157873Simpexpect ENOENT lstat ${n0} type 33157873Simp 34157873Simpexpect 0 mknod ${n0} b 0644 1 2 35157873Simpexpect block lstat ${n0} type 36157873Simpexpect 0 unlink ${n0} 37157873Simpexpect ENOENT lstat ${n0} type 38157873Simp 39157873Simpexpect 0 mknod ${n0} c 0644 1 2 40157873Simpexpect char lstat ${n0} type 41157873Simpexpect 0 unlink ${n0} 42157873Simpexpect ENOENT lstat ${n0} type 43157873Simp 44157873Simpexpect 0 bind ${n0} 45157873Simpexpect socket lstat ${n0} type 46157873Simpexpect 0 unlink ${n0} 47157873Simpexpect ENOENT lstat ${n0} type 48157873Simp 49157873Simp# successful unlink(2) updates ctime. 50157873Simpexpect 0 create ${n0} 0644 51157873Simpexpect 0 link ${n0} ${n1} 52157873Simpctime1=`${fstest} stat ${n0} ctime` 53157873Simpsleep 1 54157873Simpexpect 0 unlink ${n1} 55157873Simpctime2=`${fstest} stat ${n0} ctime` 56157873Simptest_check $ctime1 -lt $ctime2 57157873Simpexpect 0 unlink ${n0} 58157873Simp 59157873Simpexpect 0 mkfifo ${n0} 0644 60157873Simpexpect 0 link ${n0} ${n1} 61157873Simpctime1=`${fstest} stat ${n0} ctime` 62157873Simpsleep 1 63157873Simpexpect 0 unlink ${n1} 64157873Simpctime2=`${fstest} stat ${n0} ctime` 65157873Simptest_check $ctime1 -lt $ctime2 66157873Simpexpect 0 unlink ${n0} 67157873Simp 68157873Simpexpect 0 mknod ${n0} b 0644 1 2 69157873Simpexpect 0 link ${n0} ${n1} 70157873Simpctime1=`${fstest} stat ${n0} ctime` 71157873Simpsleep 1 72157873Simpexpect 0 unlink ${n1} 73157873Simpctime2=`${fstest} stat ${n0} ctime` 74157873Simptest_check $ctime1 -lt $ctime2 75157873Simpexpect 0 unlink ${n0} 76157873Simp 77157873Simpexpect 0 mknod ${n0} c 0644 1 2 78157873Simpexpect 0 link ${n0} ${n1} 79157873Simpctime1=`${fstest} stat ${n0} ctime` 80157873Simpsleep 1 81157873Simpexpect 0 unlink ${n1} 82157873Simpctime2=`${fstest} stat ${n0} ctime` 83157873Simptest_check $ctime1 -lt $ctime2 84157873Simpexpect 0 unlink ${n0} 85157873Simp 86157873Simpexpect 0 bind ${n0} 87157873Simpexpect 0 link ${n0} ${n1} 88157873Simpctime1=`${fstest} stat ${n0} ctime` 89157873Simpsleep 1 90157873Simpexpect 0 unlink ${n1} 91157873Simpctime2=`${fstest} stat ${n0} ctime` 92157873Simptest_check $ctime1 -lt $ctime2 93157873Simpexpect 0 unlink ${n0} 94157873Simp 95157873Simp# unsuccessful unlink(2) does not update ctime. 96157873Simpexpect 0 create ${n0} 0644 97157873Simpctime1=`${fstest} stat ${n0} ctime` 98157873Simpsleep 1 99157873Simpexpect EACCES -u 65534 unlink ${n0} 100157873Simpctime2=`${fstest} stat ${n0} ctime` 101157873Simptest_check $ctime1 -eq $ctime2 102157873Simpexpect 0 unlink ${n0} 103157873Simp 104157873Simpexpect 0 mkfifo ${n0} 0644 105157873Simpctime1=`${fstest} stat ${n0} ctime` 106157873Simpsleep 1 107157873Simpexpect EACCES -u 65534 unlink ${n0} 108157873Simpctime2=`${fstest} stat ${n0} ctime` 109157873Simptest_check $ctime1 -eq $ctime2 110157873Simpexpect 0 unlink ${n0} 111157873Simp 112157873Simpexpect 0 mknod ${n0} b 0644 1 2 113157873Simpctime1=`${fstest} stat ${n0} ctime` 114157873Simpsleep 1 115157873Simpexpect EACCES -u 65534 unlink ${n0} 116157873Simpctime2=`${fstest} stat ${n0} ctime` 117157873Simptest_check $ctime1 -eq $ctime2 118157873Simpexpect 0 unlink ${n0} 119157873Simp 120157873Simpexpect 0 mknod ${n0} c 0644 1 2 121157873Simpctime1=`${fstest} stat ${n0} ctime` 122157873Simpsleep 1 123157873Simpexpect EACCES -u 65534 unlink ${n0} 124157873Simpctime2=`${fstest} stat ${n0} ctime` 125157873Simptest_check $ctime1 -eq $ctime2 126157873Simpexpect 0 unlink ${n0} 127157873Simp 128157873Simpexpect 0 bind ${n0} 129157873Simpctime1=`${fstest} stat ${n0} ctime` 130157873Simpsleep 1 131157873Simpexpect EACCES -u 65534 unlink ${n0} 132157873Simpctime2=`${fstest} stat ${n0} ctime` 133157873Simptest_check $ctime1 -eq $ctime2 134157873Simpexpect 0 unlink ${n0} 135157873Simp 136157873Simpexpect 0 mkdir ${n0} 0755 137157873Simpexpect 0 create ${n0}/${n1} 0644 138157873Simptime=`${fstest} stat ${n0} ctime` 139157873Simpsleep 1 140157873Simpexpect 0 unlink ${n0}/${n1} 141157873Simpmtime=`${fstest} stat ${n0} mtime` 142157873Simptest_check $time -lt $mtime 143157873Simpctime=`${fstest} stat ${n0} ctime` 144157873Simptest_check $time -lt $ctime 145157873Simpexpect 0 rmdir ${n0} 146157873Simp 147157873Simpexpect 0 mkdir ${n0} 0755 148157873Simpexpect 0 mkfifo ${n0}/${n1} 0644 149157873Simptime=`${fstest} stat ${n0} ctime` 150157873Simpsleep 1 151157873Simpexpect 0 unlink ${n0}/${n1} 152157873Simpmtime=`${fstest} stat ${n0} mtime` 153157873Simptest_check $time -lt $mtime 154157873Simpctime=`${fstest} stat ${n0} ctime` 155157873Simptest_check $time -lt $ctime 156157873Simpexpect 0 rmdir ${n0} 157157873Simp 158157873Simpexpect 0 mkdir ${n0} 0755 159157873Simpexpect 0 mknod ${n0}/${n1} b 0644 1 2 160157873Simptime=`${fstest} stat ${n0} ctime` 161157873Simpsleep 1 162157873Simpexpect 0 unlink ${n0}/${n1} 163157873Simpmtime=`${fstest} stat ${n0} mtime` 164157873Simptest_check $time -lt $mtime 165157873Simpctime=`${fstest} stat ${n0} ctime` 166157873Simptest_check $time -lt $ctime 167157873Simpexpect 0 rmdir ${n0} 168157873Simp 169157873Simpexpect 0 mkdir ${n0} 0755 170157873Simpexpect 0 mknod ${n0}/${n1} c 0644 1 2 171157873Simptime=`${fstest} stat ${n0} ctime` 172157873Simpsleep 1 173157873Simpexpect 0 unlink ${n0}/${n1} 174157873Simpmtime=`${fstest} stat ${n0} mtime` 175157873Simptest_check $time -lt $mtime 176157873Simpctime=`${fstest} stat ${n0} ctime` 177157873Simptest_check $time -lt $ctime 178157873Simpexpect 0 rmdir ${n0} 179157873Simp 180157873Simpexpect 0 mkdir ${n0} 0755 181157873Simpexpect 0 bind ${n0}/${n1} 182157873Simptime=`${fstest} stat ${n0} ctime` 183157873Simpsleep 1 184157873Simpexpect 0 unlink ${n0}/${n1} 185157873Simpmtime=`${fstest} stat ${n0} mtime` 186157873Simptest_check $time -lt $mtime 187157873Simpctime=`${fstest} stat ${n0} ctime` 188157873Simptest_check $time -lt $ctime 189157873Simpexpect 0 rmdir ${n0} 190157873Simp 191157873Simpexpect 0 mkdir ${n0} 0755 192157873Simpexpect 0 symlink test ${n0}/${n1} 193157873Simptime=`${fstest} stat ${n0} ctime` 194157873Simpsleep 1 195157873Simpexpect 0 unlink ${n0}/${n1} 196157873Simpmtime=`${fstest} stat ${n0} mtime` 197157873Simptest_check $time -lt $mtime 198157873Simpctime=`${fstest} stat ${n0} ctime` 199157873Simptest_check $time -lt $ctime 200157873Simpexpect 0 rmdir ${n0} 201157873Simp 202157873Simpexpect 0 create ${n0} 0644 203157873Simpexpect 0 link ${n0} ${n1} 204157873Simptime=`${fstest} stat ${n0} ctime` 205157873Simpsleep 1 206157873Simpexpect 0 unlink ${n1} 207157873Simpctime=`${fstest} stat ${n0} ctime` 208157873Simptest_check $time -lt $ctime 209157873Simpexpect 0 unlink ${n0} 210157873Simp 211157873Simpcd ${cdir} 212157873Simpexpect 0 rmdir ${n2} 213157873Simp