summaryrefslogtreecommitdiff
path: root/src/cmd/tests/tests.c
diff options
context:
space:
mode:
authordzwdz2023-08-29 23:02:42 +0200
committerdzwdz2023-08-29 23:02:42 +0200
commitdd385a413c92d53a1f792011e1029d7d68e19c6c (patch)
tree134fa61d71f6894e37a1b890004cfcb2d96ea17b /src/cmd/tests/tests.c
parente43939bcc6123e02314aa403eef94d5ace441f7f (diff)
tests: fix everything broken by the pipe change
god, those tests are a mess. so are esemaphores.
Diffstat (limited to 'src/cmd/tests/tests.c')
-rw-r--r--src/cmd/tests/tests.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/cmd/tests/tests.c b/src/cmd/tests/tests.c
index 5cba682..ce28eb3 100644
--- a/src/cmd/tests/tests.c
+++ b/src/cmd/tests/tests.c
@@ -1,21 +1,26 @@
#include "tests.h"
#include <camellia/syscalls.h>
+#include <sys/wait.h>
#include <unistd.h>
-__attribute__((visibility("hidden")))
-extern char __executable_start[];
-
FILE *fail_trig;
-void run_test(void (*fn)()) {
- if (!fork()) {
+void run_test_inner(void (*fn)(), const char *s) {
+ int pid = fork();
+ if (pid == 0) {
fn();
_sys_filicide();
exit(0);
+ } else if (pid < 0) {
+ /* working around macro stupidity */
+ test_failf("%s", "in fork");
} else {
/* successful tests must return 0 */
- if (_sys_await() != 0) {
- test_failf("%p, base %p", (void*)((void*)fn - (void*)__executable_start), __executable_start);
+ int status;
+ if (waitpid(pid, &status, 0) != pid) {
+ test_failf("%s", "waitpid returned something weird");
+ } else if (WEXITSTATUS(status) != 0) {
+ test_failf("%s exited with %d", s, WEXITSTATUS(status));
}
}
}