From: Thomas Veerman Date: Fri, 26 Aug 2011 13:16:16 +0000 (+0000) Subject: Clean up tests and do runtime test for max name length X-Git-Tag: v3.2.0~332 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/index.html?a=commitdiff_plain;h=27a2afc1e7dd8408ab1fc229b53455012163bd37;p=minix.git Clean up tests and do runtime test for max name length - Remove unused code - Use standard functions declared in common.c - Change tests to do a runtime test for the max name length of a path component (aka NAME_MAX). The actual value might differ from the hard coded NAME_MAX depending on the file system used. --- diff --git a/test/common.c b/test/common.c index 5aa66fa93..f42bdca58 100644 --- a/test/common.c +++ b/test/common.c @@ -15,6 +15,7 @@ int common_test_nr = -1, errct = 0, subtest; _PROTOTYPE(void cleanup, (void)); _PROTOTYPE(int does_fs_truncate, (void)); _PROTOTYPE(void e, (int n)); +_PROTOTYPE(int name_max, (char *path)); _PROTOTYPE(void quit, (void)); _PROTOTYPE(void rm_rf_dir, (int test_nr)); _PROTOTYPE(void rm_rf_ppdir, (int test_nr)); @@ -59,6 +60,14 @@ int does_fs_truncate(void) return(does_truncate); } +int name_max(char *path) +{ + struct statvfs stvfs; + + if (statvfs(path, &stvfs) != 0) e(7779); + return(stvfs.f_namemax); +} + void rm_rf_dir(test_nr) int test_nr; diff --git a/test/test20.c b/test/test20.c index 68b2aaf04..06d5370e8 100644 --- a/test/test20.c +++ b/test/test20.c @@ -27,22 +27,15 @@ #define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir) #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a) -int errct = 0; -int subtest = 1; +#include "common.c" + int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ -char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ -char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test20a, (void)); _PROTOTYPE(void test20b, (void)); _PROTOTYPE(void test20c, (void)); _PROTOTYPE(void test20d, (void)); _PROTOTYPE(int do_check, (void)); -_PROTOTYPE(void makelongnames, (void)); -_PROTOTYPE(void e, (int number)); -_PROTOTYPE(void quit, (void)); char executable[1024]; @@ -60,11 +53,7 @@ int main(int argc, char *argv[]) strcpy(executable, "../"); strcat(executable, argv[0]); - printf("Test 20 "); - fflush(stdout); - System("rm -rf DIR_20; mkdir DIR_20"); - Chdir("DIR_20"); - makelongnames(); + start(20); superuser = (geteuid() == 0); for (i = 0; i < ITERATIONS; i++) { @@ -339,57 +328,3 @@ int do_check() return retval; } -void makelongnames() -{ - register int i; - - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; - for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ - MaxPath[i++] = '.'; - MaxPath[i] = '/'; - } - MaxPath[PATH_MAX - 1] = '\0'; - - strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ - strcpy(ToLongPath, MaxPath); - - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ - ToLongPath[PATH_MAX - 1] = '/'; - ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ -} - -void e(n) -int n; -{ - int err_num = errno; /* Save in case printf clobbers it. */ - - printf("Subtest %d, error %d errno=%d: ", subtest, n, errno); - errno = err_num; - perror(""); - if (errct++ > MAX_ERROR) { - printf("Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } - errno = 0; -} - -void quit() -{ - Chdir(".."); - System("rm -rf DIR_20"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else if (errct < 10000) { - printf("%d errors\n", errct); - exit(1); - } else { - printf("errors\n"); - exit(2); - } -} diff --git a/test/test21.c b/test/test21.c index 2a9b83285..961fadb9b 100644 --- a/test/test21.c +++ b/test/test21.c @@ -18,7 +18,7 @@ #define ITERATIONS 1 #define MAX_ERROR 4 -int subtest, errct; +#include "common.c" _PROTOTYPE(int main, (int argc, char *argv [])); _PROTOTYPE(void test21a, (void)); @@ -36,8 +36,6 @@ _PROTOTYPE(void test21m, (void)); _PROTOTYPE(void test21n, (void)); _PROTOTYPE(void test21o, (void)); _PROTOTYPE(int get_link, (char *name)); -_PROTOTYPE(void e, (int n)); -_PROTOTYPE(void quit, (void)); int main(argc, argv) int argc; @@ -50,12 +48,8 @@ char *argv[]; sync(); if (argc == 2) m = atoi(argv[1]); - printf("Test 21 "); - fflush(stdout); - - system("rm -rf DIR_21; mkdir DIR_21"); - chdir("DIR_21"); + start(21); for (i = 0; i < ITERATIONS; i++) { if (m & 00001) test21a(); if (m & 00002) test21b(); @@ -73,7 +67,6 @@ char *argv[]; if (m & 020000) test21o(); } quit(); - return(-1); /* impossible */ } void test21a() @@ -360,12 +353,6 @@ void test21e() errno = 0; if (mkdir("D1", 0777) != -1) e(8); if (errno != EEXIST) e(9); -#if NAME_MAX == 14 - if (mkdir("D1/ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0777) != 0) e(10); - if (access("D1/ABCDEFGHIJKLMN", 7 ) != 0) e(11); - if (rmdir("D1/ABCDEFGHIJKLMNOPQ") != 0) e(12); - if (access("D1/ABCDEFGHIJKLMN", 7 ) != -1) e(13); -#endif errno = 0; if (mkdir("D1/D2/x", 0777) != -1) e(14); if (errno != ENOENT) e(15); @@ -651,32 +638,3 @@ char *name; return(statbuf.st_nlink); } -void e(n) -int n; -{ - int err_num = errno; /* save errno in case printf clobbers it */ - - printf("Subtest %d, error %d errno=%d ", subtest, n, errno); - errno = err_num; /* restore errno, just in case */ - perror(""); - if (errct++ > MAX_ERROR) { - printf("Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } -} - -void quit() -{ - chdir(".."); - system("rm -rf DIR*"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(1); - } -} diff --git a/test/test22.c b/test/test22.c index 20249ac2b..4be95d05e 100644 --- a/test/test22.c +++ b/test/test22.c @@ -16,8 +16,7 @@ #define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir) #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a) -int errct = 0; /* Total error counter. */ -int subtest = 1; +#include "common.c" _PROTOTYPE(void test22a, (void)); _PROTOTYPE(int mode, (char *filename)); @@ -31,11 +30,7 @@ int main(int argc, char *argv[]) sync(); if (argc == 2) m = atoi(argv[1]); - printf("Test 22 "); - fflush(stdout); - system("chmod 777 DIR_22/* DIR_22/*/* > /dev/null 2>&1"); - System("rm -rf DIR_22; mkdir DIR_22"); - Chdir("DIR_22"); + start(22); for (i = 0; i < ITERATIONS; i++) { if (m & 0001) test22a(); @@ -165,34 +160,3 @@ char *arg; return 0777 ^ mode(arg); } -void e(n) -int n; -{ - int err_num = errno; /* Save in case printf clobbers it. */ - - printf("Subtest %d, error %d errno=%d: ", subtest, n, errno); - errno = err_num; - perror(""); - if (errct++ > MAX_ERROR) { - printf("Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } - errno = 0; -} - -void quit() -{ - Chdir(".."); - system("chmod 777 ../DIR_22/* ../DIR_22/*/* > /dev/null 2>&1"); - System("rm -rf DIR_22"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(1); - } -} diff --git a/test/test23.c b/test/test23.c index 1b2bbbcd4..059c8bd58 100644 --- a/test/test23.c +++ b/test/test23.c @@ -25,17 +25,15 @@ int superuser; /* True if we are root. */ char cwd[PATH_MAX]; /* Space for path names. */ char cwd2[PATH_MAX]; char buf[PATH_MAX]; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *ToLongName; /* Name of maximum +1 length */ char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test23a, (void)); _PROTOTYPE(void test23b, (void)); _PROTOTYPE(void test23c, (void)); _PROTOTYPE(void makelongnames, (void)); /* Fill MaxName etc. */ -_PROTOTYPE(char *last_index, (char *string, int ch)); -_PROTOTYPE(char *my_getcwd, (char *buf, int size)); int main(int argc, char *argv[]) { @@ -135,7 +133,7 @@ void test23b() System("rm -rf ../DIR_23/*"); - /* Fiddle with the size (2nt) parameter of `getcwd ()'. */ + /* Fiddle with the size (2nd) parameter of `getcwd ()'. */ if (getcwd(cwd, PATH_MAX) != cwd) e(1); /* get cwd */ if (getcwd(buf, strlen(cwd)) != (char *) 0) e(2); /* size 1 to small */ if (errno != ERANGE) e(3); @@ -279,9 +277,15 @@ void test23c() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; @@ -291,79 +295,9 @@ void makelongnames() strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ strcpy(ToLongPath, MaxPath); - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ + ToLongName[max_name_length] = 'a'; + ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */ ToLongPath[PATH_MAX - 1] = '/'; ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } -/* The following code, is take from pwd written by Adri Koppes */ - -/* My_getcwd() helper. */ -char *last_index(string, ch) -char *string; -char ch; -{ - register char *retval = '\0'; - - while (*string != '\0') { - if (*string == ch) retval = string; - string++; - } - return(retval); -} - -char *my_getcwd(buf, size) -char *buf; -int size; -{ /* should be like getcwd() */ - int sd; - register int fd; - register char *n; - char name[128]; - struct stat s, st, sk; - struct direct d; - - if (size <= 0) return(char *) 0; - - *buf = '\0'; - *name = '\0'; - stat(".", &s); - do { - if ((fd = open("..", O_RDONLY)) < 0) return(char *) 0; - st.st_dev = s.st_dev; - st.st_ino = s.st_ino; - stat("..", &s); - Chdir(".."); - sd = sizeof(struct direct); - if (s.st_dev == st.st_dev) { - do { - if (read(fd, (char *) &d, sd) < sd) return(char *) 0; - } while (d.d_ino != st.st_ino); - } else { - do { - if (read(fd, (char *) &d, sd) < sd) return(char *) 0; - stat(d.d_name, &sk); - } while ((sk.st_dev != st.st_dev) || - (sk.st_ino != st.st_ino)); - } - close(fd); - if (strcmp(".", d.d_name) != 0) { - strcat(name, "/"); - strcat(name, d.d_name); - } - } while ((s.st_ino != st.st_ino) || (s.st_dev != st.st_dev)); - if (*name == '\0') - strncat(buf, "/", size); - else - while ((n = last_index(name, '/')) != NULL) { - n[NAME_MAX] = '\0'; - strncat(buf, n, size - strlen(buf)); - *n = '\0'; - } - strncat(buf, name, size - strlen(buf)); - buf[size - 1] = '\0'; - Chdir(buf); /* get back there */ - return buf; -} - diff --git a/test/test24.c b/test/test24.c index 4b153cabf..b17bba548 100644 --- a/test/test24.c +++ b/test/test24.c @@ -32,21 +32,17 @@ _PROTOTYPE(void makelongnames, (void)); int subtest = 1; int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *ToLongName; /* Name of maximum +1 length */ char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ int main(int argc, char *argv[]) { int i, m = 0xFFFF; - sync(); + start(24); if (argc == 2) m = atoi(argv[1]); - printf("Test 24 "); - fflush(stdout); - System("rm -rf DIR_24; mkdir DIR_24"); - Chdir("DIR_24"); makelongnames(); superuser = (geteuid() == 0); @@ -171,13 +167,18 @@ void test24b() int i, j; /* i = highest open dir count */ DIR *dirp[OVERFLOW_DIR_NR], *dp; struct dirent *dep, *dep1, *dep2; - char name[NAME_MAX + 2]; /* buffer for file name, and count */ + char *name; /* buffer for file name, and count */ int dot = 0, dotdot = 0; + int max_name_length; subtest = 2; System("rm -rf ../DIR_24/*"); + max_name_length = name_max("."); + name = malloc(max_name_length + 2); + memset(name, '\0', max_name_length + 2); + for (i = 0; i < OVERFLOW_DIR_NR; i++) { dirp[i] = opendir("/"); if (dirp[i] == ((DIR *) NULL)) { @@ -195,7 +196,7 @@ void test24b() System("rm -rf foo; mkdir foo"); Chdir("foo"); name[0] = 0; - for (i = 0; i <= NAME_MAX; i++) { + for (i = 0; i <= max_name_length; i++) { if (strcat(name, "X") != name) e(5); close(creat(name, 0666)); /* fails once on */ } /* XX..XX, 1 too long */ @@ -211,13 +212,13 @@ void test24b() name[strlen(dep->d_name)] += 1; /* 'X' + 1 == 'Y' */ } if (closedir(dp) != 0) e(7); - for (i = 1; i <= NAME_MAX; i++) { /* Check if every length */ + for (i = 1; i <= max_name_length; i++) { /* Check if every length */ if (name[i] != 'Y') e(8); /* has been seen once. */ } /* Check upper and lower bound. */ if (name[0] != 'X') e(9); - if (name[NAME_MAX + 1] != '\0') e(10); + if (name[max_name_length + 1] != '\0') e(10); /* Now check if two simultaniouse open dirs do the same */ if ((dirp[1] = opendir("foo")) == ((DIR *) NULL)) e(11); @@ -343,9 +344,15 @@ DIR *dirp; /* (`f1', `f3', `f5', `.', `..') */ void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; @@ -355,9 +362,8 @@ void makelongnames() strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ strcpy(ToLongPath, MaxPath); - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ + ToLongName[max_name_length] = 'a'; + ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */ ToLongPath[PATH_MAX - 1] = '/'; ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } - diff --git a/test/test25.c b/test/test25.c index d9d2bce6f..789f0a43d 100644 --- a/test/test25.c +++ b/test/test25.c @@ -29,9 +29,9 @@ int subtest = 1; int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *ToLongName; /* Name of maximum +1 length */ char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test25a, (void)); @@ -40,8 +40,6 @@ _PROTOTYPE(void test25c, (void)); _PROTOTYPE(void test25d, (void)); _PROTOTYPE(void test25e, (void)); _PROTOTYPE(void makelongnames, (void)); -_PROTOTYPE(void e, (int number)); -_PROTOTYPE(void quit, (void)); int main(int argc, char *argv[]) { @@ -50,8 +48,8 @@ int main(int argc, char *argv[]) sync(); - if (argc == 2) m = atoi(argv[1]); start(25); + if (argc == 2) m = atoi(argv[1]); makelongnames(); superuser = (geteuid() == 0); @@ -66,7 +64,6 @@ int main(int argc, char *argv[]) if (m & 020) test25e(); } quit(); - return 1; } void test25a() @@ -688,9 +685,15 @@ void test25e() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; @@ -700,8 +703,8 @@ void makelongnames() strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ strcpy(ToLongPath, MaxPath); - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ + ToLongName[max_name_length] = 'a'; + ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */ ToLongPath[PATH_MAX - 1] = '/'; ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } diff --git a/test/test26.c b/test/test26.c index 998e9e9af..e4e455a8f 100644 --- a/test/test26.c +++ b/test/test26.c @@ -20,18 +20,11 @@ #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a) #define Mkfifo(f) if (mkfifo(f,0777)!=0) printf("Can't make fifo %s\n", f) -int errct = 0; -int subtest = 1; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ -char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ -char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ +#include "common.c" _PROTOTYPE(void test26a, (void)); _PROTOTYPE(void test26b, (void)); _PROTOTYPE(void test26c, (void)); -_PROTOTYPE(void e, (int number)); -_PROTOTYPE(void quit, (void)); int main(int argc, char *argv[]) { @@ -39,10 +32,8 @@ int main(int argc, char *argv[]) sync(); if (argc == 2) m = atoi(argv[1]); - printf("Test 26 "); - fflush(stdout); - System("rm -rf DIR_26; mkdir DIR_26"); - Chdir("DIR_26"); + + start(26); for (i = 0; i < 10; i++) { if (m & 0001) test26a(); @@ -241,33 +232,3 @@ void test26c() } } -void e(n) -int n; -{ - int err_num = errno; /* Save in case printf clobbers it. */ - - printf("Subtest %d, error %d errno=%d: ", subtest, n, errno); - errno = err_num; - perror(""); - if (errct++ > MAX_ERROR) { - printf("Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } - errno = 0; -} - -void quit() -{ - Chdir(".."); - System("rm -rf DIR_26"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(1); - } -} diff --git a/test/test27.c b/test/test27.c index a7659cc4e..689486b8d 100644 --- a/test/test27.c +++ b/test/test27.c @@ -19,31 +19,25 @@ #define System(cmd) if (system(cmd) != 0) printf("``%s'' failed\n", cmd) #define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir) -int errct = 0; -int subtest = 1; +#include "common.c" + int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *ToLongName; /* Name of maximum +1 length */ char ToLongPath[PATH_MAX + 1]; _PROTOTYPE(void test27a, (void)); _PROTOTYPE(void test27b, (void)); _PROTOTYPE(void test27c, (void)); _PROTOTYPE(void makelongnames, (void)); -_PROTOTYPE(void e, (int __n)); -_PROTOTYPE(void quit, (void)); int main(int argc, char *argv[]) { int i, m = 0xFFFF; - sync(); + start(27); if (argc == 2) m = atoi(argv[1]); - printf("Test 27 "); - fflush(stdout); - System("rm -rf DIR_27; mkdir DIR_27"); - Chdir("DIR_27"); superuser = (getuid() == 0); makelongnames(); @@ -295,9 +289,15 @@ void test27c() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; @@ -307,39 +307,9 @@ void makelongnames() strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ strcpy(ToLongPath, MaxPath); - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ + ToLongName[max_name_length] = 'a'; + ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */ ToLongPath[PATH_MAX - 1] = '/'; ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } -void e(n) -int n; -{ - int err_num = errno; /* Save in case printf clobbers it. */ - - printf("Subtest %d, error %d errno=%d: ", subtest, n, errno); - errno = err_num; - perror(""); - if (errct++ > MAX_ERROR) { - printf("Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } - errno = 0; -} - -void quit() -{ - Chdir(".."); - System("rm -rf DIR_27"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(1); - } -} diff --git a/test/test28.c b/test/test28.c index b232b3a1c..0abee297a 100644 --- a/test/test28.c +++ b/test/test28.c @@ -32,9 +32,9 @@ int subtest = 1; int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *ToLongName; /* Name of maximum +1 length */ char ToLongPath[PATH_MAX + 1]; _PROTOTYPE(void test28a, (void)); @@ -59,7 +59,6 @@ int main(int argc, char *argv[]) if (m & 0004) test28c(); } quit(); - return 1; } void test28a() @@ -393,9 +392,15 @@ void test28c() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; @@ -405,9 +410,8 @@ void makelongnames() strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ strcpy(ToLongPath, MaxPath); - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ + ToLongName[max_name_length] = 'a'; + ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */ ToLongPath[PATH_MAX - 1] = '/'; ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } - diff --git a/test/test29.c b/test/test29.c index 5e209e1b7..c797ca6e4 100644 --- a/test/test29.c +++ b/test/test29.c @@ -34,19 +34,13 @@ #define IS_CLOEXEC(fd) ((fcntl(fd, F_GETFD) & FD_CLOEXEC) == FD_CLOEXEC) #define SET_CLOEXEC(fd) fcntl(fd, F_SETFD, FD_CLOEXEC) -int errct = 0; -int subtest = 1; +#include "common.c" + int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ -char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ -char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test29a, (void)); _PROTOTYPE(void test29b, (void)); _PROTOTYPE(void test29c, (void)); -_PROTOTYPE(void e, (int number)); -_PROTOTYPE(void quit, (void)); int main(int argc, char *argv[]) { @@ -54,10 +48,8 @@ int main(int argc, char *argv[]) sync(); if (argc == 2) m = atoi(argv[1]); - printf("Test 29 "); - fflush(stdout); - System("rm -rf DIR_29; mkdir DIR_29"); - Chdir("DIR_29"); + + start(29); superuser = (geteuid() == 0); for (i = 0; i < ITERATIONS; i++) { @@ -210,34 +202,3 @@ void test29c() System("rm -rf ../DIR_29/*"); } - -void e(n) -int n; -{ - int err_num = errno; /* Save in case printf clobbers it. */ - - printf("Subtest %d, error %d errno=%d: ", subtest, n, errno); - errno = err_num; - perror(""); - if (errct++ > MAX_ERROR) { - printf("Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } - errno = 0; -} - -void quit() -{ - Chdir(".."); - System("rm -rf DIR_29"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(1); - } -} diff --git a/test/test30.c b/test/test30.c index 49a84d4ef..1ef2b4543 100644 --- a/test/test30.c +++ b/test/test30.c @@ -28,19 +28,16 @@ #define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir) #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a) -int subtest = 1; int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *ToLongName; /* Name of maximum +1 length */ char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test30a, (void)); _PROTOTYPE(void test30b, (void)); _PROTOTYPE(void test30c, (void)); _PROTOTYPE(void makelongnames, (void)); -_PROTOTYPE(void e, (int number)); -_PROTOTYPE(void quit, (void)); int main(int argc, char *argv[]) { @@ -286,9 +283,15 @@ void test30c() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; @@ -298,9 +301,8 @@ void makelongnames() strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ strcpy(ToLongPath, MaxPath); - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ + ToLongName[max_name_length] = 'a'; + ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */ ToLongPath[PATH_MAX - 1] = '/'; ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } - diff --git a/test/test31.c b/test/test31.c index 4880eee1c..06f26a21d 100644 --- a/test/test31.c +++ b/test/test31.c @@ -21,11 +21,10 @@ #define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir) #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a) -int subtest = 1; int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *ToLongName; /* Name of maximum +1 length */ char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test31a, (void)); @@ -214,9 +213,15 @@ void test31c() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; @@ -226,9 +231,8 @@ void makelongnames() strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ strcpy(ToLongPath, MaxPath); - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ + ToLongName[max_name_length] = 'a'; + ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */ ToLongPath[PATH_MAX - 1] = '/'; ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } - diff --git a/test/test32.c b/test/test32.c index c04b0ca6a..48055abae 100644 --- a/test/test32.c +++ b/test/test32.c @@ -20,31 +20,26 @@ #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a) #define Creat(f) if (close(creat(f,0777))!=0) printf("Can't creat %s\n",f) -int errct = 0; -int subtest = 1; +#include "common.c" + int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *ToLongName; /* Name of maximum +1 length */ char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test32a, (void)); _PROTOTYPE(void test32b, (void)); _PROTOTYPE(void test32c, (void)); _PROTOTYPE(void makelongnames, (void)); -_PROTOTYPE(void e, (int number)); -_PROTOTYPE(void quit, (void)); int main(int argc, char *argv[]) { int i, m = 0xFFFF; - sync(); + start(32); + if (argc == 2) m = atoi(argv[1]); - printf("Test 32 "); - fflush(stdout); - System("rm -rf DIR_32; mkdir DIR_32"); - Chdir("DIR_32"); makelongnames(); superuser = (geteuid() == 0); @@ -54,7 +49,6 @@ int main(int argc, char *argv[]) if (m & 0004) test32c(); } quit(); - return 1; } #define BUF_SIZE 1024 @@ -315,9 +309,15 @@ void test32c() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; @@ -327,39 +327,8 @@ void makelongnames() strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ strcpy(ToLongPath, MaxPath); - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ + ToLongName[max_name_length] = 'a'; + ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */ ToLongPath[PATH_MAX - 1] = '/'; ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } - -void e(n) -int n; -{ - int err_num = errno; /* Save in case printf clobbers it. */ - - printf("Subtest %d, error %d errno=%d: ", subtest, n, errno); - errno = err_num; - perror(""); - if (errct++ > MAX_ERROR) { - printf("Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } - errno = 0; -} - -void quit() -{ - Chdir(".."); - System("rm -rf DIR_32"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(1); - } -} diff --git a/test/test33.c b/test/test33.c index d37206f21..cce4adf69 100644 --- a/test/test33.c +++ b/test/test33.c @@ -23,11 +23,10 @@ #define Chmod(a,b) if (chmod(a,b) != 0) printf("Can't chmod %s\n", a) #define Mkfifo(f) if (mkfifo(f,0777)!=0) printf("Can't make fifo %s\n", f) -int subtest = 1; int superuser; /* nonzero if uid == euid (euid == 0 always) */ -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *ToLongName; /* Name of maximum +1 length */ char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test33a, (void)); @@ -600,9 +599,15 @@ void test_access() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + ToLongName = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; @@ -612,9 +617,8 @@ void makelongnames() strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ strcpy(ToLongPath, MaxPath); - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ + ToLongName[max_name_length] = 'a'; + ToLongName[max_name_length+1] = '\0';/* extend ToLongName by one too many */ ToLongPath[PATH_MAX - 1] = '/'; ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } - diff --git a/test/test34.c b/test/test34.c index 81970f28c..7776310c9 100644 --- a/test/test34.c +++ b/test/test34.c @@ -39,12 +39,11 @@ /* This program uses /etc/passwd and assumes things about it's contents. */ #define PASSWD_FILE "/etc/passwd" -int subtest = 1; int superuser; int I_can_chown; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; /* Same for path */ -char NameTooLong[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *NameTooLong; /* Name of maximum +1 length */ char PathTooLong[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test34a, (void)); @@ -541,22 +540,28 @@ void test34c() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + NameTooLong = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; } MaxPath[PATH_MAX - 1] = '\0'; - strcpy(NameTooLong, MaxName); /* copy them Max to TooLong */ + strcpy(NameTooLong, MaxName); /* copy them Max to ToLong */ strcpy(PathTooLong, MaxPath); - NameTooLong[NAME_MAX] = 'a'; - NameTooLong[NAME_MAX + 1] = '\0'; /* extend NameTooLong by one too many*/ + NameTooLong[max_name_length] = 'a'; + NameTooLong[max_name_length+1] = '\0';/* extend ToLongName by one too many */ PathTooLong[PATH_MAX - 1] = '/'; - PathTooLong[PATH_MAX] = '\0'; /* inc PathTooLong by one */ + PathTooLong[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } /* Getids returns a valid uid and gid. Is used PASSWD FILE. diff --git a/test/test35.c b/test/test35.c index d49fe3395..b69c68c33 100644 --- a/test/test35.c +++ b/test/test35.c @@ -32,12 +32,11 @@ #define PASSWD_FILE "/etc/passwd" -int subtest = 1; int I_can_chown; int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ +char *MaxName; /* Name of maximum length */ char MaxPath[PATH_MAX]; /* Same for path */ -char NameTooLong[NAME_MAX + 2]; /* Name of maximum +1 length */ +char *NameTooLong; /* Name of maximum +1 length */ char PathTooLong[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test35a, (void)); @@ -283,22 +282,28 @@ void test35c() void makelongnames() { register int i; + int max_name_length; + + max_name_length = name_max("."); /* Aka NAME_MAX, but not every FS supports + * the same length, hence runtime check */ + MaxName = malloc(max_name_length + 1); + NameTooLong = malloc(max_name_length + 1 + 1); /* Name of maximum +1 length */ + memset(MaxName, 'a', max_name_length); + MaxName[max_name_length] = '\0'; - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ MaxPath[i++] = '.'; MaxPath[i] = '/'; } MaxPath[PATH_MAX - 1] = '\0'; - strcpy(NameTooLong, MaxName); /* copy them Max to TooLong */ + strcpy(NameTooLong, MaxName); /* copy them Max to ToLong */ strcpy(PathTooLong, MaxPath); - NameTooLong[NAME_MAX] = 'a'; - NameTooLong[NAME_MAX + 1] = '\0'; /* extend NameTooLong by one too many*/ + NameTooLong[max_name_length] = 'a'; + NameTooLong[max_name_length+1] = '\0';/* extend ToLongName by one too many */ PathTooLong[PATH_MAX - 1] = '/'; - PathTooLong[PATH_MAX] = '\0'; /* inc PathTooLong by one */ + PathTooLong[PATH_MAX] = '\0'; /* inc ToLongPath by one */ } /* Getids returns a valid uid and gid. Is used PASSWD FILE. diff --git a/test/test36.c b/test/test36.c index 463b65f40..21dc41cc6 100644 --- a/test/test36.c +++ b/test/test36.c @@ -19,21 +19,14 @@ #define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir) #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a) -int errct = 0; -int subtest = 1; +#include "common.c" + int superuser; -char MaxName[NAME_MAX + 1]; /* Name of maximum length */ -char MaxPath[PATH_MAX]; /* Same for path */ -char ToLongName[NAME_MAX + 2]; /* Name of maximum +1 length */ -char ToLongPath[PATH_MAX + 1]; /* Same for path, both too long */ _PROTOTYPE(void test36a, (void)); _PROTOTYPE(void test36b, (void)); _PROTOTYPE(void test36c, (void)); _PROTOTYPE(void test36d, (void)); -_PROTOTYPE(void makelongnames, (void)); -_PROTOTYPE(void e, (int number)); -_PROTOTYPE(void quit, (void)); _PROTOTYPE(int not_provided_option, (int _option)); _PROTOTYPE(int provided_option, (int _option, int _minimum_value)); _PROTOTYPE(int variating_option, (int _option, int _minimum_value)); @@ -65,12 +58,8 @@ int main(int argc, char *argv[]) int i, m = 0xFFFF; sync(); + start(36); if (argc == 2) m = atoi(argv[1]); - printf("Test 36 "); - fflush(stdout); - System("rm -rf DIR_36; mkdir DIR_36"); - Chdir("DIR_36"); - makelongnames(); superuser = (geteuid() == 0); for (i = 0; i < ITERATIONS; i++) { @@ -141,58 +130,6 @@ void test36d() System("rm -rf ../DIR_36/*"); } -void makelongnames() -{ - register int i; - - memset(MaxName, 'a', NAME_MAX); - MaxName[NAME_MAX] = '\0'; - for (i = 0; i < PATH_MAX - 1; i++) { /* idem path */ - MaxPath[i++] = '.'; - MaxPath[i] = '/'; - } - MaxPath[PATH_MAX - 1] = '\0'; - - strcpy(ToLongName, MaxName); /* copy them Max to ToLong */ - strcpy(ToLongPath, MaxPath); - - ToLongName[NAME_MAX] = 'a'; - ToLongName[NAME_MAX + 1] = '\0'; /* extend ToLongName by one too many */ - ToLongPath[PATH_MAX - 1] = '/'; - ToLongPath[PATH_MAX] = '\0'; /* inc ToLongPath by one */ -} - -void e(n) -int n; -{ - int err_num = errno; /* Save in case printf clobbers it. */ - - printf("Subtest %d, error %d errno=%d: ", subtest, n, errno); - errno = err_num; - perror(""); - if (errct++ > MAX_ERROR) { - printf("Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } - errno = 0; -} - -void quit() -{ - Chdir(".."); - System("rm -rf DIR_36"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(1); - } -} - int not_provided_option(option) int option; { diff --git a/test/test37.c b/test/test37.c index cb21f1ec3..28876abb8 100644 --- a/test/test37.c +++ b/test/test37.c @@ -17,7 +17,9 @@ #define SIGS 14 #define MAX_ERROR 4 -int iteration, cumsig, subtest, errct = 0, sig1, sig2; +#include "common.c" + +int iteration, cumsig, sig1, sig2; int sigarray[SIGS] = {SIGHUP, SIGILL, SIGTRAP, SIGABRT, SIGIOT, SIGFPE, SIGUSR1, SIGSEGV, SIGUSR2, SIGPIPE, SIGALRM, @@ -64,9 +66,7 @@ _PROTOTYPE(void test37n, (void)); _PROTOTYPE(void catch15, (int signo)); _PROTOTYPE(void test37o, (void)); _PROTOTYPE(void clearsigstate, (void)); -_PROTOTYPE(void quit, (void)); _PROTOTYPE(void wait_for, (int pid)); -_PROTOTYPE(void e, (int n)); int main(argc, argv) int argc; @@ -76,13 +76,9 @@ char *argv[]; sync(); - if (argc == 2) m = atoi(argv[1]); - - printf("Test 37 "); - fflush(stdout); /* have to flush for child's benefit */ + start(37); - system("rm -rf DIR_37; mkdir DIR_37"); - chdir("DIR_37"); + if (argc == 2) m = atoi(argv[1]); for (i = 0; i < ITERATIONS; i++) { iteration = i; @@ -106,7 +102,6 @@ char *argv[]; } quit(); - return(-1); /* impossible */ } void test37a() @@ -1001,21 +996,6 @@ void clearsigstate() sigprocmask(SIG_UNBLOCK, &sigset_var, (sigset_t *)NULL); } -void quit() -{ - - chdir(".."); - system("rm -rf DIR*"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(4); - } -} - void wait_for(pid) pid_t pid; { @@ -1041,17 +1021,3 @@ pid_t pid; } } -void e(n) -int n; -{ - char msgbuf[80]; - - sprintf(msgbuf, "Subtest %d, error %d errno=%d ", subtest, n, errno); - perror(msgbuf); - if (errct++ > MAX_ERROR) { - fprintf(stderr, "Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } -} diff --git a/test/test38.c b/test/test38.c index d3eae8ec3..b3616b9cc 100644 --- a/test/test38.c +++ b/test/test38.c @@ -26,8 +26,8 @@ #define Chdir(dir) if (chdir(dir) != 0) printf("Can't goto %s\n", dir) #define Stat(a,b) if (stat(a,b) != 0) printf("Can't stat %s\n", a) -int errct = 0; -int subtest = 1; +#include "common.c" + int superuser; int signumber = 0; @@ -35,19 +35,15 @@ _PROTOTYPE(void test38a, (void)); _PROTOTYPE(void test38b, (void)); _PROTOTYPE(void test38c, (void)); _PROTOTYPE(void setsignumber, (int _signumber)); -_PROTOTYPE(void e, (int number)); -_PROTOTYPE(void quit, (void)); int main(int argc, char *argv[]) { int i, m = 0xFFFF; sync(); + start(38); + if (argc == 2) m = atoi(argv[1]); - printf("Test 38 "); - fflush(stdout); - System("rm -rf DIR_38; mkdir DIR_38"); - Chdir("DIR_38"); superuser = (geteuid() == 0); umask(0000); @@ -57,7 +53,6 @@ int main(int argc, char *argv[]) if (m & 0004) test38c(); } quit(); - return 1; } void test38a() @@ -736,33 +731,3 @@ int signum; signumber = signum; } -void e(n) -int n; -{ - int err_num = errno; /* Save in case printf clobbers it. */ - - printf("Subtest %d, error %d errno=%d: ", subtest, n, errno); - errno = err_num; - perror(""); - if (errct++ > MAX_ERROR) { - printf("Too many errors; test aborted\n"); - chdir(".."); - system("rm -rf DIR*"); - exit(1); - } - errno = 0; -} - -void quit() -{ - Chdir(".."); - System("rm -rf DIR_38"); - - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(1); - } -} diff --git a/test/test39.c b/test/test39.c index 928776153..31d5ee3e1 100644 --- a/test/test39.c +++ b/test/test39.c @@ -2,38 +2,33 @@ #include #include #include +#define MAX_ERROR 1 +#include "common.c" + +_PROTOTYPE( void test39a, (void) ); int main(int argc, char *argv[]) { - int g, p; - - printf("Test 39 "); + start(39); + quit(); +} - for(g = 0; g <= _ENDPOINT_MAX_GENERATION; g++) { - for(p = -MAX_NR_TASKS; p < _NR_PROCS; p++) { - endpoint_t e; - int mg, mp; - e = _ENDPOINT(g, p); - mg = _ENDPOINT_G(e); - mp = _ENDPOINT_P(e); - if(mg != g || mp != p) { - printf("%d != %d || %d != %d\n", mg, g, mp, p); - return 1; - } - if(g == 0 && e != p) { - printf("%d != %d and g=0\n", e, p); - return 1; - } - if(e == ANY || e == SELF || e == NONE) { - printf("endpoint (%d,%d) is %d; ANY, SELF or NONE\n", - g, p, e); - return 1; - } - } - } +void test39a() +{ + int g, p; - printf("ok\n"); + subtest = 1; - return 0; + for (g = 0; g <= _ENDPOINT_MAX_GENERATION; g++) { + for (p = -MAX_NR_TASKS; p < _NR_PROCS; p++) { + endpoint_t ept; + int mg, mp; + ept = _ENDPOINT(g, p); + mg = _ENDPOINT_G(ept); + mp = _ENDPOINT_P(ept); + if (mg != g || mp != p) e(1); + if (g == 0 && ept != p) e(2); + if (ept == ANY || ept == SELF || ept == NONE) e(3); + } + } } - diff --git a/test/test53.c b/test/test53.c index aea34051a..337bacaed 100644 --- a/test/test53.c +++ b/test/test53.c @@ -11,23 +11,12 @@ #define MAX_ERROR 4 #define TIMED 0 -static volatile int errct; +#include "common.c" + static volatile int expect_SIGFPE; static u64_t i, j, k; static jmp_buf jmpbuf_SIGFPE, jmpbuf_main; -static void quit(void) -{ - if (errct == 0) { - printf("ok\n"); - exit(0); - } else { - printf("%d errors\n", errct); - exit(1); - } - assert(0); /* not reachable */ -} - static void err(int line) { /* print error information */ @@ -272,7 +261,7 @@ static void test(void) int main(void) { - printf("Test 53 "); + start(53); /* set up signal handler to deal with div by zero */ if (setjmp(jmpbuf_main) == 0) { @@ -287,6 +276,4 @@ int main(void) /* this was all */ quit(); - assert(0); /* not reachable */ - return -1; }