summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-10-03 15:02:19 -0400
committerRobert Morris <[email protected]>2019-10-03 15:02:19 -0400
commit56583b1402a7f8fad0f8c3c296e26f12b1114c95 (patch)
tree68ea77f02de3b3dabea5c976f6bac571be0478d6 /user
parent78f863f8aead6346dfdfc62e91af25c9383e25a7 (diff)
downloadxv6-labs-56583b1402a7f8fad0f8c3c296e26f12b1114c95.tar.gz
xv6-labs-56583b1402a7f8fad0f8c3c296e26f12b1114c95.tar.bz2
xv6-labs-56583b1402a7f8fad0f8c3c296e26f12b1114c95.zip
updated alarmtest
Diffstat (limited to 'user')
-rw-r--r--user/alarmtest.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/user/alarmtest.c b/user/alarmtest.c
index ca3db23..d3746c4 100644
--- a/user/alarmtest.c
+++ b/user/alarmtest.c
@@ -21,7 +21,7 @@ main(int argc, char *argv[])
{
test0();
test1();
- exit();
+ exit(0);
}
volatile static int count;
@@ -44,7 +44,7 @@ test0()
count = 0;
sigalarm(2, periodic);
for(i = 0; i < 1000*500000; i++){
- if((i % 250000) == 0)
+ if((i % 1000000) == 0)
write(2, ".", 1);
if(count > 0)
break;
@@ -53,7 +53,7 @@ test0()
if(count > 0){
printf("test0 passed\n");
} else {
- printf("test0 failed\n");
+ printf("\ntest0 failed: the kernel never called the alarm handler\n");
}
}
@@ -64,6 +64,14 @@ void __attribute__ ((noinline)) foo(int i, int *j) {
*j += 1;
}
+//
+// tests that the kernel calls the handler multiple times.
+//
+// tests that, when the handler returns, it returns to
+// the point in the program where the timer interrupt
+// occurred, with all registers holding the same values they
+// held when the interrupt occurred.
+//
void
test1()
{
@@ -79,9 +87,19 @@ test1()
break;
foo(i, &j);
}
- if(i != j || count < 10){
- // i should equal j
- printf("test1 failed\n");
+ if(count < 10){
+ printf("\ntest1 failed: too few calls to the handler\n");
+ exit(1);
+ } else if(i != j){
+ // the loop should have called foo() i times, and foo() should
+ // have incremented j once per call, so j should equal i.
+ // once possible source of errors is that the handler may
+ // return somewhere other than where the timer interrupt
+ // occurred; another is that that registers may not be
+ // restored correctly, causing i or j or the address ofj
+ // to get an incorrect value.
+ printf("\ntest1 failed: foo() executed fewer times than it was called\n");
+ exit(1);
} else {
printf("test1 passed\n");
}