updated alarmtest
This commit is contained in:
parent
78f863f8ae
commit
56583b1402
6 changed files with 32 additions and 25 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue