diff --git a/qa/kern/build.json b/qa/kern/build.json index e43402e..9a845a6 100644 --- a/qa/kern/build.json +++ b/qa/kern/build.json @@ -5,7 +5,8 @@ ], "Install": "/arch/$ARCH/qa/kern", "Post": [ - "cp *.rc $JEHANNE/arch/$ARCH/qa/kern/" + "cp *.rc $JEHANNE/arch/$ARCH/qa/kern/", + "cp *.runner $JEHANNE/arch/$ARCH/qa/kern/" ], "SourceFilesCmd": [ "alarm.c", @@ -26,6 +27,7 @@ "mixedfloat.c", "noexecmem.c", "notify.c", + "nested_note.c", "nsec.c", "pipering.c", "postnote.c", diff --git a/qa/kern/nested_note.c b/qa/kern/nested_note.c new file mode 100644 index 0000000..91a0208 --- /dev/null +++ b/qa/kern/nested_note.c @@ -0,0 +1,48 @@ +#include +#include + +int done; +int waited; + +void +handler(void *v, char *s) +{ + int i; + if(strcmp(s, "stop") == 0){ + done = 1; + noted(NCONT); + } + print("waiting after %s", s); + for(i = 0; i < 1000*1000; ++i) + if(i % 4999 == 0) + print("."); + print("\n"); + print("wait after %s terminated\n", s); + waited++; + noted(NCONT); +} + +void +main(int argc, char**argv) +{ + int fd; + if(argc > 1){ + fd = ocreate(argv[1], OWRITE, 0666); + dup(fd, 1); + close(fd); + } + + if (notify(handler)){ + fprint(2, "%r\n"); + exits("notify fails"); + } + + print("note handler installed\n"); + + while(!done) + sleep(100); + if(waited == 2){ + print("PASS\n"); + exits(0); + } +} diff --git a/qa/kern/nested_note.runner b/qa/kern/nested_note.runner new file mode 100755 index 0000000..19c49e5 --- /dev/null +++ b/qa/kern/nested_note.runner @@ -0,0 +1,35 @@ +#!/cmd/rc + +# this test ensure that notes are enqueued in kernel + +runner=$0 +test = `{echo $runner|sed 's/.runner//'} +test_output = /tmp/output-`{basename $test} + +if ( test -e $test_output) rm $test_output + +$test $test_output & +testpid = $apid + +while ( ! test -e $test_output ) { sleep 2 } + +echo $test started, output to $test_output, kill at /proc/$testpid/ctl + +echo -n first > /proc/$testpid/note +echo -n second > /proc/$testpid/note +echo -n stop > /proc/$testpid/note + +wait $testpid + +if ( cat $test_output | grep 'waiting after first.........................................................................................................................................................................................................' > /dev/null ) { +if ( cat $test_output | grep 'waiting after second.........................................................................................................................................................................................................' > /dev/null ) { +if ( cat $test_output | grep 'PASS' > /dev/null ) { + rm $test_output + echo PASS + exit PASS +} +} +} +cat $test_output +echo FAIL +exit FAIL