qa: nested_note checks that notes are enqueued in kernel
This commit is contained in:
parent
bd5063666f
commit
3b35743a64
@ -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",
|
||||
|
48
qa/kern/nested_note.c
Normal file
48
qa/kern/nested_note.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include <u.h>
|
||||
#include <lib9.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
35
qa/kern/nested_note.runner
Executable file
35
qa/kern/nested_note.runner
Executable file
@ -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
|
Loading…
x
Reference in New Issue
Block a user