From f9985636de01268059c9c353ac608bb228266fdb Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 21 Jun 2021 13:30:29 +1000 Subject: [PATCH] test: fail if we can't chdir to $TMPDIR Otherwise our tests may have unpredictable behavior depending on leftover files in $PWD. --- test/pwtest.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/pwtest.c b/test/pwtest.c index 7a04e91dc..491ce19ab 100644 --- a/test/pwtest.c +++ b/test/pwtest.c @@ -914,8 +914,11 @@ static void run_test(struct pwtest_context *ctx, struct pwtest_suite *c, struct } set_test_env(ctx, t); - chdir(getenv("TMPDIR")); - + r = chdir(getenv("TMPDIR")); + if (r < 0) { + t->sig_or_errno = -errno; + return; + } if (t->args.pw_daemon) { pw_daemon = start_pwdaemon(t, write_fds[FD_DAEMON], write_fds[FD_LOG]);