summaryrefslogtreecommitdiff
path: root/usertests.c
diff options
context:
space:
mode:
Diffstat (limited to 'usertests.c')
-rw-r--r--usertests.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/usertests.c b/usertests.c
index a1e97e7..07d10d4 100644
--- a/usertests.c
+++ b/usertests.c
@@ -363,17 +363,29 @@ preempt(void)
printf(1, "preempt: ");
pid1 = fork();
+ if(pid1 < 0) {
+ printf(1, "fork failed");
+ exit();
+ }
if(pid1 == 0)
for(;;)
;
pid2 = fork();
+ if(pid2 < 0) {
+ printf(1, "fork failed\n");
+ exit();
+ }
if(pid2 == 0)
for(;;)
;
pipe(pfds);
pid3 = fork();
+ if(pid3 < 0) {
+ printf(1, "fork failed\n");
+ exit();
+ }
if(pid3 == 0){
close(pfds[0]);
if(write(pfds[1], "x", 1) != 1)
@@ -1391,6 +1403,11 @@ forktest(void)
exit();
}
+ if (n == 0) {
+ printf(1, "no fork at all!\n");
+ exit();
+ }
+
if(n == 1000){
printf(1, "fork claimed to work 1000 times!\n");
exit();
@@ -1414,16 +1431,16 @@ forktest(void)
void
sbrktest(void)
{
- int fds[2], pid, pids[10], ppid;
- char *a, *b, *c, *lastaddr, *oldbrk, *p, scratch;
- uint amt;
+ int i, fds[2], pids[10], pid, ppid;
+ char *c, *oldbrk, scratch, *a, *b, *lastaddr, *p;
+ uint64 amt;
+ #define BIG (100*1024*1024)
printf(stdout, "sbrk test\n");
oldbrk = sbrk(0);
// can one sbrk() less than a page?
a = sbrk(0);
- int i;
for(i = 0; i < 5000; i++){
b = sbrk(1);
if(b != a){
@@ -1449,9 +1466,8 @@ sbrktest(void)
wait();
// can one grow address space to something big?
-#define BIG (100*1024*1024)
a = sbrk(0);
- amt = (BIG) - (uint)a;
+ amt = (BIG) - (uint64)a;
p = sbrk(amt);
if (p != a) {
printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n");
@@ -1508,7 +1524,7 @@ sbrktest(void)
}
wait();
}
-
+
// if we run the system out of memory, does it clean up the last
// failed allocation?
if(pipe(fds) != 0){
@@ -1518,7 +1534,7 @@ sbrktest(void)
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
if((pids[i] = fork()) == 0){
// allocate a lot of memory
- sbrk(BIG - (uint)sbrk(0));
+ sbrk(BIG - (uint64)sbrk(0));
write(fds[1], "x", 1);
// sit around until killed
for(;;) sleep(1000);
@@ -1526,6 +1542,7 @@ sbrktest(void)
if(pids[i] != -1)
read(fds[0], &scratch, 1);
}
+
// if those failed allocations freed up the pages they did allocate,
// we'll be able to allocate here
c = sbrk(4096);
@@ -1549,7 +1566,7 @@ sbrktest(void)
void
validateint(int *p)
{
- int res;
+ /* XXX int res;
asm("mov %%esp, %%ebx\n\t"
"mov %3, %%esp\n\t"
"int %2\n\t"
@@ -1557,13 +1574,14 @@ validateint(int *p)
"=a" (res) :
"a" (SYS_sleep), "n" (T_SYSCALL), "c" (p) :
"ebx");
+ */
}
void
validatetest(void)
{
int hi, pid;
- uint p;
+ uint64 p;
printf(stdout, "validate test\n");
hi = 1100*1024;