X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=test%2Fsetup.cpp;h=a506976a0c793d750a7d6f23169476e59941bf0d;hb=e1ba5b9e4eb179295274026ad8fd40a68eb6c67f;hp=493b591f0825cb5ea271e3008ea191a0dffd531d;hpb=03ba544b4ef8a00bd4d51dfde1ed2bfb477096dc;p=m6w6%2Flibmemcached diff --git a/test/setup.cpp b/test/setup.cpp index 493b591f..a506976a 100644 --- a/test/setup.cpp +++ b/test/setup.cpp @@ -1,11 +1,14 @@ #include "mem_config.h" +#include "test/conf.h" #include "test/lib/env.hpp" +#include "test/lib/random.hpp" #include #include #include #include #include #include +#include static void sigchld(int, siginfo_t *si, void *) { switch (si->si_code) { @@ -30,7 +33,6 @@ static void sigchld(int, siginfo_t *si, void *) { static inline void setup_signals() { struct sigaction sa; - memset(&sa, 0, sizeof(sa)); sa.sa_flags = SA_NOCLDSTOP | SA_RESTART | SA_SIGINFO | SA_NODEFER; @@ -54,6 +56,10 @@ static inline void setup_signals() { "verify_asan_link_order=1," \ "abort_on_error=0," \ "" +# define LSAN_OPTIONS \ + "suppressions=" SOURCES_ROOT "/test/LeakSanitizer.suppressions," \ + "" + static inline void setup_asan(char **argv) { const auto set = getenv("ASAN_OPTIONS"); @@ -63,8 +69,36 @@ static inline void setup_asan(char **argv) { perror("exec()"); } } +static inline void setup_lsan(char **argv) { + const auto set = getenv("LSAN_OPTIONS"); + + if (!set || !*set) { + SET_ENV_EX(lsan, "LSAN_OPTIONS", LSAN_OPTIONS, 0); + execvp(argv[0], argv); + perror("exec()"); + } +} #else # define setup_asan(a) (void) a +# define setup_lsan(a) (void) a +#endif + +#if HAVE_TSAN +# define TSAN_OPTIONS \ + "abort_on_error=0," \ + "halt_on_error=0" \ + "" +static inline void setup_tsan(char **argv) { + const auto set = getenv("TSAN_OPTIONS"); + + if (!set || !*set) { + SET_ENV_EX(tsan, "TSAN_OPTIONS", TSAN_OPTIONS, 0); + execvp(argv[0], argv); + perror("exec()"); + } +} +#else +# define setup_tsan(a) (void) a #endif #if LIBMEMCACHED_WITH_SASL_SUPPORT @@ -76,9 +110,16 @@ static inline void setup_sasl() { # define setup_sasl() #endif +static inline void setup_random() { + random_setup(); +} + int setup(int &, char ***argv) { setup_signals(); + setup_random(); setup_asan(*argv); + setup_lsan(*argv); + setup_tsan(*argv); setup_sasl(); return 0;