From 5ebfbccd16c0e387fc661871e412dca8281c2c53 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 7 Jul 2021 12:18:52 +1000 Subject: [PATCH] pwtest: if a test expects a signal, skip it under valgrind Running under valgrind enforces --no-fork so any signal will cause valgrind to error out, failing the test abnormally. This prevents us from running our test suite through valgrind, we'd have to mark every test specifically whether it should run under valgrind or not. Easier is just to automatically skip tests expecting signals. --- test/pwtest.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/pwtest.c b/test/pwtest.c index e0e0429cc..70969f56c 100644 --- a/test/pwtest.c +++ b/test/pwtest.c @@ -412,6 +412,7 @@ void _pwtest_add(struct pwtest_context *ctx, struct pwtest_suite *suite, return; t = calloc(1, sizeof *t); + t->result = PWTEST_SYSTEM_ERROR; t->name = funcname; t->func = func; t->args.range.min = 0; @@ -432,6 +433,8 @@ void _pwtest_add(struct pwtest_context *ctx, struct pwtest_suite *suite, case PWTEST_NOARG: break; case PWTEST_ARG_SIGNAL: + if (RUNNING_ON_VALGRIND) + t->result = PWTEST_SKIP; t->args.signal = va_arg(args, int); break; case PWTEST_ARG_RANGE: @@ -908,6 +911,12 @@ static void run_test(struct pwtest_context *ctx, struct pwtest_suite *c, struct int read_fds[_FD_LAST], write_fds[_FD_LAST]; int r; + if (t->result == PWTEST_SKIP) { + char *buf = pw_array_add(&t->logs[FD_LOG], 64); + spa_scnprintf(buf, 64, "pwtest: test skipped by pwtest\n"); + return; + } + t->result = PWTEST_SYSTEM_ERROR; r = init_pipes(read_fds, write_fds);