testing: bin/memaslap
[awesomized/libmemcached] / test / setup.cpp
index 1f4c9a477d12b96ad48b6965d6e8ff8462ad3dcd..9591a3569c7b982350bfdf35fe6dc8a6563c5698 100644 (file)
@@ -1,4 +1,5 @@
 #include "mem_config.h"
+#include "test/lib/env.hpp"
 #include <cstdlib>
 #include <cstdio>
 #include <cstring>
@@ -7,12 +8,6 @@
 #include <string>
 #include <unistd.h>
 
-#if HAVE_SETENV
-# define SET_ENV(n, k, v) setenv(k, v, 0)
-#else // !HAVE_SETENV
-# define SET_ENV(n, k, v) static char n ## _env[] = k "=" v; putenv(n ## _env)
-#endif
-
 static void sigchld(int, siginfo_t *si, void *) {
   switch (si->si_code) {
   case CLD_EXITED:
@@ -64,19 +59,19 @@ static inline void setup_asan(char **argv) {
   const auto set = getenv("ASAN_OPTIONS");
 
   if (!set || !*set) {
-    SET_ENV(asan, "ASAN_OPTIONS", ASAN_OPTIONS);
+    SET_ENV_EX(asan, "ASAN_OPTIONS", ASAN_OPTIONS, 0);
     execvp(argv[0], argv);
     perror("exec()");
   }
 }
 #else
-# define setup_asan(a)
+# define setup_asan(a) (void) a
 #endif
 
 #if LIBMEMCACHED_WITH_SASL_SUPPORT
 static inline void setup_sasl() {
-  SET_ENV(sasl_pwdb, "MEMCACHED_SASL_PWDB", LIBMEMCACHED_WITH_SASL_PWDB);
-  SET_ENV(sasl_conf, "SASL_CONF_PATH", LIBMEMCACHED_WITH_SASL_CONF);
+  SET_ENV_EX(sasl_pwdb, "MEMCACHED_SASL_PWDB", LIBMEMCACHED_WITH_SASL_PWDB, 0);
+  SET_ENV_EX(sasl_conf, "SASL_CONF_PATH", LIBMEMCACHED_WITH_SASL_CONF, 0);
 }
 #else
 # define setup_sasl()