summaryrefslogtreecommitdiff
path: root/usertests.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2010-08-11 14:34:45 -0400
committerRobert Morris <[email protected]>2010-08-11 14:34:45 -0400
commit789b508d538e6faf635e49f268a4f1f9e9b65f05 (patch)
tree9515f6123cf72da77c7ebf0b4ac532c700dff30b /usertests.c
parent83d2db91f75460e1275d67847adec0fca5a9800b (diff)
downloadxv6-labs-789b508d538e6faf635e49f268a4f1f9e9b65f05.tar.gz
xv6-labs-789b508d538e6faf635e49f268a4f1f9e9b65f05.tar.bz2
xv6-labs-789b508d538e6faf635e49f268a4f1f9e9b65f05.zip
uptime() sys call for benchmarking
increase PHYSTOP
Diffstat (limited to 'usertests.c')
-rw-r--r--usertests.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/usertests.c b/usertests.c
index 9ad6448..670a4a8 100644
--- a/usertests.c
+++ b/usertests.c
@@ -322,8 +322,9 @@ void
mem(void)
{
void *m1, *m2;
- int pid;
+ int pid, ppid;
+ ppid = getpid();
if((pid = fork()) == 0){
m1 = 0;
while((m2 = malloc(10001)) != 0) {
@@ -338,6 +339,7 @@ mem(void)
m1 = malloc(1024*20);
if(m1 == 0) {
printf(1, "couldn't allocate mem?!!\n");
+ kill(ppid);
exit();
}
free(m1);
@@ -1233,6 +1235,7 @@ void
sbrktest(void)
{
int pid;
+ char *oldbrk = sbrk(0);
printf(stdout, "sbrk test\n");
@@ -1313,6 +1316,25 @@ sbrktest(void)
exit();
}
+ // can we read the kernel's memory?
+ for(a = (char*)(640*1024); a < (char *)2000000; a += 50000){
+ int ppid = getpid();
+ int pid = fork();
+ if(pid < 0){
+ printf(stdout, "fork failed\n");
+ exit();
+ }
+ if(pid == 0){
+ printf(stdout, "oops could read %x = %x\n", a, *a);
+ kill(ppid);
+ exit();
+ }
+ wait();
+ }
+
+ if(sbrk(0) > oldbrk)
+ sbrk(-(sbrk(0) - oldbrk));
+
printf(stdout, "sbrk test OK\n");
}