From 5e03dd86c8de6180ddbddb16974e5af1a010f60b Mon Sep 17 00:00:00 2001 From: rsc Date: Fri, 10 Aug 2007 17:53:09 +0000 Subject: [PATCH] add test for rm . --- BUGS | 3 --- usertests.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/BUGS b/BUGS index 12f245a..ef4213f 100644 --- a/BUGS +++ b/BUGS @@ -31,9 +31,6 @@ sysfile.c: general: sizeof parens? -usertests.c: - check for rm of . or .. - L=$HOME/mit/l (for i in *.c; do xoc -x xgnu -x ./nodecleq.zeta --typesonly $i; done) 2>&1 | grep warning diff --git a/usertests.c b/usertests.c index a449ed0..59cb0b3 100644 --- a/usertests.c +++ b/usertests.c @@ -984,6 +984,7 @@ fourteen(void) { int fd; + // DIRSIZ is 14. printf(1, "fourteen test\n"); if(mkdir("12345678901234") != 0){ @@ -1019,6 +1020,45 @@ fourteen(void) printf(1, "fourteen ok\n"); } +void +rmdot(void) +{ + printf(1, "rmdot test\n"); + if(mkdir("dots") != 0){ + printf(1, "mkdir dots failed\n"); + exit(); + } + if(chdir("dots") != 0){ + printf(1, "chdir dots failed\n"); + exit(); + } + if(unlink(".") == 0){ + printf(1, "rm . worked!\n"); + exit(); + } + if(unlink("..") == 0){ + printf(1, "rm .. worked!\n"); + exit(); + } + if(chdir("/") != 0){ + printf(1, "chdir / failed\n"); + exit(); + } + if(unlink("dots/.") == 0){ + printf(1, "unlink dots/. worked!\n"); + exit(); + } + if(unlink("dots/..") == 0){ + printf(1, "unlink dots/.. worked!\n"); + exit(); + } + if(unlink("dots") != 0){ + printf(1, "unlink dots failed!\n"); + exit(); + } + printf(1, "rmdot ok\n"); +} + int main(int argc, char *argv[]) { @@ -1040,6 +1080,7 @@ main(int argc, char *argv[]) preempt(); exitwait(); + rmdot(); fourteen(); bigfile(); subdir();