qa: introduce runners and more tests for newlib

For each test, if a script exists with the same name of the test
plus the .runner suffix, the runner is run instead of the test.

As a first example qa/lib/newlib/testsuite/atexit is run by
qa/lib/newlib/testsuite/atexit.runner.

These .runner scripts allow more complex checks of the side effects
generated by the test.
This commit is contained in:
Giacomo Tesio 2017-04-28 00:47:12 +02:00
parent ac33157c37
commit 2481b01515
10 changed files with 95 additions and 31 deletions

@ -1 +1 @@
Subproject commit cd087cebd1af4186e4cd0abdb8c5afd0f32b4e1e
Subproject commit 9161f5fee16b7609d2421c2a465d03ec4e268c1b

View File

@ -9,17 +9,19 @@ if(~ $dir '') dir=/qa
l = `{du -a /arch/$objtype/$dir|awk '{print $2}'|sort}
failed = ()
ce=.check
runner=.runner
for(t in $l){
if(test -x $t) {
echo -n $t:
$t > /tmp/qa.log >[2=1]
st = $status
if(~ `{echo $st|field 3} PASS) {
if( test -x $t$ce ) { cp /tmp/qa.log /tmp/qa.previous.log }
rm /tmp/qa.log && echo PASS
if( test -x $t$runner ) { }
if not {
echo -n $t:
$t > /tmp/qa.log >[2=1]
st = $status
if(~ `{echo $st|field 3} PASS) {
rm /tmp/qa.log && echo PASS
}
if not { echo $st && cat /tmp/qa.log; exit $st}
}
if not { echo $st && cat /tmp/qa.log; exit $st}
}
}

View File

@ -32,9 +32,9 @@ int main(int argc, char **argv)
}
wait(&status);
if(status != 0){
printf("parent: child exited with status %d\n", status);
return 2;
}
printf("parent: child exited with status %d\n", status);
return 2;
}
}
else
{

35
qa/lib/newlib/100-files.c Normal file
View File

@ -0,0 +1,35 @@
#include <stdio.h>
int
main(int argc, char** argv) {
FILE *fp;
int i;
char * output = "/tmp/io-test.txt";
if(argc == 2){
output = argv[1];
}else if(argc > 2){
printf("usage: %s [output]", argv[0]);
return 100;
}
fp = fopen(output, "w+");
if(fp == NULL){
printf("Can't open %s", output);
return 1;
}
i = fprintf(fp, "%s works.\n", "fprintf");
if(i <= 0){
fclose(fp);
printf("Can't write 'fprintf works.' to %s", output);
return 2;
}
i = fputs("fputs works.\n", fp);
if(i == EOF){
fclose(fp);
printf("Can't write 'fputs works.' to %s", output);
return 3;
}
fclose(fp);
return 0;
}

View File

@ -0,0 +1,18 @@
#!/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 > /dev/null
if ( cat $test_output | grep 'fprintf works.' > /dev/null ) {
if ( cat $test_output | grep 'fputs works.' > /dev/null ) {
rm $test_output
echo PASS
exit PASS
}
}
cat $test_output
echo FAIL
exit FAIL

View File

@ -3,9 +3,6 @@
"Include": [
"/arch/$ARCH/include/cflags.json"
],
"Projects": [
"testsuite/"
],
"Cflags": [
"-fstack-check",
"-fstack-protector-all",
@ -24,7 +21,7 @@
"Install": "/arch/$ARCH/qa/lib/newlib",
"Post": [
"rm -f *.o",
"#cp *.rc $JEHANNE/arch/$ARCH/qa/lib/newlib/"
"cp *.runner $JEHANNE/arch/$ARCH/qa/lib/newlib/"
],
"Pre": [
"rm -f *.tag.*"
@ -33,8 +30,14 @@
"libposix_customization.c"
],
"SourceFilesCmd": [
"hello.c",
"fork0.c"
"000-hello.c",
"010-fork.c",
"100-files.c"
]
},
"NewlibTestsuite": {
"Projects": [
"testsuite/"
]
}
}

View File

@ -1,12 +0,0 @@
#!/cmd/rc
if ( cat /tmp/qa.previous.log | grep a0cba > /dev/null ) {
rm /tmp/qa.previous.log
echo PASS
exit PASS
}
if not {
echo FAIL
cat /tmp/qa.previous.log
exit FAIL
}

View File

@ -0,0 +1,18 @@
#!/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
if ( cat $test_output | grep a0cba > /dev/null ) {
rm $test_output
echo PASS
exit PASS
}
if not {
cat $test_output
echo FAIL
exit FAIL
}

View File

@ -24,7 +24,7 @@
"Post": [
"mkdir -p $JEHANNE/arch/$ARCH/qa/lib/newlib/testsuite",
"find -type f -perm /a+x -exec cp {} $JEHANNE/arch/$ARCH/qa/lib/newlib/testsuite/ \\;",
"cp *.check $JEHANNE/arch/$ARCH/qa/lib/newlib/testsuite/",
"cp *.runner $JEHANNE/arch/$ARCH/qa/lib/newlib/testsuite/",
"git clean -xdf ."
],
"Pre": [