From 416c7560ea7518f51d18541dec30d34594425518 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 12 Feb 2015 18:23:31 +0000 Subject: [PATCH] loopback test: cope with being run without XDG_RUNTIME_DIR This could happen during installed-tests. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61303 --- test/loopback.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/loopback.c b/test/loopback.c index 18ca588..930008c 100644 --- a/test/loopback.c +++ b/test/loopback.c @@ -315,7 +315,10 @@ teardown_no_runtime (Fixture *f, teardown (f, addr); /* we're relying on being single-threaded for this to be safe */ - g_setenv ("XDG_RUNTIME_DIR", f->saved_runtime_dir, TRUE); + if (f->saved_runtime_dir != NULL) + g_setenv ("XDG_RUNTIME_DIR", f->saved_runtime_dir, TRUE); + else + g_unsetenv ("XDG_RUNTIME_DIR"); g_free (f->saved_runtime_dir); } @@ -335,7 +338,10 @@ teardown_runtime (Fixture *f, g_assert_cmpint (g_rmdir (f->tmp_runtime_dir), ==, 0); /* we're relying on being single-threaded for this to be safe */ - g_setenv ("XDG_RUNTIME_DIR", f->saved_runtime_dir, TRUE); + if (f->saved_runtime_dir != NULL) + g_setenv ("XDG_RUNTIME_DIR", f->saved_runtime_dir, TRUE); + else + g_unsetenv ("XDG_RUNTIME_DIR"); g_free (f->saved_runtime_dir); g_free (f->tmp_runtime_dir); } -- 2.1.4