diff --git a/tests/daemon_test.py b/tests/daemon_test.py index 83cd81d..6ff8c8a 100644 --- a/tests/daemon_test.py +++ b/tests/daemon_test.py @@ -995,7 +995,8 @@ def a_worker_line_too_long_to_relay_is_dropped_whole(): check(d.wait_event("remote_pages_changed ", since=mark) == "remote_pages_changed 3", "the line after the %d-byte one, unchanged" % size) with d.lock: - pieces = ["%d bytes" % len(e) for e in d.events[mark:] if e.startswith("x")] + # an empty line is a piece too: the end of a 2 MiB line whose start filled the relay buffer + pieces = ["%d bytes" % len(e) for e in d.events[mark:] if e.startswith("x") or not e] check(not pieces, "no piece of a %d-byte line reaches the controller: %s" % (size, pieces)) # the longest line relayed arrives whole mark = d.mark() diff --git a/tests/lv2_fixture.c b/tests/lv2_fixture.c index 934fdf1..e275fb6 100644 --- a/tests/lv2_fixture.c +++ b/tests/lv2_fixture.c @@ -107,11 +107,13 @@ static void run(LV2_Handle instance, uint32_t frames) /* stress: the gain, with the fault STRESS_FAULT names on its first run() in the process, as tests/stress_plugin.c does * for CLAP: crash aborts, hang spins forever, fork leaves a process of its own session behind (its pid written to the - * file STRESS_FORK_PIDFILE names) */ + * file STRESS_FORK_PIDFILE names before run() returns) */ static void fault_once(void) { static int done; const char *fault = getenv("STRESS_FAULT"); + int ready[2]; + char c; if (done || !fault) return; @@ -121,23 +123,31 @@ static void fault_once(void) if (!strcmp(fault, "hang")) for (;;) ; - if (!strcmp(fault, "fork") && fork() == 0) + if (!strcmp(fault, "fork") && pipe(ready) == 0) { - const char *pidfile = getenv("STRESS_FORK_PIDFILE"); - - setsid(); - if (pidfile) + if (fork() == 0) { - FILE *f = fopen(pidfile, "w"); + const char *pidfile = getenv("STRESS_FORK_PIDFILE"); - if (f) + setsid(); + if (pidfile) { - fprintf(f, "%d\n", (int)getpid()); - fclose(f); + FILE *f = fopen(pidfile, "w"); + + if (f) + { + fprintf(f, "%d\n", (int)getpid()); + fclose(f); + } } + close(ready[1]); + sleep(60); + _exit(0); } - sleep(60); - _exit(0); + close(ready[1]); + while (read(ready[0], &c, 1) > 0) + ; + close(ready[0]); } } diff --git a/tests/stress_plugin.c b/tests/stress_plugin.c index f58c225..0dce30a 100644 --- a/tests/stress_plugin.c +++ b/tests/stress_plugin.c @@ -23,7 +23,7 @@ * STRESS_FAULT=crash the first process call aborts * STRESS_FAULT=hang the first process call never returns * STRESS_FAULT=fork the first process call leaves a process behind that starts its own session and sleeps a - * minute; its pid is written to the file STRESS_FORK_PIDFILE names + * minute; the call returns once its pid is written to the file STRESS_FORK_PIDFILE names */ /* A stereo passthrough .clap the daemon's tests break on purpose: * org.plugin-hostd.test.stress parameters @@ -302,6 +302,8 @@ static void fault_once(void) { static int done; const char *fault = getenv("STRESS_FAULT"); + int ready[2]; + char c; if (done || !fault) return; @@ -311,7 +313,7 @@ static void fault_once(void) if (!strcmp(fault, "hang")) for (;;) ; - if (!strcmp(fault, "fork")) + if (!strcmp(fault, "fork") && pipe(ready) == 0) { pid_t pid = fork(); @@ -330,9 +332,14 @@ static void fault_once(void) fclose(f); } } + close(ready[1]); sleep(60); _exit(0); } + close(ready[1]); + while (read(ready[0], &c, 1) > 0) + ; + close(ready[0]); } }