From 4bb9e20fff26300411716fba0c9969d3f866890e Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 23 Dec 2021 13:04:49 +0000 Subject: [PATCH] tests: Fix environment test on FreeBSD Fix for commit 20c8ea1bc651bc4b79d39b80d42b468f6e7a2dc8; while Linux seems happy to return the value for the invalid key we set above, BSD returns NULL (which is probably a more valid thing to do). Accept both. Signed-off-by: Philip Withnall --- glib/tests/environment.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glib/tests/environment.c b/glib/tests/environment.c index 486acc907..6400e3a69 100644 --- a/glib/tests/environment.c +++ b/glib/tests/environment.c @@ -103,8 +103,11 @@ test_getenv (void) g_assert_true (g_setenv ("foo", "bar=baz", TRUE)); + /* Different OSs return different values; some return NULL because the key + * is invalid, but some are happy to return what we set above. */ data = g_getenv ("foo=bar"); - g_assert_cmpstr (data, ==, "baz"); + if (data != NULL) + g_assert_cmpstr (data, ==, "baz"); data = g_getenv ("foo"); g_assert_cmpstr (data, ==, "bar=baz");