diff --git a/qa/kern/awake_note.c b/qa/kern/awake_note.c new file mode 100644 index 0000000..b4f5f50 --- /dev/null +++ b/qa/kern/awake_note.c @@ -0,0 +1,59 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2017 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ +#include +#include + +void +handler(void *v, char *s) +{ + int64_t wakeup; + wakeup = awake(1000); + while(rendezvous(&wakeup, (void*)1) == (void*)~0) + if(jehanne_awakened(wakeup)){ + print("PASS\n"); + exits(nil); + } + print("FAIL in note handler\n"); + exits("FAIL"); +} + +void +main(int argc, char**argv) +{ + int fd, i; + 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("%s %d: waiting for note", argv[0], getpid()); + for(i = 0; i < 10*1000*1000; ++i) + if(i % 4999 == 0){ + sleep(100); + print("."); + } + + print("FAIL\n"); + exits("FAIL"); +} diff --git a/qa/kern/awake_note.runner b/qa/kern/awake_note.runner new file mode 100755 index 0000000..cf290c8 --- /dev/null +++ b/qa/kern/awake_note.runner @@ -0,0 +1,23 @@ +#!/cmd/rc + +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 +sleep 1 +echo hi > /proc/$testpid/note + +wait $testpid + +if ( cat $test_output | grep 'PASS' > /dev/null ) { + rm $test_output + echo PASS + exit PASS +} +cat $test_output +echo FAIL +exit FAIL diff --git a/qa/kern/build.json b/qa/kern/build.json index 9a845a6..fd5154f 100644 --- a/qa/kern/build.json +++ b/qa/kern/build.json @@ -12,6 +12,7 @@ "alarm.c", "args.c", "awake.c", + "awake_note.c", "brk.c", "execl.c", "float.c", diff --git a/qa/kern/nested_note.c b/qa/kern/nested_note.c index 91a0208..da22d4d 100644 --- a/qa/kern/nested_note.c +++ b/qa/kern/nested_note.c @@ -1,3 +1,20 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2017 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ #include #include