Add a regression test for mkdir(2) and rmdir(2).

This commit is contained in:
thorpej 2002-01-27 21:49:46 +00:00
parent 1731882d0a
commit abcece08e4
3 changed files with 53 additions and 2 deletions
regress/sys/fs

@ -1,5 +1,5 @@
# $NetBSD: Makefile,v 1.1 1999/03/10 18:56:46 bouyer Exp $
# $NetBSD: Makefile,v 1.2 2002/01/27 21:49:46 thorpej Exp $
SUBDIR=
SUBDIR= mkdir
.include <bsd.subdir.mk>

@ -0,0 +1,9 @@
# $NetBSD: Makefile,v 1.1 2002/01/27 21:49:46 thorpej Exp $
PROG= mkdir
NOMAN= # defined
regress: ${PROG}
@./${PROG} || (echo 'mkdir test failed' && exit 1)
.include <bsd.prog.mk>

@ -0,0 +1,42 @@
/* $NetBSD: mkdir.c,v 1.1 2002/01/27 21:49:46 thorpej Exp $ */
/*
* Written by Jason R. Thorpe, Jan 27, 2002.
* Public domain.
*/
#include <sys/types.h>
#include <err.h>
#include <unistd.h>
static const char *testdirnames[] = {
/*
* IEEE 1003.1 second ed. 2.2.2.78:
*
* If the pathname refers to a directory, it may also have
* one or more trailing slashes. Multiple successive slashes
* are considered to be the same as one slash.
*/
"dir1/",
"dir2//",
NULL,
};
int main(int, char *[]);
int
main(int argc, char *argv[])
{
int i;
for (i = 0; testdirnames[i] != NULL; i++) {
(void) rmdir(testdirnames[i]);
if (mkdir(testdirnames[i], 0777))
err(1, "mkdir(\"%s\", 0777)", testdirnames[i]);
if (rmdir(testdirnames[i]))
err(1, "rmdir(\"%s\")", testdirnames[i]);
}
exit(0);
}