diff --git a/userland/bin/ls/ls.c b/userland/bin/ls/ls.c index 6dd8c88..2041bc8 100644 --- a/userland/bin/ls/ls.c +++ b/userland/bin/ls/ls.c @@ -177,7 +177,7 @@ print(const char *path) typech = '?'; } - printf("%crwx------ %2d root %-8llu", + printf("%crwx------ %2d root %-7llu ", typech, statbuf.st_nlink, statbuf.st_size); diff --git a/userland/bin/tac/tac.c b/userland/bin/tac/tac.c index 3e0a260..edaa48d 100644 --- a/userland/bin/tac/tac.c +++ b/userland/bin/tac/tac.c @@ -197,11 +197,9 @@ dumpdata(void) indexsize = dolseek(indexfd, indexname, 0, SEEK_CUR); pos = indexsize; - while (1) { + assert(pos % sizeof(x) == 0); + while (pos > 0) { pos -= sizeof(x); - if (pos == 0) { - break; - } assert(pos >= 0); dolseek(indexfd, indexname, pos, SEEK_SET); diff --git a/userland/lib/libtest/Makefile b/userland/lib/libtest/Makefile index cf0422a..2752d19 100644 --- a/userland/lib/libtest/Makefile +++ b/userland/lib/libtest/Makefile @@ -5,7 +5,7 @@ TOP=../../.. .include "$(TOP)/mk/os161.config.mk" -SRCS=triple.c quint.c +SRCS=triple.c LIB=test .include "$(TOP)/mk/os161.lib.mk" diff --git a/userland/testbin/Makefile b/userland/testbin/Makefile index e5cf502..647f229 100644 --- a/userland/testbin/Makefile +++ b/userland/testbin/Makefile @@ -7,10 +7,10 @@ TOP=../.. SUBDIRS=add argtest badcall bigexec bigfile bigfork bigseek bloat conman \ crash ctest dirconc dirseek dirtest f_test factorial farm faulter \ - filetest forkbomb forktest frack guzzle hash hog huge kitchen \ + filetest forkbomb forktest frack hash hog huge \ malloctest matmult multiexec palin parallelvm poisondisk psort \ - quinthuge quintmat quintsort randcall redirect rmdirtest rmtest \ - sbrktest schedpong sink sort sparsefile sty tail tictac triplehuge \ + randcall redirect rmdirtest rmtest \ + sbrktest schedpong sort sparsefile tail tictac triplehuge \ triplemat triplesort usemtest zero # But not: diff --git a/userland/testbin/badcall/bad_open.c b/userland/testbin/badcall/bad_open.c index 5ce66cd..3d317ed 100644 --- a/userland/testbin/badcall/bad_open.c +++ b/userland/testbin/badcall/bad_open.c @@ -62,7 +62,7 @@ open_empty(void) report_begin("open empty string"); rv = open("", O_RDONLY); - report_check2(rv, errno, 0, EINVAL); + report_check(rv, errno, EINVAL); if (rv>=0) { close(rv); } diff --git a/userland/testbin/badcall/bad_pipe.c b/userland/testbin/badcall/bad_pipe.c index 350c3d8..172579c 100644 --- a/userland/testbin/badcall/bad_pipe.c +++ b/userland/testbin/badcall/bad_pipe.c @@ -68,6 +68,11 @@ pipe_unaligned(void) rv = pipe((int *)ptr); report_survival(rv, errno); + if (rv == 0) { + memmove(fds, ptr, 2*sizeof(int)); + close(fds[0]); + close(fds[1]); + } } void diff --git a/userland/testbin/filetest/filetest.c b/userland/testbin/filetest/filetest.c index ae93c38..dc062ec 100644 --- a/userland/testbin/filetest/filetest.c +++ b/userland/testbin/filetest/filetest.c @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) { - static char writebuf[40] = "Twiddle dee dee, Twiddle dum dum.......\n"; + static char writebuf[41] = "Twiddle dee dee, Twiddle dum dum.......\n"; static char readbuf[41]; const char *file; diff --git a/userland/testbin/forktest/forktest.c b/userland/testbin/forktest/forktest.c index 4f7fed3..46e5da2 100644 --- a/userland/testbin/forktest/forktest.c +++ b/userland/testbin/forktest/forktest.c @@ -133,25 +133,52 @@ void test(int nowait) { int pid0, pid1, pid2, pid3; + int depth = 0; /* * Caution: This generates processes geometrically. * * It is unrolled to encourage gcc to registerize the pids, * to prevent wait/exit problems if fork corrupts memory. + * + * Note: if the depth prints trigger and show that the depth + * is too small, the most likely explanation is that the fork + * child is returning from the write() inside putchar() + * instead of from fork() and thus skipping the depth++. This + * is a fairly common problem caused by races in the kernel + * fork code. */ pid0 = dofork(); + depth++; putchar('A'); + if (depth != 1) { + warnx("depth %d, should be 1", depth); + } check(); + pid1 = dofork(); + depth++; putchar('B'); + if (depth != 2) { + warnx("depth %d, should be 2", depth); + } check(); + pid2 = dofork(); + depth++; putchar('C'); + if (depth != 3) { + warnx("depth %d, should be 3", depth); + } check(); + pid3 = dofork(); + depth++; putchar('D'); + if (depth != 4) { + warnx("depth %d, should be 4", depth); + } check(); /* diff --git a/userland/testbin/hog/hog.c b/userland/testbin/hog/hog.c index 7b69f15..9c6e2b5 100644 --- a/userland/testbin/hog/hog.c +++ b/userland/testbin/hog/hog.c @@ -31,7 +31,7 @@ * hog.c * Spawned by several other user programs to test time-slicing. * - * This does not differ from guzzle in any important way. + * Loops consuming CPU cycles. */ int diff --git a/userland/testbin/multiexec/multiexec.c b/userland/testbin/multiexec/multiexec.c index a7d41c9..b6f157d 100644 --- a/userland/testbin/multiexec/multiexec.c +++ b/userland/testbin/multiexec/multiexec.c @@ -134,6 +134,7 @@ semP(struct usem *sem, size_t num) if (read(sem->fd, c, num) < 0) { err(1, "%s: read", sem->name); } + (void)c; } static diff --git a/userland/testbin/parallelvm/parallelvm.c b/userland/testbin/parallelvm/parallelvm.c index a213197..953764a 100644 --- a/userland/testbin/parallelvm/parallelvm.c +++ b/userland/testbin/parallelvm/parallelvm.c @@ -283,16 +283,24 @@ static void semP(struct usem *sem, size_t num) { - if (read(sem->fd, NULL, num) < 0) { + char c[num]; + + if (read(sem->fd, c, num) < 0) { err(1, "%s: read", sem->name); } + (void)c; } static void semV(struct usem *sem, size_t num) { - if (write(sem->fd, NULL, num) < 0) { + char c[num]; + + /* semfs does not use these values, but be conservative */ + memset(c, 0, num); + + if (write(sem->fd, c, num) < 0) { err(1, "%s: write", sem->name); } } @@ -336,7 +344,12 @@ makeprocs(bool dowait) for (i=0; i #include +#include #include #include @@ -84,9 +85,9 @@ void Pn(struct usem *sem, unsigned count) { ssize_t r; - char c; + char c[count]; - r = read(sem->fd, &c, count); + r = read(sem->fd, c, count); if (r < 0) { err(1, "%s: read", sem->name); } @@ -105,9 +106,12 @@ void Vn(struct usem *sem, unsigned count) { ssize_t r; - char c; + char c[count]; - r = write(sem->fd, &c, count); + /* semfs does not use these values, but be conservative */ + memset(c, 0, count); + + r = write(sem->fd, c, count); if (r < 0) { err(1, "%s: write", sem->name); }