qa: various fix to tests

This commit is contained in:
Giacomo Tesio 2017-08-11 02:01:55 +02:00
parent 93dde48355
commit 1c4a04cd30
21 changed files with 253 additions and 60 deletions

View File

@ -78,6 +78,7 @@ main(void)
print("FAIL: rendezvous\n");
exits("FAIL");
}
forgivewkp(wkup);
/* verify that sleeps are NOT interrupted */
fprint(2, "verify that sleeps are NOT interrupted\n", elapsed);
@ -91,6 +92,7 @@ main(void)
print("FAIL: sleep\n");
exits("FAIL");
}
forgivewkp(wkup);
/* verify that semacquires are interrupted */
fprint(2, "verify that semacquires are interrupted\n", elapsed);
@ -107,6 +109,7 @@ main(void)
print("FAIL: semacquire\n");
exits("FAIL");
}
forgivewkp(wkup);
/* verify that tsemacquire are NOT interrupted */
fprint(2, "verify that tsemacquire are NOT interrupted\n", elapsed);
@ -120,6 +123,7 @@ main(void)
print("FAIL: tsemacquire\n");
exits("FAIL");
}
forgivewkp(wkup);
/* verify that reads are interrupted */
fprint(2, "verify that reads are interrupted\n", elapsed);
@ -137,6 +141,7 @@ main(void)
print("FAIL: read\n");
exits("FAIL");
}
forgivewkp(wkup);
/* verify that writes are interrupted */
fprint(2, "verify that writes are interrupted\n", elapsed);
@ -154,6 +159,7 @@ main(void)
print("FAIL: write\n");
exits("FAIL");
}
forgivewkp(wkup);
/* do not forgivewkp the awake(100000): the kernel must handle it */
print("PASS\n");

View File

@ -28,6 +28,7 @@ handler(void *v, char *s)
print("PASS\n");
exits(nil);
}
forgivewkp(wakeup);
print("FAIL in note handler\n");
exits("FAIL");
}

View File

@ -8,9 +8,6 @@
"cp *.rc $JEHANNE/arch/$ARCH/qa/kern/",
"cp *.runner $JEHANNE/arch/$ARCH/qa/kern/"
],
"Disabled": [
"fork_chain.c"
],
"SourceFilesCmd": [
"alarm.c",
"args.c",
@ -21,6 +18,7 @@
"execl.c",
"float.c",
"fork.c",
"fork_chain.c",
"frexp.c",
"getmainpid.c",
"getpid.c",

View File

@ -27,6 +27,7 @@ handler(void *v, char *s)
int i;
if(strcmp(s, "stop") == 0){
done = 1;
print("stop note received; done = %d\n", done);
}else{
print("waiting after %s", s);
for(i = 0; i < 1000*1000; ++i)
@ -62,6 +63,6 @@ main(int argc, char**argv)
print("PASS\n");
exits("PASS");
}
print("%d notes received\n");
print("%d notes received\n", waited);
exits("FAIL");
}

View File

@ -30,6 +30,7 @@
"rsleept1.c",
"rsleept2.c",
"rwakeup0.c",
"rwakeup1.c",
"sleep.c",
"sqrt.c",
"sysfatal.c",

View File

@ -2,6 +2,12 @@
#include <u.h>
#include <lib9.h>
// from kernel's mem.h
#define MiB (1024*1024)
#define TSTKTOP (0x00007ffffffff000ull)
#define USTKSIZE (16*MiB) /* size of user stack */
#define USTKTOP (TSTKTOP-USTKSIZE) /* end of new stack in sysexec */
enum {
Njmps = 10000
};
@ -23,16 +29,26 @@ main(void)
fprint(2, "label[%d] = %p\n", i, label[i]);
fprint(2, "main: %p foo: %p\n", main, foo);
if(njmp != Njmps)
if(njmp != Njmps){
print("error: njmp = %d\n", njmp);
fail++;
if(label[JMPBUFPC] < (uintptr_t)main)
}
if(label[JMPBUFPC] < (uintptr_t)main){
print("error: label[JMPBUFPC] = %#p\n", label[JMPBUFPC]);
fail++;
if(label[JMPBUFPC] > (uintptr_t)foo)
}
if(label[JMPBUFPC] > (uintptr_t)foo){
print("error: label[JMPBUFPC] = %#p\n", label[JMPBUFPC]);
fail++;
if(label[JMPBUFSP] > (uintptr_t)&label[nelem(label)])
}
if(label[JMPBUFSP] > (uintptr_t)&label[nelem(label)]){
print("error: label[JMPBUFSP] (%#p) is greater then &label[nelem(label)] (%#p) \n", label[JMPBUFPC], &label[nelem(label)]);
fail++;
if(label[JMPBUFSP] < 0x7fffffd00000)
}
if(label[JMPBUFSP] < USTKTOP-USTKSIZE){
print("error: label[JMPBUFSP] (%#p) is lower then USTKTOP-USTKSIZE \n", label[JMPBUFSP]);
fail++;
}
if(fail == 0){
print("PASS\n");

View File

@ -149,11 +149,14 @@ spawnWaiter(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -212,6 +215,6 @@ main(void)
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -220,6 +220,6 @@ main(void)
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -70,7 +70,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -150,11 +150,14 @@ spawnWaiter(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -205,11 +208,11 @@ main(void)
}
average = average / NPROC / (1000 * 1000);
if(average < 100) /* we asked for 1ms... we are dumb, after all */
if(average < 300) /* we asked for 1ms... we are dumb, after all */
{
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -71,7 +71,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -150,11 +150,14 @@ spawnWaiter(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -212,6 +215,6 @@ main(void)
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -73,7 +73,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -154,11 +154,14 @@ spawnWaiter(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average, end;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -222,6 +225,6 @@ main(void)
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -71,7 +71,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -126,15 +126,17 @@ waiter(int index)
return end != start ? nil : "FAIL";
}
int lastspawn;
void
spawnWaiter(int index)
{
int pid;
int pid, ls = lastspawn;
char * res;
switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT)))
{
case 0:
++lastspawn;
res = waiter(index);
exits(res);
break;
@ -143,6 +145,8 @@ spawnWaiter(int index)
exits("rfork fails");
break;
default:
while(ls == lastspawn)
;
if(verbose)
print("spawn reader %d\n", pid);
break;
@ -150,11 +154,14 @@ spawnWaiter(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -207,11 +214,11 @@ main(void)
}
average = average / NPROC / (1000 * 1000);
if(average < 100) /* we asked for 1ms... we are dumb, after all */
if(average < 300) /* we asked for 1ms... we are dumb, after all */
{
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -71,7 +71,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -152,11 +152,14 @@ spawnsleeper(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -211,6 +214,6 @@ main(void)
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -73,7 +73,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -156,11 +156,14 @@ spawnWaiter(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i, awakened;
int64_t average, end;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -225,6 +228,6 @@ main(void)
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -72,7 +72,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
// printdebugrendezvouslogs();
exits("FAIL");
}
@ -130,15 +130,17 @@ sleeper(int index)
return end != start ? nil : "FAIL";
}
int lastspawn;
void
spawnsleeper(int index)
{
int pid;
int pid, ls = lastspawn;
char * res;
switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT)))
{
case 0:
++lastspawn;
res = sleeper(index);
exits(res);
break;
@ -147,6 +149,8 @@ spawnsleeper(int index)
exits("rfork fails");
break;
default:
while(ls == lastspawn)
;
if(verbose)
print("spawn sleeper %d\n", pid);
break;
@ -154,11 +158,14 @@ spawnsleeper(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -213,6 +220,6 @@ main(void)
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -34,7 +34,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -71,11 +71,14 @@ stopAllAfter(int seconds)
}
void
main(void)
main(int argc, char* argv[])
{
int s, w;
rfork(RFNOTEG);
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
if (!atnotify(handletimeout, 1)){
fprint(2, "%r\n");
exits("atnotify fails");
@ -88,8 +91,8 @@ main(void)
switch((s = rfork(RFMEM|RFPROC|RFNOWAIT)))
{
case 0:
ready = 1;
qlock(&l);
ready = 1;
rsleep(&r);
qunlock(&l);
exits(nil);
@ -109,8 +112,8 @@ main(void)
case 0:
qlock(&l);
rwakeup(&r);
ready = 2;
qunlock(&l);
ready = 2;
exits(nil);
break;
case -1:
@ -137,6 +140,6 @@ main(void)
write(s, "kill", 5);
close(s);
}
print("FAIL");
print("FAIL\n");
exits("FAIL");
}

126
qa/lib/c/rwakeup1.c Normal file
View File

@ -0,0 +1,126 @@
/*
* This file is part of Jehanne.
*
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <u.h>
#include <lib9.h>
/* verify that rwakeup returns 0 on Rendez that was timedout */
Rendez r;
QLock l;
int ready;
int verbose = 0;
int killerProc; /* pid, will kill the other processes if starved */
int
handletimeout(void *v, char *s)
{
/* just not exit, please */
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
}
void
killKiller(void)
{
postnote(PNPROC, killerProc, "interrupt");
}
void
stopAllAfter(int seconds)
{
int pid;
switch((pid = rfork(RFMEM|RFPROC|RFNOWAIT)))
{
case 0:
if(verbose)
print("killer proc started: pid %d\n", getpid());
sleep(seconds * 1000);
postnote(PNGROUP, killerProc, "timedout");
if(verbose)
print("killer proc timedout: pid %d\n", getpid());
exits("FAIL");
case -1:
fprint(2, "%r\n");
exits("rfork fails");
default:
killerProc = pid;
atexit(killKiller);
}
}
void
main(int argc, char* argv[])
{
int s, w;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
if (!atnotify(handletimeout, 1)){
fprint(2, "%r\n");
exits("atnotify fails");
}
r.l = &l;
stopAllAfter(30);
/* one process to sleep for 100ms */
switch((s = rfork(RFMEM|RFPROC|RFNOWAIT)))
{
case 0:
qlock(&l);
rsleept(&r, 100);
qunlock(&l);
ready = 1;
exits(nil);
break;
case -1:
print("rfork: %r\n");
exits("rfork fails");
break;
default:
while(ready == 0)
;
break;
}
/* now, we try to wakeup a free Rendez */
qlock(&l);
if(rwakeup(&r) == 0){
qunlock(&l);
print("PASS\n");
exits("PASS");
}
if((s = open(smprint("/proc/%d/ctl", s), OWRITE)) >= 0){
write(s, "kill", 5);
close(s);
}
if((w = open(smprint("/proc/%d/ctl", w), OWRITE)) >= 0){
write(s, "kill", 5);
close(s);
}
print("FAIL\n");
exits("FAIL");
}

View File

@ -71,7 +71,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -150,11 +150,14 @@ spawnWaiter(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -212,6 +215,6 @@ main(void)
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -73,7 +73,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -154,11 +154,14 @@ spawnWaiter(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average, end;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -222,6 +225,6 @@ main(void)
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -71,7 +71,7 @@ handletimeout(void *v, char *s)
if(strcmp(s, "timedout") == 0){
if(verbose)
print("%d: noted: %s\n", getpid(), s);
print("FAIL: timedout\n");
print("FAIL: %s timedout\n", argv0);
exits("FAIL");
}
return 0;
@ -150,11 +150,14 @@ spawnWaiter(int index)
}
void
main(void)
main(int argc, char* argv[])
{
int i;
int64_t average;
ARGBEGIN{
}ARGEND;
rfork(RFNOTEG|RFREND);
rStart.l = &rl;
rCompleted.l = &rl;
@ -207,11 +210,11 @@ main(void)
}
average = average / NPROC / (1000 * 1000);
if(average < 100) /* we asked for 1ms... we are dumb, after all */
if(average < 300) /* we asked for 1ms... we are dumb, after all */
{
print("PASS\n");
exits("PASS");
}
print("FAIL: average timeout too long %lld ms\n", average);
print("FAIL: %s: average timeout too long %lld ms\n", argv0, average);
exits("FAIL");
}

View File

@ -76,18 +76,18 @@
"SourceFiles": [
"libposix_sigchld.c"
],
"Disabled": [
"SourceFilesCmd": [
"000-hello.c",
"010-fork.c",
"020-waitpid.c",
"100-files.c",
"101-files.c",
"200-signals.c",
"201-signals.c",
"202-signals.c",
"203-signals.c"
],
"SourceFilesCmd": [
"000-hello.c",
"100-files.c",
"101-files.c"
"203-signals.c",
"204-signals.c",
"205-signals.c"
]
},
"NewlibTestsuite": {