diff --git a/Makefile.in b/Makefile.in index f7da161222..f87c19533c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -140,7 +140,7 @@ prelude: ${TOP_INCDIR}/afs ${TOP_INCDIR}/rx ${TOP_INCDIR}/hcrypto \ project: cmd comerr -tests: all +srctests: sys rx lwp util auth fsint comerr opr hcrypto ${DIR_roken} +${COMPILE_PART1} tests ${COMPILE_PART2} config: prelude @@ -623,7 +623,7 @@ finale_notest: project cmd comerr afsd butc tbutc tbudb @ENABLE_KERNEL_MODULE@ \ bozo @VFSCK@ volser tvolser tsalvaged dviced dvolser libafscp \ venus venustests update xstat afsmonitor rxdebug libafsrpc rfc3961 \ hcrypto libafsauthent libadmin man-pages tools platform kopenafs \ - authtools $(DIR_roken) rxgk rx_test rxkad_test + authtools $(DIR_roken) rxgk rx_test rxkad_test srctests +${COMPILE_PART1} finale ${COMPILE_PART2} finale_nolibafs_notest: project cmd comerr afsd butc tbutc tbudb libuafs audit kauth \ @@ -631,7 +631,7 @@ finale_nolibafs_notest: project cmd comerr afsd butc tbutc tbudb libuafs audit k volser tvolser tsalvaged dviced dvolser libafscp venus venustests \ update xstat afsmonitor rxdebug libafsrpc rfc3961 hcrypto \ libafsauthent libadmin man-pages tools platform kopenafs \ - authtools $(DIR_roken) rxgk rx_test rxkad_test + authtools $(DIR_roken) rxgk rx_test rxkad_test srctests +${COMPILE_PART1} finale ${COMPILE_PART2} finale: finale_notest test_build diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in index d31909b1a9..32365659af 100644 --- a/src/tests/Makefile.in +++ b/src/tests/Makefile.in @@ -4,9 +4,6 @@ include @TOP_OBJDIR@/src/config/Makefile.lwp SHELL = /bin/sh -all: run-tests OpenAFS/Dirpath.pm $(TEST_PROGRAMS) OpenAFS/Dirpath.sh - @chmod +x run-tests - SYS_LIBS = ${TOP_LIBDIR}/libsys.a \ ${TOP_LIBDIR}/librx.a \ ${TOP_LIBDIR}/liblwp.a \ @@ -22,12 +19,12 @@ INT_LIBS = ${TOP_LIBDIR}/libafsint.a \ ${TOP_LIBDIR}/liblwp.a \ ${TOP_LIBDIR}/libafscom_err.a \ ${TOP_LIBDIR}/util.a \ - ${TOP_LIBDIR}/libafsrfc3961.a \ - ${TOP_LIBDIR}/libopr.a \ - $(LIB_roken) \ - $(LIB_hcrypto) + ${TOP_LIBDIR}/libafsrfc3961.a -COMMON_LIBS = ${LIBS} +COMMON_LIBS = ${LIBS} \ + ${TOP_LIBDIR}/libopr.a \ + ${LIB_hcrypto} \ + ${LIB_roken} TEST_PROGRAMS = write-ro-file hello-world read-vs-mmap read-vs-mmap2 \ mmap-and-read large-dir large-dir2 large-dir3 mountpoint \ @@ -82,6 +79,9 @@ TEST_SRCS = write-ro-file.c read-vs-mmap.c read-vs-mmap2.c \ EXTRA_OBJS = err.o errx.o warn.o warnx.o vwarn.o vwarnx.o verr.o verrx.o warnerr.o +all: run-tests OpenAFS/Dirpath.pm $(TEST_PROGRAMS) OpenAFS/Dirpath.sh + @chmod +x run-tests + fsx: fsx.o $(EXTRA_OBJS) $(AFS_LDRULE) fsx.o $(EXTRA_OBJS) $(COMMON_LIBS) @@ -293,6 +293,7 @@ check-fast: run-tests $(TEST_PROGRAMS) # until make is run so we resort to creating the # configuration at make time. OpenAFS/Dirpath.pm: Makefile + mkdir -p OpenAFS @echo "Creating OpenAFS/Dirpath.pm" @echo "# This is -*- perl -*-" >$@ @echo "# auto-generated by src/tests/Makefile" >>$@ @@ -336,6 +337,7 @@ OpenAFS/Dirpath.pm: Makefile @echo "1;" >>$@ OpenAFS/Dirpath.sh: Makefile + mkdir -p OpenAFS @echo "Creating OpenAFS/Dirpath.sh" @echo "# auto-generated by src/tests/Makefile" >$@ @echo "# source or '.' in this file in shell" >>$@ diff --git a/src/tests/afscp.c b/src/tests/afscp.c index 7e24bee2db..6e4ccf6d13 100644 --- a/src/tests/afscp.c +++ b/src/tests/afscp.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tests/asu.c b/src/tests/asu.c index 1216d2908e..27ebee4097 100644 --- a/src/tests/asu.c +++ b/src/tests/asu.c @@ -80,10 +80,18 @@ main(int argc, char **argv) if (setgroups(1, groups)) errx(1, "setgroups failed"); - setgid(gid); - setuid(uid); - setegid(gid); - seteuid(uid); + if (setgid(gid) != 0) { + err(1, "setgid failed"); + } + if (setuid(uid) != 0) { + err(1, "setuid failed"); + } + if (setegid(gid) != 0) { + err(1, "setegid failed"); + } + if (seteuid(uid) != 0) { + err(1, "seteuid failed"); + } } execvp(prog, &argv[2]); diff --git a/src/tests/create-dirs.c b/src/tests/create-dirs.c index f48ce4979e..049a4a53b8 100644 --- a/src/tests/create-dirs.c +++ b/src/tests/create-dirs.c @@ -66,7 +66,7 @@ creat_dirs(int count) static void usage(int ret) { - fprintf(stderr, "%s number-of-dirs\n", __progname); + warnx("number-of-dirs"); exit(ret); } diff --git a/src/tests/create-files.c b/src/tests/create-files.c index 205a78d914..e6524baf63 100644 --- a/src/tests/create-files.c +++ b/src/tests/create-files.c @@ -89,7 +89,7 @@ creat_files(int count, long startsize) static void usage(int ret) { - fprintf(stderr, "%s number-of-files size-of-files\n", __progname); + warnx("number-of-files size-of-files"); exit(ret); } diff --git a/src/tests/create-remove.c b/src/tests/create-remove.c index 116f57dafc..334a8387f5 100644 --- a/src/tests/create-remove.c +++ b/src/tests/create-remove.c @@ -86,7 +86,7 @@ unlink_file(const char *name) static void usage(int ret) { - fprintf(stderr, "%s [file|dir] number-of-dirs\n", __progname); + warnx("[file|dir] number-of-dirs"); exit(ret); } diff --git a/src/tests/create-stat.c b/src/tests/create-stat.c index 85093b0800..3fa4f83c05 100644 --- a/src/tests/create-stat.c +++ b/src/tests/create-stat.c @@ -34,6 +34,8 @@ #include #include +#include + #include #include #include @@ -52,7 +54,7 @@ static void usage(int ret) { - fprintf(stderr, "%s file\n", __progname); + warnx("file"); exit(ret); } diff --git a/src/tests/create-symlinks.c b/src/tests/create-symlinks.c index 441e713430..f5148694ce 100644 --- a/src/tests/create-symlinks.c +++ b/src/tests/create-symlinks.c @@ -109,7 +109,7 @@ verify_contents(int count) static void usage(int ret) { - fprintf(stderr, "%s number-of-symlinks\n", __progname); + warnx("number-of-symlinks"); exit(ret); } diff --git a/src/tests/err.h b/src/tests/err.h index f0d352906d..4495996990 100644 --- a/src/tests/err.h +++ b/src/tests/err.h @@ -67,5 +67,6 @@ void vwarnx(const char *fmt, va_list ap) __attribute__ ((format(printf, 1, 0))); void warnx(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); - +void warnerr(int doerrno, const char *fmt, va_list ap) + __attribute__ ((format(printf, 2, 0))); #endif /* __ERR_H__ */ diff --git a/src/tests/fsx.c b/src/tests/fsx.c index dcf0396273..5d845c08c6 100644 --- a/src/tests/fsx.c +++ b/src/tests/fsx.c @@ -17,12 +17,10 @@ #if defined(sun) || defined(_UWIN) || defined(__linux) # include # include -# include # include # define MAP_FILE 0 -#else -# include #endif +#include #include #include #include @@ -359,14 +357,20 @@ check_trunc_hack(void) { struct stat statbuf; - ftruncate(fd, (off_t) 0); - ftruncate(fd, (off_t) 100000); + if (ftruncate(fd, (off_t) 0) != 0) { + prterr("check_trunc_hack ftruncate(0)"); + } + if (ftruncate(fd, (off_t) 100000) != 0) { + prterr("check_trunc_hack ftruncate(100000)"); + } fstat(fd, &statbuf); if (statbuf.st_size != (off_t) 100000) { prt("no extend on truncate! not posix!\n"); exit(130); } - ftruncate(fd, 0); + if (ftruncate(fd, 0) != 0) { + prterr("check_trunc_hack ftruncate(0) again"); + } } @@ -884,6 +888,13 @@ main(int argc, char **argv) if (monitorend == 0) monitorend = -1; /* aka infinity */ debug = 1; + + /* + * Falling through to 'n' seems like a mistake, but this is what + * the historical 'fsx' tool has always done. We do the same here, + * for compatibility. + */ + AFS_FALLTHROUGH; case 'n': sizechecks = 0; break; diff --git a/src/tests/large-dir.c b/src/tests/large-dir.c index 0778077e46..0be5c9b777 100644 --- a/src/tests/large-dir.c +++ b/src/tests/large-dir.c @@ -126,7 +126,7 @@ creat_files(const char *dirname, int count) static void usage(int ret) { - fprintf(stderr, "%s directory number-of-files\n", __progname); + warnx("directory number-of-files"); exit(ret); } diff --git a/src/tests/large-dir2.c b/src/tests/large-dir2.c index 1c613676cb..3cd4d195ba 100644 --- a/src/tests/large-dir2.c +++ b/src/tests/large-dir2.c @@ -105,7 +105,7 @@ creat_files(const char *dirname, int count) static void usage(int ret) { - fprintf(stderr, "%s directory number-of-files\n", __progname); + warnx("directory number-of-files"); exit(ret); } diff --git a/src/tests/large-dir3.c b/src/tests/large-dir3.c index 7863e89233..c19aacb1c6 100644 --- a/src/tests/large-dir3.c +++ b/src/tests/large-dir3.c @@ -96,7 +96,7 @@ creat_files(const char *dirname, int count) static void usage(int ret) { - fprintf(stderr, "%s directory number-of-files\n", __progname); + warnx("directory number-of-files"); exit(ret); } diff --git a/src/tests/read-write.c b/src/tests/read-write.c index cebe2dc83d..4763970c7e 100644 --- a/src/tests/read-write.c +++ b/src/tests/read-write.c @@ -110,7 +110,6 @@ main(int argc, char **argv) const char *file = "foo"; const size_t sz = 16384; char *random_buf; - char *read_buf1; char *read_buf2; int fd; @@ -126,7 +125,7 @@ main(int argc, char **argv) write_null_file(fd, sz); if (lseek(fd, 0, SEEK_SET) < 0) err(1, "lseek"); - read_buf1 = read_file(fd, sz); + read_file(fd, sz); if (lseek(fd, 0, SEEK_SET) < 0) err(1, "lseek"); random_buf = write_random_file(fd, sz); diff --git a/src/tests/readdir-vs-lstat.c b/src/tests/readdir-vs-lstat.c index c93c366f04..20a2ef2e72 100644 --- a/src/tests/readdir-vs-lstat.c +++ b/src/tests/readdir-vs-lstat.c @@ -77,7 +77,7 @@ verify_inodes(const char *dirname) static void usage(int ret) { - fprintf(stderr, "%s [directory]\n", __progname); + warnx("[directory]"); exit(ret); } diff --git a/src/tests/strange-characters-c.c b/src/tests/strange-characters-c.c index 4518db6a38..cd4a4eb6f8 100644 --- a/src/tests/strange-characters-c.c +++ b/src/tests/strange-characters-c.c @@ -69,14 +69,14 @@ look_at_file(char *name) static void usage(int ret) { - fprintf(stderr, "%s\n", __progname); + warnx(NULL); exit(ret); } int main(int argc, char **argv) { - char *file = "едц"; + char *file = "\xe5\xe4\xf6"; if (argc != 1) diff --git a/src/tests/test-parallel2.c b/src/tests/test-parallel2.c index 7299984629..a341408554 100644 --- a/src/tests/test-parallel2.c +++ b/src/tests/test-parallel2.c @@ -62,7 +62,9 @@ getcwd_worker(int num) for (i = 0; i < WORKER_TIMES; ++i) { char buf[256]; - getcwd(buf, sizeof(buf)); + if (getcwd(buf, sizeof(buf)) == NULL) { + err(1, "getcwd %s", name); + } } return 0; } @@ -138,7 +140,9 @@ stat_worker(int num) if (chdir(name) < 0) err(1, "chdir %s", name); for (i = 0; i < WORKER_TIMES; ++i) { - getcwd(buf, sizeof(buf)); + if (getcwd(buf, sizeof(buf)) == NULL) { + err(1, "getcwd %s", name); + } stat(buf, &sb); } return 0; diff --git a/src/tests/utime-file.c b/src/tests/utime-file.c index afe40622c3..c6a689b758 100644 --- a/src/tests/utime-file.c +++ b/src/tests/utime-file.c @@ -64,6 +64,7 @@ main(int argc, char **argv) len = atoi(argv[1]); if (len == 0) errx(1, "invalid len"); + break; default: errx(1, "argv != [12]"); } @@ -81,7 +82,9 @@ main(int argc, char **argv) ret = ftruncate(fd, len); fstat(fd, &sb); lseek(fd, 0, SEEK_SET); - write(fd, buf, len); + if (write(fd, buf, len) != len) { + errx(1, "write"); + } fstat(fd, &sb); t.modtime = t.actime = time(NULL);