]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test: Replace _dbus_assert_not_reached()
authorSimon McVittie <smcv@collabora.com>
Thu, 16 Apr 2020 13:21:36 +0000 (14:21 +0100)
committerSimon McVittie <smcv@collabora.com>
Mon, 20 Apr 2020 09:13:07 +0000 (10:13 +0100)
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 <smcv@collabora.com>
test/CMakeLists.txt
test/Makefile.am
test/internals/misc-internals.c
test/manual-paths.c
test/test-service.c

index d0cc8d4d30512a731787af298d76fd49543813e1..f78bba54e0b88350666ec20c5016f174164b5e7f 100644 (file)
@@ -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)
index a992bf912d746fb43d1cdf81325056ef3cb3bb8a..b539524ce23ba608de871c41c07c522acaa2df16 100644 (file)
@@ -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
index 3f66b8e3ef7881d8e4fde0090436fefd6e71e5f2..ddd4a306c5d988caaeaa68fd36f2e390880e2cab 100644 (file)
@@ -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);
index 82fc669d8d6ac50cd93fe18f9e58c1c43f8abae1..225ab1e80552c04ae24a3fb887ad91abcc3087e0 100644 (file)
@@ -9,6 +9,7 @@
 #include "dbus/dbus-list.h"
 #include "dbus/dbus-internals.h"
 #include "dbus/dbus-sysdeps.h"
+#include "test-utils.h"
 
 #include <stdio.h>
 
@@ -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;
     }
index 34bedb2d53541b287a82e244ac28a6f974edcda3..ed6a4b4160c19125ba49db7279afc5c95c48189c 100644 (file)
@@ -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;