153813Simp#!/bin/sh 2120330Simp# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/00.t 211352 2010-08-15 21:24:17Z pjd $ 3100213Simp 452506Simpdesc="unlink removes regular files, symbolic links, fifos and sockets" 552506Simp 6140752Simpdir=`dirname $0` 752506Simp. ${dir}/../misc.sh 852506Simp 952506Simpecho "1..112" 1052506Simp 1152506Simpn0=`namegen` 1252506Simpn1=`namegen` 1352506Simpn2=`namegen` 1452506Simp 1552506Simpexpect 0 mkdir ${n2} 0755 1652506Simpcdir=`pwd` 1752506Simpcd ${n2} 1852506Simp 1952506Simpexpect 0 create ${n0} 0644 2052506Simpexpect regular lstat ${n0} type 2152506Simpexpect 0 unlink ${n0} 2252506Simpexpect ENOENT lstat ${n0} type 2352506Simp 2452506Simpexpect 0 symlink ${n1} ${n0} 2552506Simpexpect symlink lstat ${n0} type 2652506Simpexpect 0 unlink ${n0} 2752506Simpexpect ENOENT lstat ${n0} type 2852506Simp 2952506Simpexpect 0 mkfifo ${n0} 0644 3052506Simpexpect fifo lstat ${n0} type 3152506Simpexpect 0 unlink ${n0} 3252506Simpexpect ENOENT lstat ${n0} type 3352506Simp 3452506Simpexpect 0 mknod ${n0} b 0644 1 2 3552506Simpexpect block lstat ${n0} type 3652506Simpexpect 0 unlink ${n0} 3752506Simpexpect ENOENT lstat ${n0} type 3852506Simp 3952506Simpexpect 0 mknod ${n0} c 0644 1 2 4052506Simpexpect char lstat ${n0} type 41140752Simpexpect 0 unlink ${n0} 42140752Simpexpect ENOENT lstat ${n0} type 43140752Simp 44140752Simpexpect 0 bind ${n0} 45140752Simpexpect socket lstat ${n0} type 46140752Simpexpect 0 unlink ${n0} 47140752Simpexpect ENOENT lstat ${n0} type 48140752Simp 49140752Simp# successful unlink(2) updates ctime. 50140752Simpexpect 0 create ${n0} 0644 51140752Simpexpect 0 link ${n0} ${n1} 52140752Simpctime1=`${fstest} stat ${n0} ctime` 53140752Simpsleep 1 54140752Simpexpect 0 unlink ${n1} 55140752Simpctime2=`${fstest} stat ${n0} ctime` 56140752Simptest_check $ctime1 -lt $ctime2 57140752Simpexpect 0 unlink ${n0} 58140752Simp 59140752Simpexpect 0 mkfifo ${n0} 0644 60140752Simpexpect 0 link ${n0} ${n1} 61140752Simpctime1=`${fstest} stat ${n0} ctime` 62140752Simpsleep 1 63140752Simpexpect 0 unlink ${n1} 64140752Simpctime2=`${fstest} stat ${n0} ctime` 65140752Simptest_check $ctime1 -lt $ctime2 66140752Simpexpect 0 unlink ${n0} 67140752Simp 6852506Simpexpect 0 mknod ${n0} b 0644 1 2 69140749Simpexpect 0 link ${n0} ${n1} 70140749Simpctime1=`${fstest} stat ${n0} ctime` 71140749Simpsleep 1 72140749Simpexpect 0 unlink ${n1} 73140749Simpctime2=`${fstest} stat ${n0} ctime` 74149869Simptest_check $ctime1 -lt $ctime2 75149869Simpexpect 0 unlink ${n0} 76149561Simp 77149869Simpexpect 0 mknod ${n0} c 0644 1 2 78149869Simpexpect 0 link ${n0} ${n1} 7952506Simpctime1=`${fstest} stat ${n0} ctime` 80140793Simpsleep 1 81140793Simpexpect 0 unlink ${n1} 8258545Simpctime2=`${fstest} stat ${n0} ctime` 8352506Simptest_check $ctime1 -lt $ctime2 8465039Simpexpect 0 unlink ${n0} 8565039Simp 86149869Simpexpect 0 bind ${n0} 8752506Simpexpect 0 link ${n0} ${n1} 88140793Simpctime1=`${fstest} stat ${n0} ctime` 89149869Simpsleep 1 90149869Simpexpect 0 unlink ${n1} 91149869Simpctime2=`${fstest} stat ${n0} ctime` 92149869Simptest_check $ctime1 -lt $ctime2 93149869Simpexpect 0 unlink ${n0} 94149869Simp 95149869Simp# unsuccessful unlink(2) does not update ctime. 96149869Simpexpect 0 create ${n0} 0644 97149869Simpctime1=`${fstest} stat ${n0} ctime` 98140793Simpsleep 1 9952506Simpexpect EACCES -u 65534 unlink ${n0} 10052506Simpctime2=`${fstest} stat ${n0} ctime` 10152506Simptest_check $ctime1 -eq $ctime2 10252506Simpexpect 0 unlink ${n0} 10358545Simp 10452506Simpexpect 0 mkfifo ${n0} 0644 10586455Simpctime1=`${fstest} stat ${n0} ctime` 10679270Simpsleep 1 107107359Snonexpect EACCES -u 65534 unlink ${n0} 10852506Simpctime2=`${fstest} stat ${n0} ctime` 10986269Simptest_check $ctime1 -eq $ctime2 11086455Simpexpect 0 unlink ${n0} 111119225Simp 11252506Simpexpect 0 mknod ${n0} b 0644 1 2 113140749Simpctime1=`${fstest} stat ${n0} ctime` 11486455Simpsleep 1 11558545Simpexpect EACCES -u 65534 unlink ${n0} 116104854Simpctime2=`${fstest} stat ${n0} ctime` 117140886Simptest_check $ctime1 -eq $ctime2 11852506Simpexpect 0 unlink ${n0} 11986455Simp 12052506Simpexpect 0 mknod ${n0} c 0644 1 2 12186455Simpctime1=`${fstest} stat ${n0} ctime` 12253813Simpsleep 1 123148141Simpexpect EACCES -u 65534 unlink ${n0} 124100213Simpctime2=`${fstest} stat ${n0} ctime` 12558545Simptest_check $ctime1 -eq $ctime2 12689945Simpexpect 0 unlink ${n0} 12784514Simp 128147872Simpexpect 0 bind ${n0} 12958545Simpctime1=`${fstest} stat ${n0} ctime` 130119234Simpsleep 1 13169138Speterexpect EACCES -u 65534 unlink ${n0} 132118634Simpctime2=`${fstest} stat ${n0} ctime` 133149561Simptest_check $ctime1 -eq $ctime2 13452506Simpexpect 0 unlink ${n0} 13558545Simp 136140837Simpexpect 0 mkdir ${n0} 0755 137140793Simpexpect 0 create ${n0}/${n1} 0644 138140793Simptime=`${fstest} stat ${n0} ctime` 139147872Simpsleep 1 140140793Simpexpect 0 unlink ${n0}/${n1} 14158545Simpmtime=`${fstest} stat ${n0} mtime` 14265039Simptest_check $time -lt $mtime 14392471Simpctime=`${fstest} stat ${n0} ctime` 144140793Simptest_check $time -lt $ctime 145116207Simpexpect 0 rmdir ${n0} 14684514Simp 14779270Simpexpect 0 mkdir ${n0} 0755 148140793Simpexpect 0 mkfifo ${n0}/${n1} 0644 14979270Simptime=`${fstest} stat ${n0} ctime` 150117438Simpsleep 1 151117602Simpexpect 0 unlink ${n0}/${n1} 152148141Simpmtime=`${fstest} stat ${n0} mtime` 153118895Simptest_check $time -lt $mtime 154119240Simpctime=`${fstest} stat ${n0} ctime` 155119240Simptest_check $time -lt $ctime 156119240Simpexpect 0 rmdir ${n0} 157119240Simp 15893620Simpexpect 0 mkdir ${n0} 0755 15986455Simpexpect 0 mknod ${n0}/${n1} b 0644 1 2 160119240Simptime=`${fstest} stat ${n0} ctime` 161119240Simpsleep 1 162119240Simpexpect 0 unlink ${n0}/${n1} 163119240Simpmtime=`${fstest} stat ${n0} mtime` 164119240Simptest_check $time -lt $mtime 165140793Simpctime=`${fstest} stat ${n0} ctime` 166119240Simptest_check $time -lt $ctime 167141122Simpexpect 0 rmdir ${n0} 168141122Simp 169141122Simpexpect 0 mkdir ${n0} 0755 170141122Simpexpect 0 mknod ${n0}/${n1} c 0644 1 2 171141122Simptime=`${fstest} stat ${n0} ctime` 172141122Simpsleep 1 173141122Simpexpect 0 unlink ${n0}/${n1} 174141122Simpmtime=`${fstest} stat ${n0} mtime` 175145247Sdamientest_check $time -lt $mtime 176141122Simpctime=`${fstest} stat ${n0} ctime` 177119240Simptest_check $time -lt $ctime 178119240Simpexpect 0 rmdir ${n0} 179140792Simp 180140792Simpexpect 0 mkdir ${n0} 0755 181141122Simpexpect 0 bind ${n0}/${n1} 182119240Simptime=`${fstest} stat ${n0} ctime` 183140793Simpsleep 1 18486455Simpexpect 0 unlink ${n0}/${n1} 18586455Simpmtime=`${fstest} stat ${n0} mtime` 18689945Simptest_check $time -lt $mtime 187149869Simpctime=`${fstest} stat ${n0} ctime` 18853813Simptest_check $time -lt $ctime 18971279Simpexpect 0 rmdir ${n0} 19071283Simp 191113667Ssanpeiexpect 0 mkdir ${n0} 0755 19253813Simpexpect 0 symlink test ${n0}/${n1} 19352506Simptime=`${fstest} stat ${n0} ctime` 194140793Simpsleep 1 195140792Simpexpect 0 unlink ${n0}/${n1} 196107359Snonmtime=`${fstest} stat ${n0} mtime` 19771283Simptest_check $time -lt $mtime 19852506Simpctime=`${fstest} stat ${n0} ctime` 19952506Simptest_check $time -lt $ctime 20086269Simpexpect 0 rmdir ${n0} 20186269Simp 20252506Simpexpect 0 create ${n0} 0644 20353813Simpexpect 0 link ${n0} ${n1} 20452506Simptime=`${fstest} stat ${n0} ctime` 20565039Simpsleep 1 20686269Simpexpect 0 unlink ${n1} 20786269Simpctime=`${fstest} stat ${n0} ctime` 20886269Simptest_check $time -lt $ctime 209135002Semaxexpect 0 unlink ${n0} 21086269Simp 21152506Simpcd ${cdir} 21252506Simpexpect 0 rmdir ${n2} 21352506Simp