diff options
author | Simon McVittie <smcv@collabora.com> | 2021-01-29 18:58:48 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2021-01-29 20:28:26 +0000 |
commit | 766295dfb757cd6e5a4c44c6776c89455191f204 (patch) | |
tree | 3ec3e86283740a491f640a9c57d51141dfa9040b | |
parent | 4c5a6a129d9fdaec15f58c6fb66fecebfd9a919d (diff) | |
download | glib-766295dfb757cd6e5a4c44c6776c89455191f204.tar.gz |
gtestutils: Default to -m no-undefined under AddressSanitizer
AddressSanitizer detects memory leaks, NULL parameters where only a
non-NULL parameter is expected, and other suspicious behaviour, so if
we try to test that sort of thing we can expect it to fail.
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | glib/gtestutils.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/glib/gtestutils.c b/glib/gtestutils.c index 473e1b677..5660fc8be 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -309,8 +309,12 @@ * behaviour, to verify that appropriate warnings are given. It might, in some * cases, be useful to turn this off with if running tests under valgrind; * in tests that use g_test_init(), the option `-m no-undefined` disables - * those tests, while `-m undefined` explicitly enables them (the default - * behaviour). + * those tests, while `-m undefined` explicitly enables them (normally + * the default behaviour). + * + * Since GLib 2.68, if GLib was compiled with gcc or clang and + * [AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer) + * is enabled, the default changes to not exercising undefined behaviour. * * Returns: %TRUE if tests may provoke programming errors */ @@ -1573,6 +1577,10 @@ void g_return_if_fail (g_test_config_vars->test_initialized == FALSE); mutable_test_config_vars.test_initialized = TRUE; +#ifdef _GLIB_ADDRESS_SANITIZER + mutable_test_config_vars.test_undefined = FALSE; +#endif + va_start (args, argv); while ((option = va_arg (args, char *))) { |