Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/daemon_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
34 changes: 22 additions & 12 deletions tests/lv2_fixture.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]);
}
}

Expand Down
11 changes: 9 additions & 2 deletions tests/stress_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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();

Expand All @@ -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]);
}
}

Expand Down
Loading