aboutsummaryrefslogtreecommitdiffstats
path: root/eztester.c
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2024-07-26 15:25:12 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2024-07-26 15:25:12 -0400
commitbbc91111375e5ecd2be708fe8c2baea88093eb1a (patch)
tree8733ae289efa3bf75037829147e76e47fa9a769d /eztester.c
parentbf52a4a4ab8db88575083202bb16aa03f7952ce2 (diff)
FEAT: worker now raises SIGSTOP while waiting for work
Diffstat (limited to 'eztester.c')
-rw-r--r--eztester.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/eztester.c b/eztester.c
index ef6ad94..38d02dc 100644
--- a/eztester.c
+++ b/eztester.c
@@ -110,7 +110,7 @@ void _ez_worker(volatile struct _ez_shared_mem *mem,
while (mem->index < list->length) {
// wait for work
while (!mem->work_in_queue) {
- usleep(1000 * 50);
+ usleep(50e3);
}
mem->status = list->tests[mem->index].runner();
@@ -122,6 +122,7 @@ void _ez_worker(volatile struct _ez_shared_mem *mem,
}
mem->work_in_queue = false;
+ raise(SIGSTOP);
}
exit(0);
}
@@ -129,13 +130,14 @@ void _ez_worker(volatile struct _ez_shared_mem *mem,
void _ez_chld_handler(int signum) {
int status;
pid_t pid;
- _ez_child_premature_exit = 1;
- while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
+ while ((pid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 0) {
if (WIFEXITED(status)) {
_ez_child_premature_exit_status = WEXITSTATUS(status);
+ _ez_child_premature_exit = 1;
} else if (WIFSIGNALED(status)) {
_ez_child_premature_exit_signal = WTERMSIG(status);
+ _ez_child_premature_exit = 1;
}
}
}
@@ -174,17 +176,17 @@ void eztester_run(eztester_list *test_list, eztester_behavior behavior) {
printf("[%03zu/%03zu] Testing: %s\n", results.current, results.total,
test.name);
fflush(stdout);
- if (_ez_child_premature_exit) {
- _ez_premature_exit("Worker Process ended prematurely!", pid, mem,
- results);
- }
+
+ kill(pid, SIGCONT);
+
while (mem->work_in_queue) {
- usleep(1000 * 50);
+ usleep(50e3);
if (_ez_child_premature_exit) {
_ez_premature_exit("Worker Process ended prematurely!", pid, mem,
results);
}
}
+
status = mem->status;
switch (status) {