From 2073269f47558063d3faf87d83e877dc6d77f96b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 4 Jun 2021 09:51:55 +1000 Subject: [PATCH] test: set PIPEWIRE_REMOTE to a garbage value if we didn't start a test daemon Don't let tests connect to the system daemon which would happen if we don't have PIPEWIRE_REMOTE set at all. --- test/pwtest.c | 7 ++++++- test/test-example.c | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/pwtest.c b/test/pwtest.c index 89fa309d6..9b61cbdb7 100644 --- a/test/pwtest.c +++ b/test/pwtest.c @@ -145,7 +145,10 @@ static void replace_env(struct pwtest_test *t, const char *prop, const char *val const char *oldval = getenv(prop); pw_properties_set(t->env, prop, oldval ? oldval : "pwtest-null"); - setenv(prop, value, 1); + if (value) + setenv(prop, value, 1); + else + unsetenv(prop); } static void restore_env(struct pwtest_test *t) @@ -780,6 +783,8 @@ static void run_test(struct pwtest_context *ctx, struct pwtest_suite *c, struct errno = -pw_daemon; goto error; } + } else { + replace_env(t, "PIPEWIRE_REMOTE", "test-has-no-daemon"); } if (ctx->no_fork) { diff --git a/test/test-example.c b/test/test-example.c index 2739ccde9..d69a88fa8 100644 --- a/test/test-example.c +++ b/test/test-example.c @@ -185,6 +185,8 @@ PWTEST(default_env_test) { /* This one is set automatically */ pwtest_str_eq(getenv("PWTEST"), "1"); + /* Default value */ + pwtest_str_eq(getenv("PIPEWIRE_REMOTE"), "test-has-no-daemon"); return PWTEST_PASS; }