From a9cfc4ce439aed41cac84d342d088cef3ec83ae4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 26 Mar 2021 13:52:38 +0000 Subject: test: Explicitly enable assertion macros To allow dbus-glib to be built with G_DISABLE_ASSERT defined but tests enabled (--disable-asserts --enable-tests), we need to explicitly undefine it when building the tests, otherwise g_test_init() turns into an abort since GLib 2.58. We no longer actually use g_assert() for test-only code, so we can remove the warning about tests' failing results not being reported. test-profile.c still leaves assertions disabled: it does not use g_test_init(), and it is intended to be used for profiling, where the overhead of assertions is potentially significant. Resolves: #16 Signed-off-by: Simon McVittie --- configure.ac | 3 --- test/core/error-mapping.c | 1 + test/core/manual/invalid-usage.c | 1 + test/core/my-object-subclass.c | 2 ++ test/core/my-object.c | 2 ++ test/core/peer-client.c | 1 + test/core/peer-on-bus.c | 1 + test/core/peer-server.c | 1 + test/core/proxy-noc.c | 1 + test/core/proxy-peer.c | 1 + test/core/registrations.c | 1 + test/core/shared-bus.c | 1 + test/core/test-dbus-glib.c | 1 + test/core/test-gvariant.c | 1 + test/core/test-service-glib.c | 1 + test/core/test-types.c | 1 + test/core/test-variant-recursion.c | 1 + test/core/unsupported-type.c | 1 + test/errors.c | 1 + test/interfaces/test-client.c | 1 + test/interfaces/test-dup-prop.c | 1 + test/interfaces/test-interfaces.c | 1 + test/interfaces/test-objects.c | 1 + test/interfaces/test-server.c | 1 + test/specialized-types.c | 1 + test/test-service.c | 1 + 26 files changed, 27 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 83f9454..b9292b9 100644 --- a/configure.ac +++ b/configure.ac @@ -344,9 +344,6 @@ echo " if test x$enable_tests = xyes; then echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure." fi -if test x$enable_tests = xyes -a x$enable_asserts = xno; then - echo "NOTE: building with unit tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)" -fi if test x$enable_gcov = xyes; then echo "NOTE: building with coverage profiling is definitely for developers only." fi diff --git a/test/core/error-mapping.c b/test/core/error-mapping.c index 58306b4..9d0c0b1 100644 --- a/test/core/error-mapping.c +++ b/test/core/error-mapping.c @@ -26,6 +26,7 @@ */ #include +#undef G_DISABLE_ASSERT #include #include diff --git a/test/core/manual/invalid-usage.c b/test/core/manual/invalid-usage.c index e87007d..383c1f5 100644 --- a/test/core/manual/invalid-usage.c +++ b/test/core/manual/invalid-usage.c @@ -28,6 +28,7 @@ */ #include +#undef G_DISABLE_ASSERT #include diff --git a/test/core/my-object-subclass.c b/test/core/my-object-subclass.c index a5e4035..bb23484 100644 --- a/test/core/my-object-subclass.c +++ b/test/core/my-object-subclass.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT + #include #include #include diff --git a/test/core/my-object.c b/test/core/my-object.c index 02839cb..1414093 100644 --- a/test/core/my-object.c +++ b/test/core/my-object.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT + #include #include #include diff --git a/test/core/peer-client.c b/test/core/peer-client.c index ba95616..73b4383 100644 --- a/test/core/peer-client.c +++ b/test/core/peer-client.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT #include #include diff --git a/test/core/peer-on-bus.c b/test/core/peer-on-bus.c index 87ff2d8..c40fc4c 100644 --- a/test/core/peer-on-bus.c +++ b/test/core/peer-on-bus.c @@ -38,6 +38,7 @@ */ #include +#undef G_DISABLE_ASSERT #include #include diff --git a/test/core/peer-server.c b/test/core/peer-server.c index 7b69c8b..e59a347 100644 --- a/test/core/peer-server.c +++ b/test/core/peer-server.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT #include #include diff --git a/test/core/proxy-noc.c b/test/core/proxy-noc.c index 843f1c3..320a24e 100644 --- a/test/core/proxy-noc.c +++ b/test/core/proxy-noc.c @@ -34,6 +34,7 @@ */ #ifdef HAVE_CONFIG_H #include +#undef G_DISABLE_ASSERT #endif #include diff --git a/test/core/proxy-peer.c b/test/core/proxy-peer.c index 87d8d0a..2f4e538 100644 --- a/test/core/proxy-peer.c +++ b/test/core/proxy-peer.c @@ -27,6 +27,7 @@ */ #include +#undef G_DISABLE_ASSERT #include diff --git a/test/core/registrations.c b/test/core/registrations.c index 621f9d1..35b09fa 100644 --- a/test/core/registrations.c +++ b/test/core/registrations.c @@ -38,6 +38,7 @@ */ #include +#undef G_DISABLE_ASSERT #include #include diff --git a/test/core/shared-bus.c b/test/core/shared-bus.c index df998ed..802f0a3 100644 --- a/test/core/shared-bus.c +++ b/test/core/shared-bus.c @@ -26,6 +26,7 @@ */ #include +#undef G_DISABLE_ASSERT #include diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c index 1a544d5..629830d 100644 --- a/test/core/test-dbus-glib.c +++ b/test/core/test-dbus-glib.c @@ -27,6 +27,7 @@ */ #include +#undef G_DISABLE_ASSERT /* -*- mode: C; c-file-style: "gnu" -*- */ #include diff --git a/test/core/test-gvariant.c b/test/core/test-gvariant.c index 8a6bced..0437675 100644 --- a/test/core/test-gvariant.c +++ b/test/core/test-gvariant.c @@ -28,6 +28,7 @@ */ #include +#undef G_DISABLE_ASSERT #include #include diff --git a/test/core/test-service-glib.c b/test/core/test-service-glib.c index 1b328f7..5e05ded 100644 --- a/test/core/test-service-glib.c +++ b/test/core/test-service-glib.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT /* -*- mode: C; c-file-style: "gnu" -*- */ #include diff --git a/test/core/test-types.c b/test/core/test-types.c index 00b522c..11348f3 100644 --- a/test/core/test-types.c +++ b/test/core/test-types.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT #include #include diff --git a/test/core/test-variant-recursion.c b/test/core/test-variant-recursion.c index bc6df8e..464f7e5 100644 --- a/test/core/test-variant-recursion.c +++ b/test/core/test-variant-recursion.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT /* -*- mode: C; c-file-style: "gnu" -*- */ #include diff --git a/test/core/unsupported-type.c b/test/core/unsupported-type.c index ac4d7df..2134a99 100644 --- a/test/core/unsupported-type.c +++ b/test/core/unsupported-type.c @@ -37,6 +37,7 @@ */ #include +#undef G_DISABLE_ASSERT #include #include diff --git a/test/errors.c b/test/errors.c index cf2110e..812e031 100644 --- a/test/errors.c +++ b/test/errors.c @@ -24,6 +24,7 @@ */ #include +#undef G_DISABLE_ASSERT #include diff --git a/test/interfaces/test-client.c b/test/interfaces/test-client.c index 8fc60a0..9f7b58e 100644 --- a/test/interfaces/test-client.c +++ b/test/interfaces/test-client.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT #include #include diff --git a/test/interfaces/test-dup-prop.c b/test/interfaces/test-dup-prop.c index 8c27fb7..0400a73 100644 --- a/test/interfaces/test-dup-prop.c +++ b/test/interfaces/test-dup-prop.c @@ -2,6 +2,7 @@ #ifdef HAVE_CONFIG_H # include +# undef G_DISABLE_ASSERT #endif #include "test-dup-prop.h" diff --git a/test/interfaces/test-interfaces.c b/test/interfaces/test-interfaces.c index de56669..d0274ef 100644 --- a/test/interfaces/test-interfaces.c +++ b/test/interfaces/test-interfaces.c @@ -2,6 +2,7 @@ #ifdef HAVE_CONFIG_H # include +# undef G_DISABLE_ASSERT #endif #include "test-interfaces.h" diff --git a/test/interfaces/test-objects.c b/test/interfaces/test-objects.c index 3533453..c11cbdc 100644 --- a/test/interfaces/test-objects.c +++ b/test/interfaces/test-objects.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT #include "test-objects.h" #include "test-interfaces.h" diff --git a/test/interfaces/test-server.c b/test/interfaces/test-server.c index 7d55723..4d32707 100644 --- a/test/interfaces/test-server.c +++ b/test/interfaces/test-server.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT #include #include "dbus/dbus-glib.h" diff --git a/test/specialized-types.c b/test/specialized-types.c index ce5d82d..2290082 100644 --- a/test/specialized-types.c +++ b/test/specialized-types.c @@ -24,6 +24,7 @@ */ #include +#undef G_DISABLE_ASSERT #include diff --git a/test/test-service.c b/test/test-service.c index 1a61058..eae6234 100644 --- a/test/test-service.c +++ b/test/test-service.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later */ #include +#undef G_DISABLE_ASSERT #include #include -- cgit v1.2.1