[glib/wip/smcv/address-sanitizer: 25/28] gtestutils: Default to -m no-undefined under AddressSanitizer
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/smcv/address-sanitizer: 25/28] gtestutils: Default to -m no-undefined under AddressSanitizer
- Date: Mon, 1 Feb 2021 11:21:41 +0000 (UTC)
commit 9fef98cf84216b33b6a2a488b544cd4056232ac1
Author: Simon McVittie <smcv collabora com>
Date: Fri Jan 29 18:58:48 2021 +0000
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>
glib/gtestutils.c | 12 ++++++++++--
1 file 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 *)))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]