Run all tests, even the ones which fail, and emit a test summary right at the

end of the build (and fail then).
This commit is contained in:
David Given 2016-12-01 23:03:30 +01:00
parent b7de58e34e
commit 8c99e2b7ad
9 changed files with 49 additions and 19 deletions

View file

@ -63,7 +63,7 @@ PLATDEP = $(INSDIR)/lib/ack
.NOTPARALLEL: .NOTPARALLEL:
MAKECMDGOALS ?= +ack MAKECMDGOALS ?= +ack +tests
BUILD_FILES = $(shell find * -name '*.lua') BUILD_FILES = $(shell find * -name '*.lua')
ifneq ($(shell which ninja),) ifneq ($(shell which ninja),)

View file

@ -46,8 +46,18 @@ installable {
"examples+pkg", "examples+pkg",
plat_packages plat_packages
}, },
deps = {
test_packages
}
} }
normalrule {
name = "tests",
ins = {
"first/testsummary.sh",
test_packages
},
outleaves = {
"stamp"
},
commands = {
"%{ins}"
}
}

11
first/testsummary.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
failed=$(find "$@" ! -size 0)
echo ""
echo "$(echo $failed | wc -w) failed tests"
echo ""
for a in $failed; do
echo "**** $a"
cat $a
echo ""
done
exec test "$failed" == ""

View file

@ -6,4 +6,3 @@ void _m_a_i_n(void)
ASSERT(0 == 0); ASSERT(0 == 0);
finished(); finished();
} }

View file

@ -42,24 +42,21 @@ definerule("plat_testsuite",
tests[#tests+1] = normalrule { tests[#tests+1] = normalrule {
name = fs, name = fs,
outleaves = { "stamp" }, outleaves = { e.plat.."-"..fs.."-testlog.txt" },
ins = { ins = {
bin, bin,
"tests/plat/testdriver.sh", "tests/plat/testdriver.sh",
"util/build+testrunner" "util/build+testrunner"
}, },
commands = { commands = {
"%{ins[2]} "..e.method.." %{ins[1]} 5 %{ins[3]}", "(%{ins[2]} "..e.method.." %{ins[1]} 5 %{ins[3]} || echo FAILED) 2>&1 > %{outs}",
"touch %{outs}"
} }
} }
end end
return normalrule { return bundle {
name = e.name, name = e.name,
outleaves = { "stamp" }, srcs = tests,
ins = tests,
commands = { "touch %{outs}" }
} }
end end
) )

View file

@ -26,7 +26,10 @@ void writehex(uint32_t code)
void fail(uint32_t code) void fail(uint32_t code)
{ {
write(1, "@@FAIL 0x", 10); static const char fail_msg[] = "@@FAIL 0x";
static const char nl_msg[] = "\n";
write(1, fail_msg, sizeof(fail_msg)-1);
writehex(code); writehex(code);
write(1, "\n", 1); write(1, nl_msg, sizeof(nl_msg)-1);
} }

View file

@ -26,7 +26,7 @@ get_test_output() {
qemu-system-ppc) img="-kernel $img" ;; qemu-system-ppc) img="-kernel $img" ;;
esac esac
$timeoutprog -t $timeout -- $method -nographic $img > $result $timeoutprog -t $timeout -- $method -nographic $img 2>&1 > $result
;; ;;
qemu-*) qemu-*)
@ -35,7 +35,7 @@ get_test_output() {
exit 0 exit 0
fi fi
$method $img > $result $method $img 2>&1 > $result
;; ;;
*) *)
@ -45,6 +45,6 @@ get_test_output() {
esac esac
} }
get_test_output > $result get_test_output
( grep -q @@FAIL $result || ! grep -q @@FINISHED $result ) && cat $result && exit 1 ( grep -q @@FAIL $result || ! grep -q @@FINISHED $result ) && cat $result && exit 1
exit 0 exit 0

View file

@ -5,3 +5,4 @@ cprogram {
"modules/src/data+lib" "modules/src/data+lib"
} }
} }

View file

@ -6,6 +6,7 @@
#include <signal.h> #include <signal.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <setjmp.h> #include <setjmp.h>
#include <ctype.h>
#include "diagnostics.h" #include "diagnostics.h"
static bool timed_out = false; static bool timed_out = false;
@ -57,6 +58,7 @@ int main(int argc, char* const argv[])
FILE* childin; FILE* childin;
int wstatus; int wstatus;
char buffer[4096]; char buffer[4096];
char* p;
parse_arguments(argc, argv); parse_arguments(argc, argv);
@ -90,9 +92,13 @@ int main(int argc, char* const argv[])
break; break;
fputs(buffer, stdout); fputs(buffer, stdout);
if (strcmp(buffer, "@@FINISHED\n") == 0) p = buffer;
while (isspace(*p))
p++;
if (strcmp(p, "@@FINISHED\n") == 0)
break; break;
if (strcmp(buffer, "@@FINISHED\r\n") == 0) if (strcmp(p, "@@FINISHED\r\n") == 0)
break; break;
} }
@ -103,6 +109,9 @@ int main(int argc, char* const argv[])
kill(pid, SIGKILL); kill(pid, SIGKILL);
waitpid(pid, &wstatus, 0); waitpid(pid, &wstatus, 0);
if (timed_out) if (timed_out)
{
fprintf(stderr, "@@TIMEDOUT\n");
exit(1); exit(1);
}
exit(WEXITSTATUS(wstatus)); exit(WEXITSTATUS(wstatus));
} }