diff options
| author | rtm <rtm> | 2006-08-29 19:06:37 +0000 |
|---|---|---|
| committer | rtm <rtm> | 2006-08-29 19:06:37 +0000 |
| commit | dfcc5b997ce9c313b9ac0e7d8da39c4416b472a8 (patch) | |
| tree | 2d6c4e47bad6cfe7436896068a5872ace545a974 /usertests.c | |
| parent | d7ce6545e7179e9a4b950838c354b485e3f3fdb8 (diff) | |
| download | xv6-labs-2022-dfcc5b997ce9c313b9ac0e7d8da39c4416b472a8.tar.xz xv6-labs-2022-dfcc5b997ce9c313b9ac0e7d8da39c4416b472a8.zip | |
prune unneeded panics and debug output
Diffstat (limited to 'usertests.c')
| -rw-r--r-- | usertests.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/usertests.c b/usertests.c index badaa1c..54cebbd 100644 --- a/usertests.c +++ b/usertests.c @@ -13,7 +13,10 @@ pipe1(void) int fds[2], pid; int seq = 0, i, n, cc, total; - pipe(fds); + if(pipe(fds) != 0){ + puts("pipe() failed\n"); + exit(); + } pid = fork(); if(pid == 0){ close(fds[0]); @@ -26,7 +29,7 @@ pipe1(void) } } exit(); - } else { + } else if(pid > 0){ close(fds[1]); total = 0; cc = 1; @@ -43,9 +46,12 @@ pipe1(void) cc = sizeof(buf); } if(total != 5 * 1033) - printf(1, "pipe1 oops 3\n"); + printf(1, "pipe1 oops 3 total %d\n", total); close(fds[0]); wait(); + } else { + puts("fork() failed\n"); + exit(); } puts("pipe1 ok\n"); } @@ -121,26 +127,30 @@ void mem(void) { void *m1, *m2; + int pid; - m1 = 0; - while ((m2 = malloc(1024)) != 0) { - printf(1, "malloc %x\n", m2); - *(char **) m2 = m1; - m1 = m2; - } - while (m1) { - m2 = *(char **)m1; + if((pid = fork()) == 0){ + m1 = 0; + while ((m2 = malloc(10001)) != 0) { + *(char **) m2 = m1; + m1 = m2; + } + while (m1) { + m2 = *(char **)m1; + free(m1); + m1 = m2; + } + m1 = malloc(1024*20); + if (m1 == 0) { + puts("couldn't allocate mem?!!\n"); + exit(); + } free(m1); - m1 = m2; - } - m1 = malloc(1024*20); - if (m1 == 0) { - puts("couldn't allocate mem?!!\n"); + printf(1, "mem ok\n"); exit(); + } else { + wait(); } - free(m1); - - printf(1, "mem ok\n"); } int |
