From: Simon McVittie Date: Thu, 16 Apr 2020 13:21:36 +0000 (+0100) Subject: test: Replace _dbus_assert_not_reached() X-Git-Tag: dbus-1.13.14~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e559663e038cc48aa7120cd6f3d4ed52a4e9abca;p=thirdparty%2Fdbus.git test: Replace _dbus_assert_not_reached() Assertions can be disabled; but in test code the assertions are the entire point, so we don't want to disable them. Use _dbus_test_fatal() instead. test-service is actually a test helper rather than a test, so use its pre-existing die() function instead. Signed-off-by: Simon McVittie --- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d0cc8d4d3..f78bba54e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -92,7 +92,7 @@ add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} ${DBUS_IN add_helper_executable(manual-tcp ${manual-tcp_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_helper_executable(manual-backtrace manual-backtrace.c dbus-1) if(WIN32) - add_helper_executable(manual-paths ${manual-paths_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) + add_helper_executable(manual-paths ${manual-paths_SOURCES} dbus-testutils) endif() if(DBUS_ENABLE_EMBEDDED_TESTS) diff --git a/test/Makefile.am b/test/Makefile.am index a992bf912..b539524ce 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -175,7 +175,7 @@ manual_dir_iter_SOURCES = manual-dir-iter.c manual_dir_iter_LDADD = $(top_builddir)/dbus/libdbus-internal.la manual_paths_SOURCES = manual-paths.c -manual_paths_LDADD = $(top_builddir)/dbus/libdbus-internal.la +manual_paths_LDADD = libdbus-testutils.la manual_tcp_SOURCES = manual-tcp.c manual_tcp_LDADD = $(top_builddir)/dbus/libdbus-internal.la diff --git a/test/internals/misc-internals.c b/test/internals/misc-internals.c index 3f66b8e3e..ddd4a306c 100644 --- a/test/internals/misc-internals.c +++ b/test/internals/misc-internals.c @@ -698,7 +698,7 @@ _dbus_server_test (const char *test_data_dir _DBUS_GNUC_UNUSED) { _dbus_warn ("server listen error: %s: %s", error.name, error.message); dbus_error_free (&error); - _dbus_assert_not_reached ("Failed to listen for valid address."); + _dbus_test_fatal ("Failed to listen for valid address."); } id = dbus_server_get_id (server); @@ -710,7 +710,7 @@ _dbus_server_test (const char *test_data_dir _DBUS_GNUC_UNUSED) { _dbus_warn ("server id '%s' is not in the server address '%s'", id, address); - _dbus_assert_not_reached ("bad server id or address"); + _dbus_test_fatal ("bad server id or address"); } dbus_free (id); diff --git a/test/manual-paths.c b/test/manual-paths.c index 82fc669d8..225ab1e80 100644 --- a/test/manual-paths.c +++ b/test/manual-paths.c @@ -9,6 +9,7 @@ #include "dbus/dbus-list.h" #include "dbus/dbus-internals.h" #include "dbus/dbus-sysdeps.h" +#include "test-utils.h" #include @@ -19,13 +20,13 @@ print_install_root (void) if (!_dbus_string_init (&runtime_prefix)) { - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); return FALSE; } if (!_dbus_get_install_root (&runtime_prefix)) { - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_string_free (&runtime_prefix); return FALSE; } @@ -51,7 +52,7 @@ print_service_dirs (void) dirs = NULL; if (!_dbus_get_standard_session_servicedirs (&dirs)) - _dbus_assert_not_reached ("couldn't get standard dirs"); + _dbus_test_fatal ("couldn't get standard dirs"); while ((link = _dbus_list_pop_first_link (&dirs))) { @@ -69,14 +70,14 @@ static dbus_bool_t print_replace_install_prefix(const char *s) if (!_dbus_string_init (&str)) { - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); return FALSE; } if (!_dbus_string_append (&str, s) || !_dbus_replace_install_prefix (&str)) { - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_string_free (&str); return FALSE; } diff --git a/test/test-service.c b/test/test-service.c index 34bedb2d5..ed6a4b416 100644 --- a/test/test-service.c +++ b/test/test-service.c @@ -114,7 +114,7 @@ check_hello_from_self_reply (DBusPendingCall *pcall, dbus_error_free (&error); } else - _dbus_assert_not_reached ("Unexpected message received"); + die ("Unexpected message received"); hello_from_self_reply_received = TRUE;