From f37cd4c227397bfbc8c0b635417f0bf85d7ded33 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 21 Apr 2010 12:25:29 -0400 Subject: [PATCH] Detect broken unsetenv at unit-test runtime If we have an unsetenv function that doesn't work, we can't run the main/base_environ unit test, so we should skip it. --- test/regress.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/regress.c b/test/regress.c index 532542a6..c230e1db 100644 --- a/test/regress.c +++ b/test/regress.c @@ -1831,6 +1831,18 @@ test_base_environ(void *arg) int i, n_methods=0; const char *defaultname; + /* See if unsetenv works before we rely on it. */ + setenv("EVENT_NOWAFFLES", "1", 1); + unsetenv("EVENT_NOWAFFLES"); + if (getenv("EVENT_NOWAFFLES") != NULL) { +#ifndef _EVENT_HAVE_UNSETENV + TT_DECLARE("NOTE", ("Can't fake unsetenv; skipping test")); +#else + TT_DECLARE("NOTE", ("unsetenv doesn't work; skipping test")); +#endif + tt_skip(); + } + basenames = event_get_supported_methods(); for (i = 0; basenames[i]; ++i) { methodname_to_envvar(basenames[i], varbuf, sizeof(varbuf)); -- 2.40.0