Userland test changes.

This commit is contained in:
Geoffrey Challen 2017-02-09 09:51:39 -05:00
parent 4c9b79877e
commit 9986e07810
12 changed files with 67 additions and 19 deletions

View File

@ -177,7 +177,7 @@ print(const char *path)
typech = '?'; typech = '?';
} }
printf("%crwx------ %2d root %-8llu", printf("%crwx------ %2d root %-7llu ",
typech, typech,
statbuf.st_nlink, statbuf.st_nlink,
statbuf.st_size); statbuf.st_size);

View File

@ -197,11 +197,9 @@ dumpdata(void)
indexsize = dolseek(indexfd, indexname, 0, SEEK_CUR); indexsize = dolseek(indexfd, indexname, 0, SEEK_CUR);
pos = indexsize; pos = indexsize;
while (1) { assert(pos % sizeof(x) == 0);
while (pos > 0) {
pos -= sizeof(x); pos -= sizeof(x);
if (pos == 0) {
break;
}
assert(pos >= 0); assert(pos >= 0);
dolseek(indexfd, indexname, pos, SEEK_SET); dolseek(indexfd, indexname, pos, SEEK_SET);

View File

@ -5,7 +5,7 @@
TOP=../../.. TOP=../../..
.include "$(TOP)/mk/os161.config.mk" .include "$(TOP)/mk/os161.config.mk"
SRCS=triple.c quint.c SRCS=triple.c
LIB=test LIB=test
.include "$(TOP)/mk/os161.lib.mk" .include "$(TOP)/mk/os161.lib.mk"

View File

@ -7,10 +7,10 @@ TOP=../..
SUBDIRS=add argtest badcall bigexec bigfile bigfork bigseek bloat conman \ SUBDIRS=add argtest badcall bigexec bigfile bigfork bigseek bloat conman \
crash ctest dirconc dirseek dirtest f_test factorial farm faulter \ 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 \ malloctest matmult multiexec palin parallelvm poisondisk psort \
quinthuge quintmat quintsort randcall redirect rmdirtest rmtest \ randcall redirect rmdirtest rmtest \
sbrktest schedpong sink sort sparsefile sty tail tictac triplehuge \ sbrktest schedpong sort sparsefile tail tictac triplehuge \
triplemat triplesort usemtest zero triplemat triplesort usemtest zero
# But not: # But not:

View File

@ -62,7 +62,7 @@ open_empty(void)
report_begin("open empty string"); report_begin("open empty string");
rv = open("", O_RDONLY); rv = open("", O_RDONLY);
report_check2(rv, errno, 0, EINVAL); report_check(rv, errno, EINVAL);
if (rv>=0) { if (rv>=0) {
close(rv); close(rv);
} }

View File

@ -68,6 +68,11 @@ pipe_unaligned(void)
rv = pipe((int *)ptr); rv = pipe((int *)ptr);
report_survival(rv, errno); report_survival(rv, errno);
if (rv == 0) {
memmove(fds, ptr, 2*sizeof(int));
close(fds[0]);
close(fds[1]);
}
} }
void void

View File

@ -46,7 +46,7 @@
int int
main(int argc, char *argv[]) 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]; static char readbuf[41];
const char *file; const char *file;

View File

@ -133,25 +133,52 @@ void
test(int nowait) test(int nowait)
{ {
int pid0, pid1, pid2, pid3; int pid0, pid1, pid2, pid3;
int depth = 0;
/* /*
* Caution: This generates processes geometrically. * Caution: This generates processes geometrically.
* *
* It is unrolled to encourage gcc to registerize the pids, * It is unrolled to encourage gcc to registerize the pids,
* to prevent wait/exit problems if fork corrupts memory. * 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(); pid0 = dofork();
depth++;
putchar('A'); putchar('A');
if (depth != 1) {
warnx("depth %d, should be 1", depth);
}
check(); check();
pid1 = dofork(); pid1 = dofork();
depth++;
putchar('B'); putchar('B');
if (depth != 2) {
warnx("depth %d, should be 2", depth);
}
check(); check();
pid2 = dofork(); pid2 = dofork();
depth++;
putchar('C'); putchar('C');
if (depth != 3) {
warnx("depth %d, should be 3", depth);
}
check(); check();
pid3 = dofork(); pid3 = dofork();
depth++;
putchar('D'); putchar('D');
if (depth != 4) {
warnx("depth %d, should be 4", depth);
}
check(); check();
/* /*

View File

@ -31,7 +31,7 @@
* hog.c * hog.c
* Spawned by several other user programs to test time-slicing. * 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 int

View File

@ -134,6 +134,7 @@ semP(struct usem *sem, size_t num)
if (read(sem->fd, c, num) < 0) { if (read(sem->fd, c, num) < 0) {
err(1, "%s: read", sem->name); err(1, "%s: read", sem->name);
} }
(void)c;
} }
static static

View File

@ -283,16 +283,24 @@ static
void void
semP(struct usem *sem, size_t num) 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); err(1, "%s: read", sem->name);
} }
(void)c;
} }
static static
void void
semV(struct usem *sem, size_t num) 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); err(1, "%s: write", sem->name);
} }
} }
@ -336,7 +344,12 @@ makeprocs(bool dowait)
for (i=0; i<NJOBS; i++) { for (i=0; i<NJOBS; i++) {
pids[i] = fork(); pids[i] = fork();
if (pids[i]<0) { if (pids[i]<0) {
warn("fork"); warn("fork (process %d)", i);
if (dowait) {
semopen(&s1);
semV(&s1, 1);
semclose(&s1);
}
} }
if (pids[i]==0) { if (pids[i]==0) {
/* child */ /* child */

View File

@ -35,6 +35,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <err.h> #include <err.h>
@ -84,9 +85,9 @@ void
Pn(struct usem *sem, unsigned count) Pn(struct usem *sem, unsigned count)
{ {
ssize_t r; ssize_t r;
char c; char c[count];
r = read(sem->fd, &c, count); r = read(sem->fd, c, count);
if (r < 0) { if (r < 0) {
err(1, "%s: read", sem->name); err(1, "%s: read", sem->name);
} }
@ -105,9 +106,12 @@ void
Vn(struct usem *sem, unsigned count) Vn(struct usem *sem, unsigned count)
{ {
ssize_t r; 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) { if (r < 0) {
err(1, "%s: write", sem->name); err(1, "%s: write", sem->name);
} }