From 7e88ee36b013b7fe3c5708fbad98990517faa110 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 14 Nov 2017 14:17:53 +0000 Subject: [PATCH 07/13] Prefer to use _dbus_test_fatal() for assertion failures in tests This is a little more self-documenting - it justifies why it's acceptable to fail hard on out-of-memory conditions. _dbus_test_fatal() isn't compiled unless we are compiling embedded tests, so compiling with embedded tests disabled provides reasonable confidence that we aren't using _dbus_test_fatal() inappropriately. Signed-off-by: Simon McVittie --- bus/activation.c | 7 +- bus/config-parser-trivial.c | 18 +-- bus/config-parser.c | 70 ++++----- bus/dispatch.c | 148 +++++++++---------- bus/expirelist.c | 3 +- bus/signals.c | 25 ++-- dbus/dbus-address.c | 23 +-- dbus/dbus-auth-script.c | 6 +- dbus/dbus-auth-util.c | 16 +-- dbus/dbus-credentials-util.c | 17 +-- dbus/dbus-dataslot.c | 9 +- dbus/dbus-hash.c | 8 +- dbus/dbus-keyring.c | 4 +- dbus/dbus-list.c | 49 +++---- dbus/dbus-marshal-basic.c | 19 +-- dbus/dbus-marshal-byteswap-util.c | 6 +- dbus/dbus-marshal-recursive-util.c | 34 ++--- dbus/dbus-marshal-validate-util.c | 32 ++--- dbus/dbus-memory.c | 7 +- dbus/dbus-message-factory.c | 124 ++++++++-------- dbus/dbus-message-util.c | 141 +++++++++---------- dbus/dbus-misc.c | 5 +- dbus/dbus-object-tree.c | 3 +- dbus/dbus-sha.c | 44 +++--- dbus/dbus-signature.c | 3 +- dbus/dbus-string-util.c | 281 ++++++++++++++++++------------------- dbus/dbus-sysdeps-util.c | 5 +- dbus/dbus-userdb-util.c | 8 +- 28 files changed, 563 insertions(+), 552 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index 6f009f5c..2759f395 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef HAVE_ERRNO_H #include #endif @@ -2577,7 +2578,7 @@ do_test (const char *description, dbus_bool_t oom_test, CheckData *data) err = !check_func (data); if (err) - _dbus_assert_not_reached ("Test failed"); + _dbus_test_fatal ("Test failed"); return TRUE; } @@ -2698,7 +2699,7 @@ bus_activation_service_reload_test (const DBusString *test_data_dir) /* Do normal tests */ if (!init_service_reload_test (&directory)) - _dbus_assert_not_reached ("could not initiate service reload test"); + _dbus_test_fatal ("could not initiate service reload test"); if (!do_service_reload_test (test_data_dir, &directory, FALSE)) { @@ -2710,7 +2711,7 @@ bus_activation_service_reload_test (const DBusString *test_data_dir) /* Do OOM tests */ if (!init_service_reload_test (&directory)) - _dbus_assert_not_reached ("could not initiate service reload test"); + _dbus_test_fatal ("could not initiate service reload test"); if (!do_service_reload_test (test_data_dir, &directory, TRUE)) { diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c index bb163928..0351d20a 100644 --- a/bus/config-parser-trivial.c +++ b/bus/config-parser-trivial.c @@ -544,20 +544,20 @@ process_test_valid_subdir (const DBusString *test_base_dir, dir = NULL; if (!_dbus_string_init (&test_directory)) - _dbus_assert_not_reached ("didn't allocate test_directory"); + _dbus_test_fatal ("didn't allocate test_directory"); _dbus_string_init_const (&filename, subdir); if (!_dbus_string_copy (test_base_dir, 0, &test_directory, 0)) - _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory"); + _dbus_test_fatal ("couldn't copy test_base_dir to test_directory"); if (!_dbus_concat_dir_and_file (&test_directory, &filename)) - _dbus_assert_not_reached ("couldn't allocate full path"); + _dbus_test_fatal ("couldn't allocate full path"); _dbus_string_free (&filename); if (!_dbus_string_init (&filename)) - _dbus_assert_not_reached ("didn't allocate filename string"); + _dbus_test_fatal ("didn't allocate filename string"); dbus_error_init (&error); dir = _dbus_directory_open (&test_directory, &error); @@ -584,13 +584,13 @@ process_test_valid_subdir (const DBusString *test_base_dir, LoaderOomData d; if (!_dbus_string_init (&full_path)) - _dbus_assert_not_reached ("couldn't init string"); + _dbus_test_fatal ("couldn't init string"); if (!_dbus_string_copy (&test_directory, 0, &full_path, 0)) - _dbus_assert_not_reached ("couldn't copy dir to full_path"); + _dbus_test_fatal ("couldn't copy dir to full_path"); if (!_dbus_concat_dir_and_file (&full_path, &filename)) - _dbus_assert_not_reached ("couldn't concat file to dir"); + _dbus_test_fatal ("couldn't concat file to dir"); if (!_dbus_string_ends_with_c_str (&full_path, ".conf")) { @@ -616,8 +616,8 @@ process_test_valid_subdir (const DBusString *test_base_dir, */ /* if (!_dbus_test_oom_handling ("config-loader", check_loader_oom_func, &d)) */ if (!check_loader_oom_func (&d)) - _dbus_assert_not_reached ("test failed"); - + _dbus_test_fatal ("test failed"); + _dbus_string_free (&full_path); } diff --git a/bus/config-parser.c b/bus/config-parser.c index 254e3fa2..c99a7170 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -3077,9 +3077,9 @@ do_check_own_rules (BusPolicy *policy) dbus_bool_t ret; if (!_dbus_string_init (&service_name)) - _dbus_assert_not_reached ("couldn't init string"); + _dbus_test_fatal ("couldn't init string"); if (!_dbus_string_append (&service_name, checks[i].name)) - _dbus_assert_not_reached ("couldn't append string"); + _dbus_test_fatal ("couldn't append string"); ret = bus_policy_check_can_own (policy, &service_name); _dbus_test_diag (" Check name %s: %s", checks[i].name, @@ -3190,20 +3190,20 @@ process_test_valid_subdir (const DBusString *test_base_dir, dir = NULL; if (!_dbus_string_init (&test_directory)) - _dbus_assert_not_reached ("didn't allocate test_directory"); + _dbus_test_fatal ("didn't allocate test_directory"); _dbus_string_init_const (&filename, subdir); if (!_dbus_string_copy (test_base_dir, 0, &test_directory, 0)) - _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory"); + _dbus_test_fatal ("couldn't copy test_base_dir to test_directory"); if (!_dbus_concat_dir_and_file (&test_directory, &filename)) - _dbus_assert_not_reached ("couldn't allocate full path"); + _dbus_test_fatal ("couldn't allocate full path"); _dbus_string_free (&filename); if (!_dbus_string_init (&filename)) - _dbus_assert_not_reached ("didn't allocate filename string"); + _dbus_test_fatal ("didn't allocate filename string"); dbus_error_init (&error); dir = _dbus_directory_open (&test_directory, &error); @@ -3230,13 +3230,13 @@ process_test_valid_subdir (const DBusString *test_base_dir, LoaderOomData d; if (!_dbus_string_init (&full_path)) - _dbus_assert_not_reached ("couldn't init string"); + _dbus_test_fatal ("couldn't init string"); if (!_dbus_string_copy (&test_directory, 0, &full_path, 0)) - _dbus_assert_not_reached ("couldn't copy dir to full_path"); + _dbus_test_fatal ("couldn't copy dir to full_path"); if (!_dbus_concat_dir_and_file (&full_path, &filename)) - _dbus_assert_not_reached ("couldn't concat file to dir"); + _dbus_test_fatal ("couldn't concat file to dir"); if (!_dbus_string_ends_with_c_str (&full_path, ".conf")) { @@ -3264,8 +3264,8 @@ process_test_valid_subdir (const DBusString *test_base_dir, */ /* if (!_dbus_test_oom_handling ("config-loader", check_loader_oom_func, &d)) */ if (!check_loader_oom_func (&d)) - _dbus_assert_not_reached ("test failed"); - + _dbus_test_fatal ("test failed"); + _dbus_string_free (&full_path); } @@ -3525,7 +3525,7 @@ all_are_equiv (const DBusString *target_directory) retval = FALSE; if (!_dbus_string_init (&filename)) - _dbus_assert_not_reached ("didn't allocate filename string"); + _dbus_test_fatal ("didn't allocate filename string"); dbus_error_init (&error); dir = _dbus_directory_open (target_directory, &error); @@ -3546,13 +3546,13 @@ all_are_equiv (const DBusString *target_directory) DBusString full_path; if (!_dbus_string_init (&full_path)) - _dbus_assert_not_reached ("couldn't init string"); + _dbus_test_fatal ("couldn't init string"); if (!_dbus_string_copy (target_directory, 0, &full_path, 0)) - _dbus_assert_not_reached ("couldn't copy dir to full_path"); + _dbus_test_fatal ("couldn't copy dir to full_path"); if (!_dbus_concat_dir_and_file (&full_path, &filename)) - _dbus_assert_not_reached ("couldn't concat file to dir"); + _dbus_test_fatal ("couldn't concat file to dir"); if (!_dbus_string_ends_with_c_str (&full_path, ".conf")) { @@ -3618,20 +3618,20 @@ process_test_equiv_subdir (const DBusString *test_base_dir, retval = FALSE; if (!_dbus_string_init (&test_directory)) - _dbus_assert_not_reached ("didn't allocate test_directory"); + _dbus_test_fatal ("didn't allocate test_directory"); _dbus_string_init_const (&filename, subdir); if (!_dbus_string_copy (test_base_dir, 0, &test_directory, 0)) - _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory"); + _dbus_test_fatal ("couldn't copy test_base_dir to test_directory"); if (!_dbus_concat_dir_and_file (&test_directory, &filename)) - _dbus_assert_not_reached ("couldn't allocate full path"); + _dbus_test_fatal ("couldn't allocate full path"); _dbus_string_free (&filename); if (!_dbus_string_init (&filename)) - _dbus_assert_not_reached ("didn't allocate filename string"); + _dbus_test_fatal ("didn't allocate filename string"); dbus_error_init (&error); dir = _dbus_directory_open (&test_directory, &error); @@ -3653,14 +3653,14 @@ process_test_equiv_subdir (const DBusString *test_base_dir, continue; if (!_dbus_string_init (&full_path)) - _dbus_assert_not_reached ("couldn't init string"); + _dbus_test_fatal ("couldn't init string"); if (!_dbus_string_copy (&test_directory, 0, &full_path, 0)) - _dbus_assert_not_reached ("couldn't copy dir to full_path"); + _dbus_test_fatal ("couldn't copy dir to full_path"); if (!_dbus_concat_dir_and_file (&full_path, &filename)) - _dbus_assert_not_reached ("couldn't concat file to dir"); - + _dbus_test_fatal ("couldn't concat file to dir"); + equal = all_are_equiv (&full_path); _dbus_string_free (&full_path); @@ -3732,21 +3732,21 @@ test_default_session_servicedirs (const DBusString *test_base_dir) !_dbus_string_init (&data_home_based) || !_dbus_string_init (&data_dirs_based) || !_dbus_string_init (&data_dirs_based2)) - _dbus_assert_not_reached ("OOM allocating strings"); + _dbus_test_fatal ("OOM allocating strings"); if (!_dbus_string_copy (test_base_dir, 0, &full_path, 0)) - _dbus_assert_not_reached ("couldn't copy test_base_dir to full_path"); + _dbus_test_fatal ("couldn't copy test_base_dir to full_path"); _dbus_string_init_const (&tmp, "valid-config-files"); if (!_dbus_concat_dir_and_file (&full_path, &tmp)) - _dbus_assert_not_reached ("couldn't allocate full path"); + _dbus_test_fatal ("couldn't allocate full path"); _dbus_string_init_const (&tmp, "standard-session-dirs.conf"); if (!_dbus_concat_dir_and_file (&full_path, &tmp)) - _dbus_assert_not_reached ("couldn't allocate full path"); + _dbus_test_fatal ("couldn't allocate full path"); #ifdef DBUS_WIN if (!_dbus_string_append (&install_root_based, DBUS_DATADIR) || @@ -3793,21 +3793,21 @@ test_default_session_servicedirs (const DBusString *test_base_dir) !_dbus_string_append (&runtime_dir_based, xdg_runtime_dir) || !_dbus_string_append (&data_home_based, xdg_data_home) || !_dbus_string_append (&data_home_based, "/dbus-1/services")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); if (!_dbus_ensure_directory (&runtime_dir_based, NULL)) - _dbus_assert_not_reached ("Unable to create fake XDG_RUNTIME_DIR"); + _dbus_test_fatal ("Unable to create fake XDG_RUNTIME_DIR"); if (!_dbus_string_append (&runtime_dir_based, "/dbus-1/services")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); /* Sanity check: the Makefile sets this up. We assume that if this is * right, the XDG_DATA_DIRS will be too. */ if (!_dbus_string_starts_with_c_str (&data_home_based, dbus_test_builddir)) - _dbus_assert_not_reached ("$XDG_DATA_HOME should start with $DBUS_TEST_BUILDDIR"); + _dbus_test_fatal ("$XDG_DATA_HOME should start with $DBUS_TEST_BUILDDIR"); if (!_dbus_string_starts_with_c_str (&runtime_dir_based, dbus_test_builddir)) - _dbus_assert_not_reached ("$XDG_RUNTIME_DIR should start with $DBUS_TEST_BUILDDIR"); + _dbus_test_fatal ("$XDG_RUNTIME_DIR should start with $DBUS_TEST_BUILDDIR"); test_session_service_dir_matches[0] = _dbus_string_get_const_data ( &runtime_dir_based); @@ -3822,7 +3822,7 @@ test_default_session_servicedirs (const DBusString *test_base_dir) parser = bus_config_load (&full_path, TRUE, NULL, &error); if (parser == NULL) - _dbus_assert_not_reached (error.message); + _dbus_test_fatal ("%s", error.message); dirs = bus_config_parser_get_service_dirs (parser); @@ -3872,7 +3872,7 @@ test_default_session_servicedirs (const DBusString *test_base_dir) } if (!bus_config_parser_get_watched_dirs (parser, &watched_dirs)) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); #ifdef DBUS_WIN /* We expect all directories to be watched (not that it matters on Windows, @@ -3952,7 +3952,7 @@ test_default_system_servicedirs (void) dirs = NULL; if (!_dbus_get_standard_system_servicedirs (&dirs)) - _dbus_assert_not_reached ("couldn't get stardard dirs"); + _dbus_test_fatal ("couldn't get stardard dirs"); /* make sure we read and parse the env variable correctly */ i = 0; diff --git a/bus/dispatch.c b/bus/dispatch.c index 9a14849a..812c5796 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -824,7 +824,7 @@ kill_client_connection (BusContext *context, /* Run disconnect handler in test.c */ if (bus_connection_dispatch_one_message (connection)) - _dbus_assert_not_reached ("something received on connection being killed other than the disconnect"); + _dbus_test_fatal ("something received on connection being killed other than the disconnect"); _dbus_assert (!dbus_connection_get_is_connected (connection)); dbus_connection_unref (connection); @@ -843,10 +843,10 @@ kill_client_connection (BusContext *context, dbus_free (base_service); if (socd.failed) - _dbus_assert_not_reached ("didn't get the expected NameOwnerChanged (deletion) messages"); + _dbus_test_fatal ("didn't get the expected NameOwnerChanged (deletion) messages"); if (!check_no_leftovers (context)) - _dbus_assert_not_reached ("stuff left in message queues after disconnecting a client"); + _dbus_test_fatal ("stuff left in message queues after disconnecting a client"); } static void @@ -861,7 +861,7 @@ kill_client_connection_unchecked (DBusConnection *connection) dbus_connection_close (connection); /* dispatching disconnect handler will unref once */ if (bus_connection_dispatch_one_message (connection)) - _dbus_assert_not_reached ("message other than disconnect dispatched after failure to register"); + _dbus_test_fatal ("message other than disconnect dispatched after failure to register"); _dbus_assert (!bus_test_client_listed (connection)); dbus_connection_unref (connection); @@ -4399,7 +4399,7 @@ check1_try_iterations (BusContext *context, if (!_dbus_test_oom_handling (description, check_oom_check1_func, &d)) - _dbus_assert_not_reached ("test failed"); + _dbus_test_fatal ("test failed"); } static dbus_bool_t @@ -4834,7 +4834,7 @@ bus_dispatch_test_conf (const DBusString *test_data_dir, /* save the config name for the activation helper */ if (!setenv_TEST_LAUNCH_HELPER_CONFIG (test_data_dir, filename)) - _dbus_assert_not_reached ("no memory setting TEST_LAUNCH_HELPER_CONFIG"); + _dbus_test_fatal ("no memory setting TEST_LAUNCH_HELPER_CONFIG"); dbus_error_init (&error); @@ -4844,72 +4844,72 @@ bus_dispatch_test_conf (const DBusString *test_data_dir, foo = dbus_connection_open_private (TEST_DEBUG_PIPE, &error); if (foo == NULL) - _dbus_assert_not_reached ("could not alloc connection"); + _dbus_test_fatal ("could not alloc connection"); if (!bus_setup_debug_client (foo)) - _dbus_assert_not_reached ("could not set up connection"); + _dbus_test_fatal ("could not set up connection"); spin_connection_until_authenticated (context, foo); if (!check_hello_message (context, foo)) - _dbus_assert_not_reached ("hello message failed"); + _dbus_test_fatal ("hello message failed"); if (!check_double_hello_message (context, foo)) - _dbus_assert_not_reached ("double hello message failed"); + _dbus_test_fatal ("double hello message failed"); if (!check_add_match (context, foo, "")) - _dbus_assert_not_reached ("AddMatch message failed"); + _dbus_test_fatal ("AddMatch message failed"); bar = dbus_connection_open_private (TEST_DEBUG_PIPE, &error); if (bar == NULL) - _dbus_assert_not_reached ("could not alloc connection"); + _dbus_test_fatal ("could not alloc connection"); if (!bus_setup_debug_client (bar)) - _dbus_assert_not_reached ("could not set up connection"); + _dbus_test_fatal ("could not set up connection"); spin_connection_until_authenticated (context, bar); if (!check_hello_message (context, bar)) - _dbus_assert_not_reached ("hello message failed"); + _dbus_test_fatal ("hello message failed"); if (!check_add_match (context, bar, "")) - _dbus_assert_not_reached ("AddMatch message failed"); + _dbus_test_fatal ("AddMatch message failed"); baz = dbus_connection_open_private (TEST_DEBUG_PIPE, &error); if (baz == NULL) - _dbus_assert_not_reached ("could not alloc connection"); + _dbus_test_fatal ("could not alloc connection"); if (!bus_setup_debug_client (baz)) - _dbus_assert_not_reached ("could not set up connection"); + _dbus_test_fatal ("could not set up connection"); spin_connection_until_authenticated (context, baz); if (!check_hello_message (context, baz)) - _dbus_assert_not_reached ("hello message failed"); + _dbus_test_fatal ("hello message failed"); if (!check_add_match (context, baz, "")) - _dbus_assert_not_reached ("AddMatch message failed"); + _dbus_test_fatal ("AddMatch message failed"); if (!check_add_match (context, baz, "interface='com.example'")) - _dbus_assert_not_reached ("AddMatch message failed"); + _dbus_test_fatal ("AddMatch message failed"); #ifdef DBUS_ENABLE_STATS if (!check_get_all_match_rules (context, baz)) - _dbus_assert_not_reached ("GetAllMatchRules message failed"); + _dbus_test_fatal ("GetAllMatchRules message failed"); #endif if (!check_get_connection_unix_user (context, baz)) - _dbus_assert_not_reached ("GetConnectionUnixUser message failed"); + _dbus_test_fatal ("GetConnectionUnixUser message failed"); #ifdef DBUS_WIN_FIXME _dbus_verbose("TODO: testing of GetConnectionUnixProcessID message skipped for now\n"); #else if (!check_get_connection_unix_process_id (context, baz)) - _dbus_assert_not_reached ("GetConnectionUnixProcessID message failed"); + _dbus_test_fatal ("GetConnectionUnixProcessID message failed"); #endif if (!check_list_services (context, baz)) - _dbus_assert_not_reached ("ListActivatableNames message failed"); + _dbus_test_fatal ("ListActivatableNames message failed"); if (!check_no_leftovers (context)) _dbus_test_fatal ("Messages were left over after setting up initial connections"); @@ -4940,7 +4940,7 @@ bus_dispatch_test_conf (const DBusString *test_data_dir, /* specific to launcher */ if (use_launcher) if (!check_launch_service_file_missing (context, foo)) - _dbus_assert_not_reached ("did not get service file not found error"); + _dbus_test_fatal ("did not get service file not found error"); #if 0 /* Note: need to resolve some issues with the testing code in order to run @@ -4952,10 +4952,10 @@ bus_dispatch_test_conf (const DBusString *test_data_dir, #endif if (!check_existent_service_auto_start (context, foo)) - _dbus_assert_not_reached ("existent service auto start failed"); + _dbus_test_fatal ("existent service auto start failed"); if (!check_shell_service_success_auto_start (context, foo)) - _dbus_assert_not_reached ("shell success service auto start failed"); + _dbus_test_fatal ("shell success service auto start failed"); _dbus_verbose ("Disconnecting foo, bar, and baz\n"); @@ -4979,7 +4979,7 @@ bus_dispatch_test_conf_fail (const DBusString *test_data_dir, /* save the config name for the activation helper */ if (!setenv_TEST_LAUNCH_HELPER_CONFIG (test_data_dir, filename)) - _dbus_assert_not_reached ("no memory setting TEST_LAUNCH_HELPER_CONFIG"); + _dbus_test_fatal ("no memory setting TEST_LAUNCH_HELPER_CONFIG"); dbus_error_init (&error); @@ -4989,33 +4989,33 @@ bus_dispatch_test_conf_fail (const DBusString *test_data_dir, foo = dbus_connection_open_private (TEST_DEBUG_PIPE, &error); if (foo == NULL) - _dbus_assert_not_reached ("could not alloc connection"); + _dbus_test_fatal ("could not alloc connection"); if (!bus_setup_debug_client (foo)) - _dbus_assert_not_reached ("could not set up connection"); + _dbus_test_fatal ("could not set up connection"); spin_connection_until_authenticated (context, foo); if (!check_hello_message (context, foo)) - _dbus_assert_not_reached ("hello message failed"); + _dbus_test_fatal ("hello message failed"); if (!check_double_hello_message (context, foo)) - _dbus_assert_not_reached ("double hello message failed"); + _dbus_test_fatal ("double hello message failed"); if (!check_add_match (context, foo, "")) - _dbus_assert_not_reached ("AddMatch message failed"); + _dbus_test_fatal ("AddMatch message failed"); /* this only tests the activation.c user check */ if (!check_launch_service_user_missing (context, foo)) - _dbus_assert_not_reached ("user missing did not trigger error"); + _dbus_test_fatal ("user missing did not trigger error"); /* this only tests the desktop.c exec check */ if (!check_launch_service_exec_missing (context, foo)) - _dbus_assert_not_reached ("exec missing did not trigger error"); + _dbus_test_fatal ("exec missing did not trigger error"); /* this only tests the desktop.c service check */ if (!check_launch_service_service_missing (context, foo)) - _dbus_assert_not_reached ("service missing did not trigger error"); + _dbus_test_fatal ("service missing did not trigger error"); _dbus_verbose ("Disconnecting foo\n"); @@ -5071,18 +5071,18 @@ bus_dispatch_sha1_test (const DBusString *test_data_dir) foo = dbus_connection_open_private (TEST_DEBUG_PIPE, &error); if (foo == NULL) - _dbus_assert_not_reached ("could not alloc connection"); + _dbus_test_fatal ("could not alloc connection"); if (!bus_setup_debug_client (foo)) - _dbus_assert_not_reached ("could not set up connection"); + _dbus_test_fatal ("could not set up connection"); spin_connection_until_authenticated (context, foo); if (!check_hello_message (context, foo)) - _dbus_assert_not_reached ("hello message failed"); + _dbus_test_fatal ("hello message failed"); if (!check_add_match (context, foo, "")) - _dbus_assert_not_reached ("addmatch message failed"); + _dbus_test_fatal ("addmatch message failed"); if (!check_no_leftovers (context)) _dbus_test_fatal ("Messages were left over after setting up initial SHA-1 connection"); @@ -5114,67 +5114,67 @@ bus_unix_fds_passing_test(const DBusString *test_data_dir) context = bus_context_new_test (test_data_dir, "valid-config-files/debug-allow-all.conf"); if (context == NULL) - _dbus_assert_not_reached ("could not alloc context"); + _dbus_test_fatal ("could not alloc context"); foo = dbus_connection_open_private (TEST_DEBUG_PIPE, &error); if (foo == NULL) - _dbus_assert_not_reached ("could not alloc connection"); + _dbus_test_fatal ("could not alloc connection"); if (!bus_setup_debug_client (foo)) - _dbus_assert_not_reached ("could not set up connection"); + _dbus_test_fatal ("could not set up connection"); spin_connection_until_authenticated (context, foo); if (!check_hello_message (context, foo)) - _dbus_assert_not_reached ("hello message failed"); + _dbus_test_fatal ("hello message failed"); if (!check_add_match (context, foo, "")) - _dbus_assert_not_reached ("AddMatch message failed"); + _dbus_test_fatal ("AddMatch message failed"); bar = dbus_connection_open_private (TEST_DEBUG_PIPE, &error); if (bar == NULL) - _dbus_assert_not_reached ("could not alloc connection"); + _dbus_test_fatal ("could not alloc connection"); if (!bus_setup_debug_client (bar)) - _dbus_assert_not_reached ("could not set up connection"); + _dbus_test_fatal ("could not set up connection"); spin_connection_until_authenticated (context, bar); if (!check_hello_message (context, bar)) - _dbus_assert_not_reached ("hello message failed"); + _dbus_test_fatal ("hello message failed"); if (!check_add_match (context, bar, "")) - _dbus_assert_not_reached ("AddMatch message failed"); + _dbus_test_fatal ("AddMatch message failed"); if (!(m = dbus_message_new_signal("/", "a.b.c", "d"))) - _dbus_assert_not_reached ("could not alloc message"); + _dbus_test_fatal ("could not alloc message"); if (!(_dbus_socketpair (one, one+1, TRUE, &error))) - _dbus_assert_not_reached("Failed to allocate pipe #1"); + _dbus_test_fatal ("Failed to allocate pipe #1"); if (!(_dbus_socketpair (two, two+1, TRUE, &error))) - _dbus_assert_not_reached("Failed to allocate pipe #2"); + _dbus_test_fatal ("Failed to allocate pipe #2"); if (!dbus_message_append_args(m, DBUS_TYPE_UNIX_FD, one, DBUS_TYPE_UNIX_FD, two, DBUS_TYPE_UNIX_FD, two, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached("Failed to attach fds."); + _dbus_test_fatal ("Failed to attach fds."); if (!_dbus_close_socket (one[0], &error)) - _dbus_assert_not_reached("Failed to close pipe #1 "); + _dbus_test_fatal ("Failed to close pipe #1 "); if (!_dbus_close_socket (two[0], &error)) - _dbus_assert_not_reached("Failed to close pipe #2 "); + _dbus_test_fatal ("Failed to close pipe #2 "); if (!(dbus_connection_can_send_type(foo, DBUS_TYPE_UNIX_FD))) - _dbus_assert_not_reached("Connection cannot do fd passing"); + _dbus_test_fatal ("Connection cannot do fd passing"); if (!(dbus_connection_can_send_type(bar, DBUS_TYPE_UNIX_FD))) - _dbus_assert_not_reached("Connection cannot do fd passing"); + _dbus_test_fatal ("Connection cannot do fd passing"); if (!dbus_connection_send (foo, m, NULL)) - _dbus_assert_not_reached("Failed to send fds"); + _dbus_test_fatal ("Failed to send fds"); dbus_message_unref(m); @@ -5185,20 +5185,20 @@ bus_unix_fds_passing_test(const DBusString *test_data_dir) block_connection_until_message_from_bus (context, foo, "unix fd reception on foo"); if (!(m = pop_message_waiting_for_memory (foo))) - _dbus_assert_not_reached("Failed to receive msg"); + _dbus_test_fatal ("Failed to receive msg"); if (!dbus_message_is_signal(m, "a.b.c", "d")) - _dbus_assert_not_reached("bogus message received"); + _dbus_test_fatal ("bogus message received"); dbus_message_unref(m); block_connection_until_message_from_bus (context, bar, "unix fd reception on bar"); if (!(m = pop_message_waiting_for_memory (bar))) - _dbus_assert_not_reached("Failed to receive msg"); + _dbus_test_fatal ("Failed to receive msg"); if (!dbus_message_is_signal(m, "a.b.c", "d")) - _dbus_assert_not_reached("bogus message received"); + _dbus_test_fatal ("bogus message received"); if (!dbus_message_get_args(m, &error, @@ -5206,35 +5206,35 @@ bus_unix_fds_passing_test(const DBusString *test_data_dir) DBUS_TYPE_UNIX_FD, &y, DBUS_TYPE_UNIX_FD, &z, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached("Failed to parse fds."); + _dbus_test_fatal ("Failed to parse fds."); dbus_message_unref(m); if (write(x, "X", 1) != 1) - _dbus_assert_not_reached("Failed to write to pipe #1"); + _dbus_test_fatal ("Failed to write to pipe #1"); if (write(y, "Y", 1) != 1) - _dbus_assert_not_reached("Failed to write to pipe #2"); + _dbus_test_fatal ("Failed to write to pipe #2"); if (write(z, "Z", 1) != 1) - _dbus_assert_not_reached("Failed to write to pipe #2/2nd fd"); + _dbus_test_fatal ("Failed to write to pipe #2/2nd fd"); if (!_dbus_close(x, &error)) - _dbus_assert_not_reached("Failed to close pipe #1/other side "); + _dbus_test_fatal ("Failed to close pipe #1/other side "); if (!_dbus_close(y, &error)) - _dbus_assert_not_reached("Failed to close pipe #2/other side "); + _dbus_test_fatal ("Failed to close pipe #2/other side "); if (!_dbus_close(z, &error)) - _dbus_assert_not_reached("Failed to close pipe #2/other size 2nd fd "); + _dbus_test_fatal ("Failed to close pipe #2/other size 2nd fd "); if (read(one[1].fd, &r, 1) != 1 || r != 'X') - _dbus_assert_not_reached("Failed to read value from pipe."); + _dbus_test_fatal ("Failed to read value from pipe."); if (read(two[1].fd, &r, 1) != 1 || r != 'Y') - _dbus_assert_not_reached("Failed to read value from pipe."); + _dbus_test_fatal ("Failed to read value from pipe."); if (read(two[1].fd, &r, 1) != 1 || r != 'Z') - _dbus_assert_not_reached("Failed to read value from pipe."); + _dbus_test_fatal ("Failed to read value from pipe."); if (!_dbus_close_socket (one[1], &error)) - _dbus_assert_not_reached("Failed to close pipe #1 "); + _dbus_test_fatal ("Failed to close pipe #1 "); if (!_dbus_close_socket (two[1], &error)) - _dbus_assert_not_reached("Failed to close pipe #2 "); + _dbus_test_fatal ("Failed to close pipe #2 "); _dbus_verbose ("Disconnecting foo\n"); kill_client_connection_unchecked (foo); diff --git a/bus/expirelist.c b/bus/expirelist.c index 4a397527..e3bea5c0 100644 --- a/bus/expirelist.c +++ b/bus/expirelist.c @@ -26,6 +26,7 @@ #include "test.h" #include #include +#include #include struct BusExpireList @@ -362,7 +363,7 @@ bus_expire_list_test (const DBusString *test_data_dir) item->item.added_tv_sec = tv_sec; item->item.added_tv_usec = tv_usec; if (!bus_expire_list_add (list, &item->item)) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); next_interval = do_expiration_with_monotonic_time (list, tv_sec_not_expired, diff --git a/bus/signals.c b/bus/signals.c index 6b7a464c..b70dd353 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -29,6 +29,7 @@ #include "services.h" #include "utils.h" #include +#include struct BusMatchRule { @@ -2739,7 +2740,7 @@ test_matching (void) message1 = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL); _dbus_assert (message1 != NULL); if (!dbus_message_set_member (message1, "Frobated")) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); v_STRING = "foobar"; v_INT32 = 3; @@ -2747,8 +2748,8 @@ test_matching (void) DBUS_TYPE_STRING, &v_STRING, DBUS_TYPE_INT32, &v_INT32, NULL)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + check_matching (message1, 1, should_match_message_1, should_not_match_message_1); @@ -2758,14 +2759,14 @@ test_matching (void) message2 = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL); _dbus_assert (message2 != NULL); if (!dbus_message_set_member (message2, "NameOwnerChanged")) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); /* Obviously this isn't really a NameOwnerChanged signal. */ v_STRING = EXAMPLE_NAME; if (!dbus_message_append_args (message2, DBUS_TYPE_STRING, &v_STRING, NULL)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); check_matching (message2, 2, should_match_message_2, @@ -2814,12 +2815,12 @@ test_path_match (int type, _dbus_assert (message != NULL); if (!dbus_message_set_member (message, "Foo")) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); if (!dbus_message_append_args (message, type, &path, NULL)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); matched = match_rule_matches (rule, NULL, NULL, message, 0); @@ -2924,22 +2925,22 @@ test_matching_path_namespace (void) message1 = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL); _dbus_assert (message1 != NULL); if (!dbus_message_set_path (message1, "/foo/TheObjectManager")) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); message2 = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL); _dbus_assert (message2 != NULL); if (!dbus_message_set_path (message2, "/foo/TheObjectManager/child_object")) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); message3 = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL); _dbus_assert (message3 != NULL); if (!dbus_message_set_path (message3, "/foo/TheObjectManagerOther")) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); message4 = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL); _dbus_assert (message4 != NULL); if (!dbus_message_set_path (message4, "/")) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); check_matching (message1, 1, path_namespace_should_match_message_1, @@ -2971,7 +2972,7 @@ bus_signals_test (const DBusString *test_data_dir) bus_matchmaker_unref (matchmaker); if (!_dbus_test_oom_handling ("parsing match rules", test_parsing, NULL)) - _dbus_assert_not_reached ("Parsing match rules test failed"); + _dbus_test_fatal ("Parsing match rules test failed"); test_equality (); test_matching (); diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c index 66b26d58..02b35a0e 100644 --- a/dbus/dbus-address.c +++ b/dbus/dbus-address.c @@ -28,6 +28,7 @@ #include "dbus-list.h" #include "dbus-string.h" #include "dbus-protocol.h" +#include /** * @defgroup DBusAddressInternals Address parsing @@ -713,7 +714,7 @@ _dbus_address_test (void) escaped = dbus_address_escape_value (test->unescaped); if (escaped == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); if (strcmp (escaped, test->escaped) != 0) { @@ -766,7 +767,7 @@ _dbus_address_test (void) if (!dbus_parse_address ("unix:path=/tmp/foo;debug:name=test,sliff=sloff;", &entries, &len, &error)) - _dbus_assert_not_reached ("could not parse address"); + _dbus_test_fatal ("could not parse address"); _dbus_assert (len == 2); _dbus_assert (strcmp (dbus_address_entry_get_value (entries[0], "path"), "/tmp/foo") == 0); _dbus_assert (strcmp (dbus_address_entry_get_value (entries[1], "name"), "test") == 0); @@ -776,47 +777,47 @@ _dbus_address_test (void) /* Different possible errors */ if (dbus_parse_address ("", &entries, &len, &error)) - _dbus_assert_not_reached ("Parsed incorrect address."); + _dbus_test_fatal ("Parsed incorrect address."); else dbus_error_free (&error); if (dbus_parse_address ("foo", &entries, &len, &error)) - _dbus_assert_not_reached ("Parsed incorrect address."); + _dbus_test_fatal ("Parsed incorrect address."); else dbus_error_free (&error); if (dbus_parse_address ("foo:bar", &entries, &len, &error)) - _dbus_assert_not_reached ("Parsed incorrect address."); + _dbus_test_fatal ("Parsed incorrect address."); else dbus_error_free (&error); if (dbus_parse_address ("foo:bar,baz", &entries, &len, &error)) - _dbus_assert_not_reached ("Parsed incorrect address."); + _dbus_test_fatal ("Parsed incorrect address."); else dbus_error_free (&error); if (dbus_parse_address ("foo:bar=foo,baz", &entries, &len, &error)) - _dbus_assert_not_reached ("Parsed incorrect address."); + _dbus_test_fatal ("Parsed incorrect address."); else dbus_error_free (&error); if (dbus_parse_address ("foo:bar=foo;baz", &entries, &len, &error)) - _dbus_assert_not_reached ("Parsed incorrect address."); + _dbus_test_fatal ("Parsed incorrect address."); else dbus_error_free (&error); if (dbus_parse_address ("foo:=foo", &entries, &len, &error)) - _dbus_assert_not_reached ("Parsed incorrect address."); + _dbus_test_fatal ("Parsed incorrect address."); else dbus_error_free (&error); if (dbus_parse_address ("foo:foo=", &entries, &len, &error)) - _dbus_assert_not_reached ("Parsed incorrect address."); + _dbus_test_fatal ("Parsed incorrect address."); else dbus_error_free (&error); if (dbus_parse_address ("foo:foo,bar=baz", &entries, &len, &error)) - _dbus_assert_not_reached ("Parsed incorrect address."); + _dbus_test_fatal ("Parsed incorrect address."); else dbus_error_free (&error); diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index 708627bd..34c67f1d 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -226,17 +226,17 @@ auth_set_unix_credentials(DBusAuth *auth, credentials = _dbus_credentials_new (); if (credentials == NULL) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (uid != DBUS_UID_UNSET) { if (!_dbus_credentials_add_unix_uid (credentials, uid)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); } if (pid != DBUS_PID_UNSET) { if (!_dbus_credentials_add_pid (credentials, pid)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); } _dbus_auth_set_credentials (auth, credentials); diff --git a/dbus/dbus-auth-util.c b/dbus/dbus-auth-util.c index 2a172883..fe091cad 100644 --- a/dbus/dbus-auth-util.c +++ b/dbus/dbus-auth-util.c @@ -52,20 +52,20 @@ process_test_subdir (const DBusString *test_base_dir, dir = NULL; if (!_dbus_string_init (&test_directory)) - _dbus_assert_not_reached ("didn't allocate test_directory"); + _dbus_test_fatal ("didn't allocate test_directory"); _dbus_string_init_const (&filename, subdir); if (!_dbus_string_copy (test_base_dir, 0, &test_directory, 0)) - _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory"); - + _dbus_test_fatal ("couldn't copy test_base_dir to test_directory"); + if (!_dbus_concat_dir_and_file (&test_directory, &filename)) - _dbus_assert_not_reached ("couldn't allocate full path"); + _dbus_test_fatal ("couldn't allocate full path"); _dbus_string_free (&filename); if (!_dbus_string_init (&filename)) - _dbus_assert_not_reached ("didn't allocate filename string"); + _dbus_test_fatal ("didn't allocate filename string"); dir = _dbus_directory_open (&test_directory, &error); if (dir == NULL) @@ -85,13 +85,13 @@ process_test_subdir (const DBusString *test_base_dir, DBusString full_path; if (!_dbus_string_init (&full_path)) - _dbus_assert_not_reached ("couldn't init string"); + _dbus_test_fatal ("couldn't init string"); if (!_dbus_string_copy (&test_directory, 0, &full_path, 0)) - _dbus_assert_not_reached ("couldn't copy dir to full_path"); + _dbus_test_fatal ("couldn't copy dir to full_path"); if (!_dbus_concat_dir_and_file (&full_path, &filename)) - _dbus_assert_not_reached ("couldn't concat file to dir"); + _dbus_test_fatal ("couldn't concat file to dir"); if (!_dbus_string_ends_with_c_str (&filename, ".auth-script")) { diff --git a/dbus/dbus-credentials-util.c b/dbus/dbus-credentials-util.c index 94d72014..b40072df 100644 --- a/dbus/dbus-credentials-util.c +++ b/dbus/dbus-credentials-util.c @@ -25,6 +25,7 @@ #include "dbus-internals.h" #include "dbus-test.h" #include "dbus-credentials.h" +#include /** * @addtogroup DBusCredentials @@ -90,7 +91,7 @@ _dbus_credentials_test (const char *test_data_dir) creds = make_credentials (12, 511, SAMPLE_SID); if (creds == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); /* test refcounting */ _dbus_credentials_ref (creds); @@ -110,7 +111,7 @@ _dbus_credentials_test (const char *test_data_dir) /* Test copy */ creds2 = _dbus_credentials_copy (creds); if (creds2 == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_assert (_dbus_credentials_include (creds2, DBUS_CREDENTIAL_UNIX_USER_ID)); _dbus_assert (_dbus_credentials_include (creds2, DBUS_CREDENTIAL_UNIX_PROCESS_ID)); @@ -127,7 +128,7 @@ _dbus_credentials_test (const char *test_data_dir) /* Same user if both unix and windows are the same */ creds2 = make_credentials (12, DBUS_PID_UNSET, SAMPLE_SID); if (creds2 == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_assert (_dbus_credentials_same_user (creds, creds2)); @@ -136,7 +137,7 @@ _dbus_credentials_test (const char *test_data_dir) /* Not the same user if Windows is missing */ creds2 = make_credentials (12, DBUS_PID_UNSET, NULL); if (creds2 == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_assert (!_dbus_credentials_same_user (creds, creds2)); _dbus_assert (_dbus_credentials_are_superset (creds, creds2)); @@ -146,7 +147,7 @@ _dbus_credentials_test (const char *test_data_dir) /* Not the same user if Windows is different */ creds2 = make_credentials (12, DBUS_PID_UNSET, OTHER_SAMPLE_SID); if (creds2 == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_assert (!_dbus_credentials_same_user (creds, creds2)); _dbus_assert (!_dbus_credentials_are_superset (creds, creds2)); @@ -156,7 +157,7 @@ _dbus_credentials_test (const char *test_data_dir) /* Not the same user if Unix is missing */ creds2 = make_credentials (DBUS_UID_UNSET, DBUS_PID_UNSET, SAMPLE_SID); if (creds2 == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_assert (!_dbus_credentials_same_user (creds, creds2)); _dbus_assert (_dbus_credentials_are_superset (creds, creds2)); @@ -166,7 +167,7 @@ _dbus_credentials_test (const char *test_data_dir) /* Not the same user if Unix is different */ creds2 = make_credentials (15, DBUS_PID_UNSET, SAMPLE_SID); if (creds2 == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_assert (!_dbus_credentials_same_user (creds, creds2)); _dbus_assert (!_dbus_credentials_are_superset (creds, creds2)); @@ -176,7 +177,7 @@ _dbus_credentials_test (const char *test_data_dir) /* Not the same user if both are missing */ creds2 = make_credentials (DBUS_UID_UNSET, DBUS_PID_UNSET, NULL); if (creds2 == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_assert (!_dbus_credentials_same_user (creds, creds2)); _dbus_assert (_dbus_credentials_are_superset (creds, creds2)); diff --git a/dbus/dbus-dataslot.c b/dbus/dbus-dataslot.c index a4b3bfc0..429a840b 100644 --- a/dbus/dbus-dataslot.c +++ b/dbus/dbus-dataslot.c @@ -24,6 +24,7 @@ #include #include "dbus-dataslot.h" #include "dbus-threads-internal.h" +#include /** * @defgroup DBusDataSlot Data slots @@ -376,7 +377,7 @@ _dbus_data_slot_test (void) void *old_data; if (!_dbus_data_slot_allocator_init (&allocator, _DBUS_LOCK_server_slots)) - _dbus_assert_not_reached ("no memory for allocator"); + _dbus_test_fatal ("no memory for allocator"); _dbus_data_slot_list_init (&list); @@ -394,7 +395,7 @@ _dbus_data_slot_test (void) _dbus_data_slot_allocator_alloc (&allocator, &tmp); if (tmp != i) - _dbus_assert_not_reached ("did not allocate slots in numeric order"); + _dbus_test_fatal ("did not allocate slots in numeric order"); ++i; } @@ -407,7 +408,7 @@ _dbus_data_slot_test (void) _DBUS_INT_TO_POINTER (i), test_free_slot_data_func, &old_free_func, &old_data)) - _dbus_assert_not_reached ("no memory to set data"); + _dbus_test_fatal ("no memory to set data"); _dbus_assert (old_free_func == NULL); _dbus_assert (old_data == NULL); @@ -427,7 +428,7 @@ _dbus_data_slot_test (void) _DBUS_INT_TO_POINTER (i), test_free_slot_data_func, &old_free_func, &old_data)) - _dbus_assert_not_reached ("no memory to set data"); + _dbus_test_fatal ("no memory to set data"); _dbus_assert (old_free_func == test_free_slot_data_func); _dbus_assert (_DBUS_POINTER_TO_INT (old_data) == i); diff --git a/dbus/dbus-hash.c b/dbus/dbus-hash.c index d60f6cb0..1192c6c4 100644 --- a/dbus/dbus-hash.c +++ b/dbus/dbus-hash.c @@ -1599,14 +1599,14 @@ _dbus_hash_test (void) keys = dbus_new (char *, N_HASH_KEYS); if (keys == NULL) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); for (i = 0; i < N_HASH_KEYS; i++) { keys[i] = dbus_malloc (128); if (keys[i] == NULL) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); } _dbus_test_diag ("Computing test hash keys..."); @@ -1949,11 +1949,11 @@ _dbus_hash_test (void) while (i >= 0) { if (!_dbus_hash_iter_lookup (table1, keys[i], FALSE, &iter)) - _dbus_assert_not_reached ("hash entry should have existed"); + _dbus_test_fatal ("hash entry should have existed"); _dbus_hash_iter_remove_entry (&iter); if (!_dbus_hash_iter_lookup (table2, _DBUS_INT_TO_POINTER (i), FALSE, &iter)) - _dbus_assert_not_reached ("hash entry should have existed"); + _dbus_test_fatal ("hash entry should have existed"); _dbus_hash_iter_remove_entry (&iter); _dbus_assert (count_entries (table1) == i); diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 34b7311f..dbeb8791 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -1064,9 +1064,9 @@ _dbus_keyring_test (void) _dbus_assert (!_dbus_keyring_validate_context (&context)); if (!_dbus_string_init (&context)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_append_byte (&context, '\0')) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); _dbus_assert (!_dbus_keyring_validate_context (&context)); _dbus_string_free (&context); diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c index 8e713c00..aa556040 100644 --- a/dbus/dbus-list.c +++ b/dbus/dbus-list.c @@ -26,6 +26,7 @@ #include "dbus-list.h" #include "dbus-mempool.h" #include "dbus-threads-internal.h" +#include /** * @defgroup DBusList Linked list @@ -963,10 +964,10 @@ _dbus_list_test (void) while (i < 10) { if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for append"); - + _dbus_test_fatal ("could not allocate for append"); + if (!_dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("count not allocate for prepend"); + _dbus_test_fatal ("count not allocate for prepend"); ++i; verify_list (&list1); @@ -992,9 +993,9 @@ _dbus_list_test (void) while (i < 10) { if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); if (!_dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for prepend"); + _dbus_test_fatal ("could not allocate for prepend"); ++i; } @@ -1037,9 +1038,9 @@ _dbus_list_test (void) while (i < 10) { if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); if (!_dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for prepend"); + _dbus_test_fatal ("could not allocate for prepend"); ++i; } @@ -1089,9 +1090,9 @@ _dbus_list_test (void) while (i < 10) { if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); if (!_dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for prepend"); + _dbus_test_fatal ("could not allocate for prepend"); ++i; verify_list (&list1); @@ -1149,9 +1150,9 @@ _dbus_list_test (void) while (i < 10) { if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); if (!_dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for prepend"); + _dbus_test_fatal ("could not allocate for prepend"); ++i; } @@ -1161,9 +1162,9 @@ _dbus_list_test (void) if ((i % 2) == 0) { if (!_dbus_list_remove (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("element should have been in list"); + _dbus_test_fatal ("element should have been in list"); if (!_dbus_list_remove (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("element should have been in list"); + _dbus_test_fatal ("element should have been in list"); verify_list (&list1); verify_list (&list2); @@ -1183,9 +1184,9 @@ _dbus_list_test (void) while (i < 10) { if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); if (!_dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for prepend"); + _dbus_test_fatal ("could not allocate for prepend"); ++i; } @@ -1195,9 +1196,9 @@ _dbus_list_test (void) if ((i % 2) != 0) { if (!_dbus_list_remove (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("element should have been in list"); + _dbus_test_fatal ("element should have been in list"); if (!_dbus_list_remove (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("element should have been in list"); + _dbus_test_fatal ("element should have been in list"); verify_list (&list1); verify_list (&list2); @@ -1225,9 +1226,9 @@ _dbus_list_test (void) while (i < 10) { if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); if (!_dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for prepend"); + _dbus_test_fatal ("could not allocate for prepend"); ++i; } @@ -1276,9 +1277,9 @@ _dbus_list_test (void) while (i < 10) { if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); if (!_dbus_list_prepend (&list2, _DBUS_INT_TO_POINTER (i))) - _dbus_assert_not_reached ("could not allocate for prepend"); + _dbus_test_fatal ("could not allocate for prepend"); ++i; } @@ -1346,11 +1347,11 @@ _dbus_list_test (void) /* using remove_last */ if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (2))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (1))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); if (!_dbus_list_append (&list1, _DBUS_INT_TO_POINTER (3))) - _dbus_assert_not_reached ("could not allocate for append"); + _dbus_test_fatal ("could not allocate for append"); _dbus_list_remove_last (&list1, _DBUS_INT_TO_POINTER (2)); diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c index 4352e52a..93daa09e 100644 --- a/dbus/dbus-marshal-basic.c +++ b/dbus/dbus-marshal-basic.c @@ -26,6 +26,7 @@ #include "dbus-internals.h" #include "dbus-marshal-basic.h" #include "dbus-signature.h" +#include #include @@ -1512,7 +1513,7 @@ swap_test_array (void *array, if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_##typename, \ &v_##typename, \ byte_order, NULL)) \ - _dbus_assert_not_reached ("no memory"); \ + _dbus_test_fatal ("no memory"); \ } while (0) #define DEMARSHAL_BASIC(typename, byte_order) \ @@ -1528,7 +1529,7 @@ swap_test_array (void *array, { \ _dbus_verbose_bytes_of_string (&str, dump_pos, \ _dbus_string_get_length (&str) - dump_pos); \ - _dbus_assert_not_reached ("demarshaled wrong value"); \ + _dbus_test_fatal ("demarshaled wrong value"); \ } \ } while (0) @@ -1549,7 +1550,7 @@ swap_test_array (void *array, _dbus_verbose_bytes_of_string (&str, dump_pos, \ _dbus_string_get_length (&str) - dump_pos); \ _dbus_warn ("literal '%s'\nvalue '%s'", literal, v_##typename); \ - _dbus_assert_not_reached ("demarshaled wrong value"); \ + _dbus_test_fatal ("demarshaled wrong value"); \ } \ } while (0) @@ -1559,12 +1560,12 @@ swap_test_array (void *array, v_UINT32 = sizeof(literal); \ if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_UINT32, &v_UINT32, \ byte_order, &next)) \ - _dbus_assert_not_reached ("no memory"); \ + _dbus_test_fatal ("no memory"); \ v_ARRAY_##typename = literal; \ if (!_dbus_marshal_write_fixed_multi (&str, next, DBUS_TYPE_##typename, \ &v_ARRAY_##typename, _DBUS_N_ELEMENTS(literal), \ byte_order, NULL)) \ - _dbus_assert_not_reached ("no memory"); \ + _dbus_test_fatal ("no memory"); \ } while (0) #define DEMARSHAL_FIXED_ARRAY(typename, byte_order) \ @@ -1591,7 +1592,7 @@ swap_test_array (void *array, _dbus_verbose_bytes ((const unsigned char *) literal, sizeof (literal), 0); \ _dbus_verbose ("READ DATA\n"); \ _dbus_verbose_bytes ((const unsigned char *) v_ARRAY_##typename, sizeof (literal), 0); \ - _dbus_assert_not_reached ("demarshaled wrong fixed array value"); \ + _dbus_test_fatal ("demarshaled wrong fixed array value"); \ } \ } while (0) @@ -1639,7 +1640,7 @@ _dbus_marshal_test (void) int byte_order; if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); + _dbus_test_fatal ("failed to init string"); pos = 0; @@ -1648,13 +1649,13 @@ _dbus_marshal_test (void) DEMARSHAL_BASIC (DOUBLE, DBUS_BIG_ENDIAN); t_DOUBLE = 3.14; if (!_DBUS_DOUBLES_BITWISE_EQUAL (t_DOUBLE, v_DOUBLE)) - _dbus_assert_not_reached ("got wrong double value"); + _dbus_test_fatal ("got wrong double value"); MARSHAL_BASIC (DOUBLE, DBUS_LITTLE_ENDIAN, 3.14); DEMARSHAL_BASIC (DOUBLE, DBUS_LITTLE_ENDIAN); t_DOUBLE = 3.14; if (!_DBUS_DOUBLES_BITWISE_EQUAL (t_DOUBLE, v_DOUBLE)) - _dbus_assert_not_reached ("got wrong double value"); + _dbus_test_fatal ("got wrong double value"); /* Marshal signed 16 integers */ MARSHAL_TEST (INT16, DBUS_BIG_ENDIAN, -12345); diff --git a/dbus/dbus-marshal-byteswap-util.c b/dbus/dbus-marshal-byteswap-util.c index 85d46d1d..cdca3f44 100644 --- a/dbus/dbus-marshal-byteswap-util.c +++ b/dbus/dbus-marshal-byteswap-util.c @@ -38,7 +38,7 @@ do_byteswap_test (int byte_order) int opposite_order; if (!_dbus_string_init (&signature) || !_dbus_string_init (&body)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); opposite_order = byte_order == DBUS_LITTLE_ENDIAN ? DBUS_BIG_ENDIAN : DBUS_LITTLE_ENDIAN; @@ -52,10 +52,10 @@ do_byteswap_test (int byte_order) DBusTypeReader copy_reader; if (!_dbus_string_init (©)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); if (!_dbus_string_copy (&body, 0, ©, 0)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_marshal_byteswap (&signature, 0, byte_order, diff --git a/dbus/dbus-marshal-recursive-util.c b/dbus/dbus-marshal-recursive-util.c index 5ebd6363..a8584e2b 100644 --- a/dbus/dbus-marshal-recursive-util.c +++ b/dbus/dbus-marshal-recursive-util.c @@ -227,7 +227,7 @@ data_block_verify (DataBlock *block) _dbus_verbose_bytes_of_string (&block->signature, offset, _dbus_string_get_length (&block->signature) - offset); - _dbus_assert_not_reached ("block did not verify: bad bytes at end of signature"); + _dbus_test_fatal ("block did not verify: bad bytes at end of signature"); } if (!_dbus_string_ends_with_c_str (&block->body, FENCE_BYTES_STR)) @@ -241,7 +241,7 @@ data_block_verify (DataBlock *block) _dbus_verbose_bytes_of_string (&block->body, offset, _dbus_string_get_length (&block->body) - offset); - _dbus_assert_not_reached ("block did not verify: bad bytes at end of body"); + _dbus_test_fatal ("block did not verify: bad bytes at end of body"); } _dbus_assert (_dbus_string_validate_nul (&block->signature, @@ -1022,7 +1022,7 @@ node_append_child (TestTypeNode *node, _dbus_assert (node->klass->instance_size >= (int) sizeof (TestTypeNodeContainer)); if (!_dbus_list_append (&container->children, child)) - _dbus_assert_not_reached ("no memory"); /* we never check the return value on node_append_child anyhow - it's run from outside the malloc-failure test code */ + _dbus_test_fatal ("no memory"); /* we never check the return value on node_append_child anyhow - it's run from outside the malloc-failure test code */ return TRUE; } @@ -1114,7 +1114,7 @@ run_test_copy (NodeIterationData *nid) _dbus_verbose ("DEST\n"); _dbus_verbose_bytes_of_string (&dest.signature, 0, _dbus_string_get_length (&dest.signature)); - _dbus_assert_not_reached ("signatures did not match"); + _dbus_test_fatal ("signatures did not match"); } if (!_dbus_string_equal (&src->body, &dest.body)) @@ -1125,7 +1125,7 @@ run_test_copy (NodeIterationData *nid) _dbus_verbose ("DEST\n"); _dbus_verbose_bytes_of_string (&dest.body, 0, _dbus_string_get_length (&dest.body)); - _dbus_assert_not_reached ("bodies did not match"); + _dbus_test_fatal ("bodies did not match"); } retval = TRUE; @@ -1320,7 +1320,7 @@ run_test_delete_values (NodeIterationData *nid) while (elem > 0) { if (!_dbus_type_reader_next (&array)) - _dbus_assert_not_reached ("should have had another element"); + _dbus_test_fatal ("should have had another element"); --elem; } @@ -1461,7 +1461,7 @@ run_test_nodes_in_one_configuration (TestTypeNode **nodes, NodeIterationData nid; if (!data_block_init (&block, byte_order, initial_offset)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); nid.signature = signature; nid.block = █ @@ -1479,7 +1479,7 @@ run_test_nodes_in_one_configuration (TestTypeNode **nodes, else { if (!run_test_nodes_iteration (&nid)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); } data_block_free (&block); @@ -1493,13 +1493,13 @@ run_test_nodes (TestTypeNode **nodes, DBusString signature; if (!_dbus_string_init (&signature)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); i = 0; while (i < n_nodes) { if (! node_build_signature (nodes[i], &signature)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); ++i; } @@ -1600,14 +1600,14 @@ build_body (TestTypeNode **nodes, while (i < n_nodes) { if (! node_build_signature (nodes[i], signature)) - _dbus_assert_not_reached ("no memory"); - + _dbus_test_fatal ("no memory"); + ++i; } if (!data_block_init (&block, byte_order, 0)) - _dbus_assert_not_reached ("no memory"); - + _dbus_test_fatal ("no memory"); + data_block_init_reader_writer (&block, &reader, &writer); @@ -1616,13 +1616,13 @@ build_body (TestTypeNode **nodes, */ if (!_dbus_string_insert_byte (&block.signature, 0, '\0')) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); i = 0; while (i < n_nodes) { if (!node_write_value (nodes[i], &block, &writer, i)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); ++i; } @@ -1630,7 +1630,7 @@ build_body (TestTypeNode **nodes, if (!_dbus_string_copy_len (&block.body, 0, _dbus_string_get_length (&block.body) - N_FENCE_BYTES, body, 0)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); data_block_free (&block); } diff --git a/dbus/dbus-marshal-validate-util.c b/dbus/dbus-marshal-validate-util.c index 86b08a1a..dc074b2d 100644 --- a/dbus/dbus-marshal-validate-util.c +++ b/dbus/dbus-marshal-validate-util.c @@ -386,49 +386,49 @@ _dbus_marshal_validate_test (void) /* Validate claimed length longer than real length */ _dbus_string_init_const (&str, "abc.efg"); if (_dbus_validate_bus_name (&str, 0, 8)) - _dbus_assert_not_reached ("validated too-long string"); + _dbus_test_fatal ("validated too-long string"); if (_dbus_validate_interface (&str, 0, 8)) - _dbus_assert_not_reached ("validated too-long string"); + _dbus_test_fatal ("validated too-long string"); if (_dbus_validate_error_name (&str, 0, 8)) - _dbus_assert_not_reached ("validated too-long string"); + _dbus_test_fatal ("validated too-long string"); _dbus_string_init_const (&str, "abc"); if (_dbus_validate_member (&str, 0, 4)) - _dbus_assert_not_reached ("validated too-long string"); + _dbus_test_fatal ("validated too-long string"); /* Validate string exceeding max name length */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); while (_dbus_string_get_length (&str) <= DBUS_MAXIMUM_NAME_LENGTH) if (!_dbus_string_append (&str, "abc.def")) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (_dbus_validate_bus_name (&str, 0, _dbus_string_get_length (&str))) - _dbus_assert_not_reached ("validated overmax string"); + _dbus_test_fatal ("validated overmax string"); if (_dbus_validate_interface (&str, 0, _dbus_string_get_length (&str))) - _dbus_assert_not_reached ("validated overmax string"); + _dbus_test_fatal ("validated overmax string"); if (_dbus_validate_error_name (&str, 0, _dbus_string_get_length (&str))) - _dbus_assert_not_reached ("validated overmax string"); + _dbus_test_fatal ("validated overmax string"); /* overlong member */ _dbus_string_set_length (&str, 0); while (_dbus_string_get_length (&str) <= DBUS_MAXIMUM_NAME_LENGTH) if (!_dbus_string_append (&str, "abc")) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (_dbus_validate_member (&str, 0, _dbus_string_get_length (&str))) - _dbus_assert_not_reached ("validated overmax string"); + _dbus_test_fatal ("validated overmax string"); /* overlong unique name */ _dbus_string_set_length (&str, 0); _dbus_string_append (&str, ":"); while (_dbus_string_get_length (&str) <= DBUS_MAXIMUM_NAME_LENGTH) if (!_dbus_string_append (&str, "abc")) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (_dbus_validate_bus_name (&str, 0, _dbus_string_get_length (&str))) - _dbus_assert_not_reached ("validated overmax string"); + _dbus_test_fatal ("validated overmax string"); _dbus_string_free (&str); @@ -440,7 +440,7 @@ _dbus_marshal_validate_test (void) DBusString body; if (!_dbus_string_init (&signature) || !_dbus_string_init (&body)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); sequence = 0; while (dbus_internal_do_not_use_generate_bodies (sequence, @@ -459,7 +459,7 @@ _dbus_marshal_validate_test (void) validity, sequence); _dbus_verbose_bytes_of_string (&signature, 0, _dbus_string_get_length (&signature)); _dbus_verbose_bytes_of_string (&body, 0, _dbus_string_get_length (&body)); - _dbus_assert_not_reached ("test failed"); + _dbus_test_fatal ("test failed"); } _dbus_string_set_length (&signature, 0); @@ -484,7 +484,7 @@ _dbus_marshal_validate_test (void) validity, sequence); _dbus_verbose_bytes_of_string (&signature, 0, _dbus_string_get_length (&signature)); _dbus_verbose_bytes_of_string (&body, 0, _dbus_string_get_length (&body)); - _dbus_assert_not_reached ("test failed"); + _dbus_test_fatal ("test failed"); } _dbus_string_set_length (&signature, 0); diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c index a9c2f7a4..c4cbd315 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -27,6 +27,7 @@ #include "dbus-sysdeps.h" #include "dbus-list.h" #include "dbus-threads.h" +#include #include /** @@ -939,18 +940,18 @@ _dbus_memory_test (void) guards = TRUE; p = dbus_malloc (4); if (p == NULL) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); for (size = 4; size < 256; size += 4) { p = dbus_realloc (p, size); if (p == NULL) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); } for (size = 256; size != 0; size -= 4) { p = dbus_realloc (p, size); if (p == NULL) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); } dbus_free (p); guards = old_guards; diff --git a/dbus/dbus-message-factory.c b/dbus/dbus-message-factory.c index 2c4cd496..f358eb11 100644 --- a/dbus/dbus-message-factory.c +++ b/dbus/dbus-message-factory.c @@ -104,9 +104,9 @@ static void set_reply_serial (DBusMessage *message) { if (message == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); if (!dbus_message_set_reply_serial (message, 100)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); } static dbus_bool_t @@ -137,8 +137,8 @@ generate_trivial_inner (DBusMessageDataIter *iter, if (!dbus_message_set_error_name (message, "org.freedesktop.TestErrorName")) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + { DBusMessageIter iter2; const char *v_STRING = "This is an error"; @@ -147,7 +147,7 @@ generate_trivial_inner (DBusMessageDataIter *iter, if (!dbus_message_iter_append_basic (&iter2, DBUS_TYPE_STRING, &v_STRING)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); } set_reply_serial (message); @@ -157,7 +157,7 @@ generate_trivial_inner (DBusMessageDataIter *iter, } if (message == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); *message_p = message; @@ -179,15 +179,15 @@ generate_many_bodies_inner (DBusMessageDataIter *iter, "o.z.B", "Nah"); if (message == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); byte_order = _dbus_header_get_byte_order (&message->header); set_reply_serial (message); if (!_dbus_string_init (&signature) || !_dbus_string_init (&body)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + if (dbus_internal_do_not_use_generate_bodies (iter_get_sequence (iter), byte_order, &signature, &body)) @@ -199,10 +199,10 @@ generate_many_bodies_inner (DBusMessageDataIter *iter, DBUS_HEADER_FIELD_SIGNATURE, DBUS_TYPE_SIGNATURE, &v_SIGNATURE)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); if (!_dbus_string_move (&body, 0, &message->body, 0)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_marshal_set_uint32 (&message->header.data, BODY_LENGTH_OFFSET, _dbus_string_get_length (&message->body), @@ -235,11 +235,11 @@ generate_from_message (DBusString *data, /* move for efficiency, since we'll nuke the message anyway */ if (!_dbus_string_move (&message->header.data, 0, data, 0)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); if (!_dbus_string_copy (&message->body, 0, data, _dbus_string_get_length (data))) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); } static dbus_bool_t @@ -293,7 +293,7 @@ simple_method_call (void) "o.b.Z", "Fro"); if (message == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); return message; } @@ -305,7 +305,7 @@ simple_signal (void) "o.b.Z", "Fro"); if (message == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); return message; } @@ -315,7 +315,7 @@ simple_method_return (void) DBusMessage *message; message = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); if (message == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); set_reply_serial (message); @@ -328,11 +328,11 @@ simple_error (void) DBusMessage *message; message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); if (message == NULL) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); if (!dbus_message_set_error_name (message, "foo.bar")) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + set_reply_serial (message); return message; @@ -368,19 +368,19 @@ message_with_nesting_levels (int levels) DBUS_TYPE_INT32_AS_STRING : DBUS_TYPE_VARIANT_AS_STRING, &children[i])) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); ++i; parents[i] = children[i-1]; } --i; if (!dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); while (i >= 0) { if (!dbus_message_iter_close_container (&parents[i], &children[i])) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); --i; } @@ -415,8 +415,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -439,7 +439,7 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); i = 0; while (i < (DBUS_MAXIMUM_TYPE_RECURSION_DEPTH + 1)) @@ -454,8 +454,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_HEADER_FIELD_SIGNATURE, DBUS_TYPE_SIGNATURE, &v_STRING)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -475,7 +475,7 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); i = 0; while (i <= (DBUS_MAXIMUM_TYPE_RECURSION_DEPTH + 1)) @@ -499,8 +499,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_HEADER_FIELD_SIGNATURE, DBUS_TYPE_SIGNATURE, &v_STRING)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -516,8 +516,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -535,8 +535,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -554,8 +554,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -609,8 +609,8 @@ generate_special (DBusMessageDataIter *iter, if (!_dbus_header_set_field_basic (&message->header, DBUS_HEADER_FIELD_SENDER, DBUS_TYPE_STRING, &v_STRING)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + generate_from_message (data, expected_validity, message); *expected_validity = DBUS_INVALID_BAD_SENDER; @@ -620,8 +620,8 @@ generate_special (DBusMessageDataIter *iter, message = simple_method_call (); if (!dbus_message_set_interface (message, DBUS_INTERFACE_LOCAL)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + generate_from_message (data, expected_validity, message); *expected_validity = DBUS_INVALID_USES_LOCAL_INTERFACE; @@ -631,8 +631,8 @@ generate_special (DBusMessageDataIter *iter, message = simple_method_call (); if (!dbus_message_set_path (message, DBUS_PATH_LOCAL)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + generate_from_message (data, expected_validity, message); *expected_validity = DBUS_INVALID_USES_LOCAL_PATH; @@ -643,8 +643,8 @@ generate_special (DBusMessageDataIter *iter, message = simple_method_call (); if (!dbus_message_set_interface (message, NULL)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + generate_from_message (data, expected_validity, message); *expected_validity = DBUS_VALID; @@ -655,8 +655,8 @@ generate_special (DBusMessageDataIter *iter, message = simple_signal (); if (!dbus_message_set_interface (message, NULL)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + generate_from_message (data, expected_validity, message); *expected_validity = DBUS_INVALID_MISSING_INTERFACE; @@ -666,8 +666,8 @@ generate_special (DBusMessageDataIter *iter, message = simple_method_return (); if (!_dbus_header_delete_field (&message->header, DBUS_HEADER_FIELD_REPLY_SERIAL)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + generate_from_message (data, expected_validity, message); *expected_validity = DBUS_INVALID_MISSING_REPLY_SERIAL; @@ -677,8 +677,8 @@ generate_special (DBusMessageDataIter *iter, message = simple_error (); if (!dbus_message_set_error_name (message, NULL)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + generate_from_message (data, expected_validity, message); *expected_validity = DBUS_INVALID_MISSING_ERROR_NAME; @@ -696,7 +696,7 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); i = 0; while (i <= (DBUS_MAXIMUM_TYPE_RECURSION_DEPTH*3 + 3)) @@ -726,8 +726,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_HEADER_FIELD_SIGNATURE, DBUS_TYPE_SIGNATURE, &v_STRING)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -743,8 +743,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -763,8 +763,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -782,8 +782,8 @@ generate_special (DBusMessageDataIter *iter, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_INVALID)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + _dbus_header_get_field_raw (&message->header, DBUS_HEADER_FIELD_SIGNATURE, NULL, &pos); @@ -865,7 +865,7 @@ generate_wrong_length (DBusMessageDataIter *iter, else { if (!_dbus_string_lengthen (data, adjust)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); *expected_validity = DBUS_INVALID_TOO_MUCH_DATA; } @@ -1286,8 +1286,8 @@ _dbus_message_data_iter_get_and_next (DBusMessageDataIter *iter, func = generators[generator].func; if (!_dbus_string_init (&data->data)) - _dbus_assert_not_reached ("oom"); - + _dbus_test_fatal ("oom"); + if ((*func)(iter, &data->data, &data->expected_validity)) ; else diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index 629eb504..96c726f3 100644 --- a/dbus/dbus-message-util.c +++ b/dbus/dbus-message-util.c @@ -389,7 +389,7 @@ check_loader_results (DBusMessageLoader *loader, DBusValidity expected_validity) { if (!_dbus_message_loader_queue_messages (loader)) - _dbus_assert_not_reached ("no memory to queue messages"); + _dbus_test_fatal ("no memory to queue messages"); if (expected_validity == DBUS_VALID) return check_have_valid_message (loader); @@ -461,7 +461,7 @@ dbus_internal_do_not_use_try_message_file (const DBusString *filename, retval = FALSE; if (!_dbus_string_init (&data)) - _dbus_assert_not_reached ("could not allocate string"); + _dbus_test_fatal ("could not allocate string"); if (!dbus_internal_do_not_use_load_message_file (filename, &data)) goto failed; @@ -614,20 +614,20 @@ process_test_subdir (const DBusString *test_base_dir, dir = NULL; if (!_dbus_string_init (&test_directory)) - _dbus_assert_not_reached ("didn't allocate test_directory"); + _dbus_test_fatal ("didn't allocate test_directory"); _dbus_string_init_const (&filename, subdir); if (!_dbus_string_copy (test_base_dir, 0, &test_directory, 0)) - _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory"); + _dbus_test_fatal ("couldn't copy test_base_dir to test_directory"); if (!_dbus_concat_dir_and_file (&test_directory, &filename)) - _dbus_assert_not_reached ("couldn't allocate full path"); + _dbus_test_fatal ("couldn't allocate full path"); _dbus_string_free (&filename); if (!_dbus_string_init (&filename)) - _dbus_assert_not_reached ("didn't allocate filename string"); + _dbus_test_fatal ("didn't allocate filename string"); dir = _dbus_directory_open (&test_directory, &error); if (dir == NULL) @@ -647,13 +647,13 @@ process_test_subdir (const DBusString *test_base_dir, DBusString full_path; if (!_dbus_string_init (&full_path)) - _dbus_assert_not_reached ("couldn't init string"); + _dbus_test_fatal ("couldn't init string"); if (!_dbus_string_copy (&test_directory, 0, &full_path, 0)) - _dbus_assert_not_reached ("couldn't copy dir to full_path"); + _dbus_test_fatal ("couldn't copy dir to full_path"); if (!_dbus_concat_dir_and_file (&full_path, &filename)) - _dbus_assert_not_reached ("couldn't concat file to dir"); + _dbus_test_fatal ("couldn't concat file to dir"); if (_dbus_string_ends_with_c_str (&filename, ".message-raw")) ; @@ -757,33 +757,33 @@ dbus_internal_do_not_use_foreach_message_file (const char *test_d #define GET_AND_CHECK(iter, typename, literal) \ do { \ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_##typename) \ - _dbus_assert_not_reached ("got wrong argument type from message iter"); \ + _dbus_test_fatal ("got wrong argument type from message iter"); \ dbus_message_iter_get_basic (&iter, &v_##typename); \ if (v_##typename != literal) \ - _dbus_assert_not_reached ("got wrong value from message iter"); \ + _dbus_test_fatal ("got wrong value from message iter"); \ } while (0) #define GET_AND_CHECK_STRCMP(iter, typename, literal) \ do { \ if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_##typename) \ - _dbus_assert_not_reached ("got wrong argument type from message iter"); \ + _dbus_test_fatal ("got wrong argument type from message iter"); \ dbus_message_iter_get_basic (&iter, &v_##typename); \ if (strcmp (v_##typename, literal) != 0) \ - _dbus_assert_not_reached ("got wrong value from message iter"); \ + _dbus_test_fatal ("got wrong value from message iter"); \ } while (0) #define GET_AND_CHECK_AND_NEXT(iter, typename, literal) \ do { \ GET_AND_CHECK(iter, typename, literal); \ if (!dbus_message_iter_next (&iter)) \ - _dbus_assert_not_reached ("failed to move iter to next"); \ + _dbus_test_fatal ("failed to move iter to next"); \ } while (0) #define GET_AND_CHECK_STRCMP_AND_NEXT(iter, typename, literal) \ do { \ GET_AND_CHECK_STRCMP(iter, typename, literal); \ if (!dbus_message_iter_next (&iter)) \ - _dbus_assert_not_reached ("failed to move iter to next"); \ + _dbus_test_fatal ("failed to move iter to next"); \ } while (0) static void @@ -812,10 +812,10 @@ message_iter_test (DBusMessage *message) GET_AND_CHECK_AND_NEXT (iter, DOUBLE, 3.14159); if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY) - _dbus_assert_not_reached ("Argument type not an array"); + _dbus_test_fatal ("Argument type not an array"); if (dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_DOUBLE) - _dbus_assert_not_reached ("Array type not double"); + _dbus_test_fatal ("Array type not double"); dbus_message_iter_recurse (&iter, &array); @@ -823,32 +823,32 @@ message_iter_test (DBusMessage *message) GET_AND_CHECK (array, DOUBLE, 2.5); if (dbus_message_iter_next (&array)) - _dbus_assert_not_reached ("Didn't reach end of array"); + _dbus_test_fatal ("Didn't reach end of array"); if (!dbus_message_iter_next (&iter)) - _dbus_assert_not_reached ("Reached end of arguments"); + _dbus_test_fatal ("Reached end of arguments"); GET_AND_CHECK_AND_NEXT (iter, BYTE, 0xF0); if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY) - _dbus_assert_not_reached ("no array"); + _dbus_test_fatal ("no array"); if (dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_INT32) - _dbus_assert_not_reached ("Array type not int32"); + _dbus_test_fatal ("Array type not int32"); /* Empty array */ dbus_message_iter_recurse (&iter, &array); if (dbus_message_iter_next (&array)) - _dbus_assert_not_reached ("Didn't reach end of array"); + _dbus_test_fatal ("Didn't reach end of array"); if (!dbus_message_iter_next (&iter)) - _dbus_assert_not_reached ("Reached end of arguments"); + _dbus_test_fatal ("Reached end of arguments"); GET_AND_CHECK (iter, BYTE, 0xF0); if (dbus_message_iter_next (&iter)) - _dbus_assert_not_reached ("Didn't reach end of arguments"); + _dbus_test_fatal ("Didn't reach end of arguments"); } #endif @@ -917,120 +917,119 @@ verify_test_message (DBusMessage *message) &our_string_array, &our_string_array_len, 0)) { - _dbus_warn ("error: %s - %s", error.name, + _dbus_test_fatal ("Could not get arguments: %s - %s", error.name, (error.message != NULL) ? error.message : "no message"); - _dbus_assert_not_reached ("Could not get arguments"); } if (our_int16 != -0x123) - _dbus_assert_not_reached ("16-bit integers differ!"); + _dbus_test_fatal ("16-bit integers differ!"); if (our_uint16 != 0x123) - _dbus_assert_not_reached ("16-bit uints differ!"); + _dbus_test_fatal ("16-bit uints differ!"); if (our_int != -0x12345678) - _dbus_assert_not_reached ("integers differ!"); + _dbus_test_fatal ("integers differ!"); if (our_uint != 0x12300042) - _dbus_assert_not_reached ("uints differ!"); + _dbus_test_fatal ("uints differ!"); if (our_int64 != DBUS_INT64_CONSTANT (-0x123456789abcd)) - _dbus_assert_not_reached ("64-bit integers differ!"); + _dbus_test_fatal ("64-bit integers differ!"); if (our_uint64 != DBUS_UINT64_CONSTANT (0x123456789abcd)) - _dbus_assert_not_reached ("64-bit unsigned integers differ!"); + _dbus_test_fatal ("64-bit unsigned integers differ!"); v_DOUBLE = 3.14159; if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double, v_DOUBLE)) - _dbus_assert_not_reached ("doubles differ!"); + _dbus_test_fatal ("doubles differ!"); if (strcmp (our_str, "Test string") != 0) - _dbus_assert_not_reached ("strings differ!"); + _dbus_test_fatal ("strings differ!"); if (!our_bool) - _dbus_assert_not_reached ("booleans differ"); + _dbus_test_fatal ("booleans differ"); if (our_byte_1 != 42) - _dbus_assert_not_reached ("bytes differ!"); + _dbus_test_fatal ("bytes differ!"); if (our_byte_2 != 24) - _dbus_assert_not_reached ("bytes differ!"); + _dbus_test_fatal ("bytes differ!"); if (our_uint32_array_len != 4 || our_uint32_array[0] != 0x12345678 || our_uint32_array[1] != 0x23456781 || our_uint32_array[2] != 0x34567812 || our_uint32_array[3] != 0x45678123) - _dbus_assert_not_reached ("uint array differs"); + _dbus_test_fatal ("uint array differs"); if (our_int32_array_len != 4 || our_int32_array[0] != 0x12345678 || our_int32_array[1] != -0x23456781 || our_int32_array[2] != 0x34567812 || our_int32_array[3] != -0x45678123) - _dbus_assert_not_reached ("int array differs"); + _dbus_test_fatal ("int array differs"); if (our_uint64_array_len != 4 || our_uint64_array[0] != 0x12345678 || our_uint64_array[1] != 0x23456781 || our_uint64_array[2] != 0x34567812 || our_uint64_array[3] != 0x45678123) - _dbus_assert_not_reached ("uint64 array differs"); + _dbus_test_fatal ("uint64 array differs"); if (our_int64_array_len != 4 || our_int64_array[0] != 0x12345678 || our_int64_array[1] != -0x23456781 || our_int64_array[2] != 0x34567812 || our_int64_array[3] != -0x45678123) - _dbus_assert_not_reached ("int64 array differs"); + _dbus_test_fatal ("int64 array differs"); if (our_double_array_len != 3) - _dbus_assert_not_reached ("double array had wrong length"); + _dbus_test_fatal ("double array had wrong length"); /* On all IEEE machines (i.e. everything sane) exact equality * should be preserved over the wire */ v_DOUBLE = 0.1234; if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double_array[0], v_DOUBLE)) - _dbus_assert_not_reached ("double array had wrong values"); + _dbus_test_fatal ("double array had wrong values"); v_DOUBLE = 9876.54321; if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double_array[1], v_DOUBLE)) - _dbus_assert_not_reached ("double array had wrong values"); + _dbus_test_fatal ("double array had wrong values"); v_DOUBLE = -300.0; if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double_array[2], v_DOUBLE)) - _dbus_assert_not_reached ("double array had wrong values"); + _dbus_test_fatal ("double array had wrong values"); if (our_byte_array_len != 4) - _dbus_assert_not_reached ("byte array had wrong length"); + _dbus_test_fatal ("byte array had wrong length"); if (our_byte_array[0] != 'a' || our_byte_array[1] != 'b' || our_byte_array[2] != 'c' || our_byte_array[3] != 234) - _dbus_assert_not_reached ("byte array had wrong values"); + _dbus_test_fatal ("byte array had wrong values"); if (our_boolean_array_len != 5) - _dbus_assert_not_reached ("bool array had wrong length"); + _dbus_test_fatal ("bool array had wrong length"); if (our_boolean_array[0] != TRUE || our_boolean_array[1] != FALSE || our_boolean_array[2] != TRUE || our_boolean_array[3] != TRUE || our_boolean_array[4] != FALSE) - _dbus_assert_not_reached ("bool array had wrong values"); + _dbus_test_fatal ("bool array had wrong values"); if (our_string_array_len != 4) - _dbus_assert_not_reached ("string array was wrong length"); + _dbus_test_fatal ("string array was wrong length"); if (strcmp (our_string_array[0], "Foo") != 0 || strcmp (our_string_array[1], "bar") != 0 || strcmp (our_string_array[2], "") != 0 || strcmp (our_string_array[3], "woo woo woo woo") != 0) - _dbus_assert_not_reached ("string array had wrong values"); + _dbus_test_fatal ("string array had wrong values"); dbus_free_string_array (our_string_array); if (dbus_message_iter_next (&iter)) - _dbus_assert_not_reached ("Didn't reach end of arguments"); + _dbus_test_fatal ("Didn't reach end of arguments"); } static void @@ -1119,7 +1118,7 @@ verify_test_message_memleak (DBusMessage *message) } else { - _dbus_warn ("error: parse with wrong signature: 'uashuu'."); + _dbus_test_fatal ("error: parse with wrong signature: 'uashuu'."); } /* parse with wrong signature: "uashuashu" */ @@ -1153,7 +1152,7 @@ verify_test_message_memleak (DBusMessage *message) } else { - _dbus_warn ("error: parse with wrong signature: 'uashuashu'."); + _dbus_test_fatal ("error: parse with wrong signature: 'uashuashu'."); } /* parse with correct signature: "uashuash" */ @@ -1275,7 +1274,7 @@ _dbus_message_test (const char *test_data_dir) /* string length including nul byte not a multiple of 4 */ if (!dbus_message_set_sender (message, "org.foo.bar1")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (dbus_message_has_sender (message, "org.foo.bar1")); dbus_message_set_reply_serial (message, 5678); @@ -1286,7 +1285,7 @@ _dbus_message_test (const char *test_data_dir) _dbus_string_get_length (&message->body)); if (!dbus_message_set_sender (message, NULL)) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_verbose_bytes_of_string (&message->header.data, 0, @@ -1309,50 +1308,50 @@ _dbus_message_test (const char *test_data_dir) /* Set/get some header fields */ if (!dbus_message_set_path (message, "/foo")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (strcmp (dbus_message_get_path (message), "/foo") == 0); if (!dbus_message_set_interface (message, "org.Foo")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (strcmp (dbus_message_get_interface (message), "org.Foo") == 0); if (!dbus_message_set_member (message, "Bar")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (strcmp (dbus_message_get_member (message), "Bar") == 0); /* Set/get them with longer values */ if (!dbus_message_set_path (message, "/foo/bar")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (strcmp (dbus_message_get_path (message), "/foo/bar") == 0); if (!dbus_message_set_interface (message, "org.Foo.Bar")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (strcmp (dbus_message_get_interface (message), "org.Foo.Bar") == 0); if (!dbus_message_set_member (message, "BarFoo")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (strcmp (dbus_message_get_member (message), "BarFoo") == 0); /* Realloc shorter again */ if (!dbus_message_set_path (message, "/foo")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (strcmp (dbus_message_get_path (message), "/foo") == 0); if (!dbus_message_set_interface (message, "org.Foo")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (strcmp (dbus_message_get_interface (message), "org.Foo") == 0); if (!dbus_message_set_member (message, "Bar")) - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); _dbus_assert (strcmp (dbus_message_get_member (message), "Bar") == 0); @@ -1573,17 +1572,17 @@ _dbus_message_test (const char *test_data_dir) /* Now pop back the message */ if (!_dbus_message_loader_queue_messages (loader)) - _dbus_assert_not_reached ("no memory to queue messages"); + _dbus_test_fatal ("no memory to queue messages"); if (_dbus_message_loader_get_is_corrupted (loader)) - _dbus_assert_not_reached ("message loader corrupted"); + _dbus_test_fatal ("message loader corrupted"); message = _dbus_message_loader_pop_message (loader); if (!message) - _dbus_assert_not_reached ("received a NULL message"); + _dbus_test_fatal ("received a NULL message"); if (dbus_message_get_reply_serial (message) != 5678) - _dbus_assert_not_reached ("reply serial fields differ"); + _dbus_test_fatal ("reply serial fields differ"); dbus_message_unref (message); @@ -1604,7 +1603,7 @@ _dbus_message_test (const char *test_data_dir) char garbage_header[DBUS_MINIMUM_HEADER_SIZE] = "xxx"; if (!dbus_message_marshal (message_without_unix_fds, &marshalled, &len)) - _dbus_assert_not_reached ("failed to marshal message"); + _dbus_test_fatal ("failed to marshal message"); _dbus_assert (len != 0); _dbus_assert (marshalled != NULL); @@ -1818,7 +1817,7 @@ _dbus_message_test (const char *test_data_dir) (DBusForeachMessageFileFunc) dbus_internal_do_not_use_try_message_file, NULL)) - _dbus_assert_not_reached ("foreach_message_file test failed"); + _dbus_test_fatal ("foreach_message_file test failed"); _dbus_check_fdleaks_leave (initial_fds); diff --git a/dbus/dbus-misc.c b/dbus/dbus-misc.c index 2be58a25..7f95803d 100644 --- a/dbus/dbus-misc.c +++ b/dbus/dbus-misc.c @@ -25,6 +25,7 @@ #include "dbus-misc.h" #include "dbus-internals.h" #include "dbus-string.h" +#include /** * @defgroup DBusMisc Miscellaneous @@ -276,14 +277,14 @@ _dbus_misc_test (void) /* Check DBUS_VERSION_STRING */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!(_dbus_string_append_int (&str, major) && _dbus_string_append_byte (&str, '.') && _dbus_string_append_int (&str, minor) && _dbus_string_append_byte (&str, '.') && _dbus_string_append_int (&str, micro))) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); _dbus_assert (_dbus_string_equal_c_str (&str, DBUS_VERSION_STRING)); diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index ab5df39b..6ac58ef3 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -28,6 +28,7 @@ #include "dbus-hash.h" #include "dbus-protocol.h" #include "dbus-string.h" +#include #include #include @@ -1648,7 +1649,7 @@ run_decompose_tests (void) ++i; } _dbus_warn ("}"); - _dbus_assert_not_reached ("path decompose failed"); + _dbus_test_fatal ("path decompose failed"); } dbus_free_string_array (result); diff --git a/dbus/dbus-sha.c b/dbus/dbus-sha.c index b09a4516..bbe000d6 100644 --- a/dbus/dbus-sha.c +++ b/dbus/dbus-sha.c @@ -529,10 +529,10 @@ check_sha_binary (const unsigned char *input, _dbus_string_init_const (&expected_str, expected); if (!_dbus_string_init (&results)) - _dbus_assert_not_reached ("no memory for SHA-1 results"); + _dbus_test_fatal ("no memory for SHA-1 results"); if (!_dbus_sha_compute (&input_str, &results)) - _dbus_assert_not_reached ("no memory for SHA-1 results"); + _dbus_test_fatal ("no memory for SHA-1 results"); if (!_dbus_string_equal (&expected_str, &results)) { @@ -622,7 +622,7 @@ decode_compact_string (const DBusString *line, if (byte_containing_next_bit >= _dbus_string_get_length (decoded)) { if (!_dbus_string_set_length (decoded, byte_containing_next_bit + 1)) - _dbus_assert_not_reached ("no memory to extend to next byte"); + _dbus_test_fatal ("no memory to extend to next byte"); } old_byte = _dbus_string_get_byte (decoded, byte_containing_next_bit); @@ -666,7 +666,7 @@ get_next_expected_result (DBusString *results, retval = FALSE; if (!_dbus_string_init (&line)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); next_iteration: while (_dbus_string_pop_line (results, &line)) @@ -689,7 +689,7 @@ get_next_expected_result (DBusString *results, int i; if (!_dbus_string_move (&line, 0, result, 0)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); i = 0; while (i < _dbus_string_get_length (result)) @@ -723,7 +723,7 @@ get_next_expected_result (DBusString *results, break; default: if ((c < '0' || c > '9') && (c < 'a' || c > 'f')) - _dbus_assert_not_reached ("invalid SHA-1 test script"); + _dbus_test_fatal ("invalid SHA-1 test script"); } ++i; @@ -757,33 +757,33 @@ process_test_data (const char *test_data_dir) retval = FALSE; if (!_dbus_string_init (&tests_file)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_init (&results_file)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_init (&tests)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_init (&results)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_init (&line)) - _dbus_assert_not_reached ("no memory"); - + _dbus_test_fatal ("no memory"); + if (!_dbus_string_append (&tests_file, test_data_dir)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_append (&results_file, test_data_dir)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); _dbus_string_init_const (&tmp, "sha-1/byte-messages.sha1"); if (!_dbus_concat_dir_and_file (&tests_file, &tmp)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); _dbus_string_init_const (&tmp, "sha-1/byte-hashes.sha1"); if (!_dbus_concat_dir_and_file (&results_file, &tmp)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_file_get_contents (&tests, &tests_file, &error)) { @@ -845,16 +845,16 @@ process_test_data (const char *test_data_dir) success = FALSE; if (!_dbus_string_init (&next_line)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_init (&expected)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_init (&test)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_init (&result)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); /* the "compact strings" are "^"-terminated not * newline-terminated so readahead to find the @@ -866,7 +866,7 @@ process_test_data (const char *test_data_dir) if (!_dbus_string_append_byte (&line, ' ') || !_dbus_string_move (&next_line, 0, &line, _dbus_string_get_length (&line))) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); } if (!decode_compact_string (&line, &test)) @@ -877,7 +877,7 @@ process_test_data (const char *test_data_dir) } if (!_dbus_sha_compute (&test, &result)) - _dbus_assert_not_reached ("no memory for SHA-1 result"); + _dbus_test_fatal ("no memory for SHA-1 result"); if (!get_next_expected_result (&results, &expected)) { diff --git a/dbus/dbus-signature.c b/dbus/dbus-signature.c index ef9eca91..94a25d5e 100644 --- a/dbus/dbus-signature.c +++ b/dbus/dbus-signature.c @@ -28,6 +28,7 @@ #include "dbus-marshal-basic.h" #include "dbus-internals.h" #include "dbus-test.h" +#include /** * Implementation details of #DBusSignatureIter, all fields are private @@ -581,7 +582,7 @@ _dbus_signature_test (void) return TRUE; #if 0 oom: - _dbus_assert_not_reached ("out of memory"); + _dbus_test_fatal ("out of memory"); return FALSE; #endif } diff --git a/dbus/dbus-string-util.c b/dbus/dbus-string-util.c index 59f2ac27..750275a0 100644 --- a/dbus/dbus-string-util.c +++ b/dbus/dbus-string-util.c @@ -133,29 +133,28 @@ test_hex_roundtrip (const char *data, len = strlen (data); if (!_dbus_string_init (&orig)) - _dbus_assert_not_reached ("could not init string"); + _dbus_test_fatal ("could not init string"); if (!_dbus_string_init (&encoded)) - _dbus_assert_not_reached ("could not init string"); + _dbus_test_fatal ("could not init string"); if (!_dbus_string_init (&decoded)) - _dbus_assert_not_reached ("could not init string"); + _dbus_test_fatal ("could not init string"); if (!_dbus_string_append_len (&orig, data, len)) - _dbus_assert_not_reached ("couldn't append orig data"); + _dbus_test_fatal ("couldn't append orig data"); if (!_dbus_string_hex_encode (&orig, 0, &encoded, 0)) - _dbus_assert_not_reached ("could not encode"); + _dbus_test_fatal ("could not encode"); if (!_dbus_string_hex_decode (&encoded, 0, &end, &decoded, 0)) - _dbus_assert_not_reached ("could not decode"); + _dbus_test_fatal ("could not decode"); _dbus_assert (_dbus_string_get_length (&encoded) == end); if (!_dbus_string_equal (&orig, &decoded)) { const char *s; - _dbus_test_diag ("Original string %d bytes encoded %d bytes decoded %d bytes", _dbus_string_get_length (&orig), @@ -253,10 +252,10 @@ _dbus_string_test (void) int j; if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); + _dbus_test_fatal ("failed to init string"); if (!_dbus_string_set_length (&str, lens[i])) - _dbus_assert_not_reached ("failed to set string length"); + _dbus_test_fatal ("failed to set string length"); j = lens[i]; while (j > 0) @@ -277,10 +276,10 @@ _dbus_string_test (void) /* Test equality */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); if (!_dbus_string_append (&str, "Hello World")) - _dbus_assert_not_reached ("oom"); + _dbus_test_fatal ("oom"); _dbus_string_init_const (&other, "H"); _dbus_assert (_dbus_string_equal_substring (&str, 0, 1, &other, 0)); @@ -320,18 +319,18 @@ _dbus_string_test (void) /* Test appending data */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); + _dbus_test_fatal ("failed to init string"); i = 0; while (i < 10) { if (!_dbus_string_append (&str, "a")) - _dbus_assert_not_reached ("failed to append string to string"); + _dbus_test_fatal ("failed to append string to string"); _dbus_assert (_dbus_string_get_length (&str) == i * 2 + 1); if (!_dbus_string_append_byte (&str, 'b')) - _dbus_assert_not_reached ("failed to append byte to string"); + _dbus_test_fatal ("failed to append byte to string"); _dbus_assert (_dbus_string_get_length (&str) == i * 2 + 2); @@ -343,15 +342,15 @@ _dbus_string_test (void) /* Check steal_data */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); + _dbus_test_fatal ("failed to init string"); if (!_dbus_string_append (&str, "Hello World")) - _dbus_assert_not_reached ("could not append to string"); + _dbus_test_fatal ("could not append to string"); i = _dbus_string_get_length (&str); if (!_dbus_string_steal_data (&str, &s)) - _dbus_assert_not_reached ("failed to steal data"); + _dbus_test_fatal ("failed to steal data"); _dbus_assert (_dbus_string_get_length (&str) == 0); _dbus_assert (((int)strlen (s)) == i); @@ -361,33 +360,33 @@ _dbus_string_test (void) /* Check move */ if (!_dbus_string_append (&str, "Hello World")) - _dbus_assert_not_reached ("could not append to string"); + _dbus_test_fatal ("could not append to string"); i = _dbus_string_get_length (&str); if (!_dbus_string_init (&other)) - _dbus_assert_not_reached ("could not init string"); + _dbus_test_fatal ("could not init string"); if (!_dbus_string_move (&str, 0, &other, 0)) - _dbus_assert_not_reached ("could not move"); + _dbus_test_fatal ("could not move"); _dbus_assert (_dbus_string_get_length (&str) == 0); _dbus_assert (_dbus_string_get_length (&other) == i); if (!_dbus_string_append (&str, "Hello World")) - _dbus_assert_not_reached ("could not append to string"); + _dbus_test_fatal ("could not append to string"); if (!_dbus_string_move (&str, 0, &other, _dbus_string_get_length (&other))) - _dbus_assert_not_reached ("could not move"); + _dbus_test_fatal ("could not move"); _dbus_assert (_dbus_string_get_length (&str) == 0); _dbus_assert (_dbus_string_get_length (&other) == i * 2); if (!_dbus_string_append (&str, "Hello World")) - _dbus_assert_not_reached ("could not append to string"); + _dbus_test_fatal ("could not append to string"); if (!_dbus_string_move (&str, 0, &other, _dbus_string_get_length (&other) / 2)) - _dbus_assert_not_reached ("could not move"); + _dbus_test_fatal ("could not move"); _dbus_assert (_dbus_string_get_length (&str) == 0); _dbus_assert (_dbus_string_get_length (&other) == i * 3); @@ -397,21 +396,21 @@ _dbus_string_test (void) /* Check copy */ if (!_dbus_string_append (&str, "Hello World")) - _dbus_assert_not_reached ("could not append to string"); + _dbus_test_fatal ("could not append to string"); i = _dbus_string_get_length (&str); if (!_dbus_string_init (&other)) - _dbus_assert_not_reached ("could not init string"); - + _dbus_test_fatal ("could not init string"); + if (!_dbus_string_copy (&str, 0, &other, 0)) - _dbus_assert_not_reached ("could not copy"); + _dbus_test_fatal ("could not copy"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == i); if (!_dbus_string_copy (&str, 0, &other, _dbus_string_get_length (&other))) - _dbus_assert_not_reached ("could not copy"); + _dbus_test_fatal ("could not copy"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == i * 2); @@ -419,7 +418,7 @@ _dbus_string_test (void) "Hello WorldHello World")); if (!_dbus_string_copy (&str, 0, &other, _dbus_string_get_length (&other) / 2)) - _dbus_assert_not_reached ("could not copy"); + _dbus_test_fatal ("could not copy"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == i * 3); @@ -432,19 +431,19 @@ _dbus_string_test (void) /* Check replace */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); - + _dbus_test_fatal ("failed to init string"); + if (!_dbus_string_append (&str, "Hello World")) - _dbus_assert_not_reached ("could not append to string"); + _dbus_test_fatal ("could not append to string"); i = _dbus_string_get_length (&str); if (!_dbus_string_init (&other)) - _dbus_assert_not_reached ("could not init string"); - + _dbus_test_fatal ("could not init string"); + if (!_dbus_string_replace_len (&str, 0, _dbus_string_get_length (&str), &other, 0, _dbus_string_get_length (&other))) - _dbus_assert_not_reached ("could not replace"); + _dbus_test_fatal ("could not replace"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == i); @@ -452,7 +451,7 @@ _dbus_string_test (void) if (!_dbus_string_replace_len (&str, 0, _dbus_string_get_length (&str), &other, 5, 1)) - _dbus_assert_not_reached ("could not replace center space"); + _dbus_test_fatal ("could not replace center space"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == i * 2 - 1); @@ -464,8 +463,8 @@ _dbus_string_test (void) &other, _dbus_string_get_length (&other) - 1, 1)) - _dbus_assert_not_reached ("could not replace end character"); - + _dbus_test_fatal ("could not replace end character"); + _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == i * 2 - 1); _dbus_assert (_dbus_string_equal_c_str (&other, @@ -480,24 +479,24 @@ _dbus_string_test (void) */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); - + _dbus_test_fatal ("failed to init string"); + if (!_dbus_string_append (&str, "Hello World")) - _dbus_assert_not_reached ("could not append to string"); + _dbus_test_fatal ("could not append to string"); i = _dbus_string_get_length (&str); if (!_dbus_string_init (&other)) - _dbus_assert_not_reached ("could not init string"); + _dbus_test_fatal ("could not init string"); if (!_dbus_string_append (&other, "Foo String")) - _dbus_assert_not_reached ("could not append to string"); + _dbus_test_fatal ("could not append to string"); a = _dbus_string_get_length (&other); if (!_dbus_string_replace_len (&str, 0, 6, &other, 4, 0)) - _dbus_assert_not_reached ("could not replace 0 length"); + _dbus_test_fatal ("could not replace 0 length"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == a + 6); @@ -508,7 +507,7 @@ _dbus_string_test (void) &other, _dbus_string_get_length (&other), 0)) - _dbus_assert_not_reached ("could not replace at the end"); + _dbus_test_fatal ("could not replace at the end"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == a + 6 + 6); @@ -519,7 +518,7 @@ _dbus_string_test (void) &other, _dbus_string_get_length (&other) - 5, 5)) - _dbus_assert_not_reached ("could not replace same length"); + _dbus_test_fatal ("could not replace same length"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == a + 6 + 6); @@ -528,7 +527,7 @@ _dbus_string_test (void) if (!_dbus_string_replace_len (&str, 6, 5, &other, 4, 12)) - _dbus_assert_not_reached ("could not replace with shorter string"); + _dbus_test_fatal ("could not replace with shorter string"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == a + 5); @@ -537,7 +536,7 @@ _dbus_string_test (void) if (!_dbus_string_replace_len (&str, 0, 1, &other, 0, 3)) - _dbus_assert_not_reached ("could not replace at the beginning"); + _dbus_test_fatal ("could not replace at the beginning"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == a + 3); @@ -548,7 +547,7 @@ _dbus_string_test (void) &other, _dbus_string_get_length (&other) - 5, 5)) - _dbus_assert_not_reached ("could not replace same length"); + _dbus_test_fatal ("could not replace same length"); _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == a + 3); @@ -561,10 +560,10 @@ _dbus_string_test (void) /* Check insert/set/get byte */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); + _dbus_test_fatal ("failed to init string"); if (!_dbus_string_append (&str, "Hello")) - _dbus_assert_not_reached ("failed to append Hello"); + _dbus_test_fatal ("failed to append Hello"); _dbus_assert (_dbus_string_get_byte (&str, 0) == 'H'); _dbus_assert (_dbus_string_get_byte (&str, 1) == 'e'); @@ -576,14 +575,14 @@ _dbus_string_test (void) _dbus_assert (_dbus_string_get_byte (&str, 1) == 'q'); if (!_dbus_string_insert_bytes (&str, 0, 1, 255)) - _dbus_assert_not_reached ("can't insert byte"); + _dbus_test_fatal ("can't insert byte"); if (!_dbus_string_insert_bytes (&str, 2, 4, 'Z')) - _dbus_assert_not_reached ("can't insert byte"); + _dbus_test_fatal ("can't insert byte"); if (!_dbus_string_insert_bytes (&str, _dbus_string_get_length (&str), 1, 'W')) - _dbus_assert_not_reached ("can't insert byte"); - + _dbus_test_fatal ("can't insert byte"); + _dbus_assert (_dbus_string_get_byte (&str, 0) == 255); _dbus_assert (_dbus_string_get_byte (&str, 1) == 'H'); _dbus_assert (_dbus_string_get_byte (&str, 2) == 'Z'); @@ -601,15 +600,15 @@ _dbus_string_test (void) /* Check append/parse int/double */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); + _dbus_test_fatal ("failed to init string"); if (!_dbus_string_append_int (&str, 27)) - _dbus_assert_not_reached ("failed to append int"); + _dbus_test_fatal ("failed to append int"); i = _dbus_string_get_length (&str); if (!_dbus_string_parse_int (&str, 0, &v, &end)) - _dbus_assert_not_reached ("failed to parse int"); + _dbus_test_fatal ("failed to parse int"); _dbus_assert (v == 27); _dbus_assert (end == i); @@ -618,82 +617,82 @@ _dbus_string_test (void) /* Test find */ if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("failed to init string"); + _dbus_test_fatal ("failed to init string"); if (!_dbus_string_append (&str, "Hello")) - _dbus_assert_not_reached ("couldn't append to string"); + _dbus_test_fatal ("couldn't append to string"); if (!_dbus_string_find (&str, 0, "He", &i)) - _dbus_assert_not_reached ("didn't find 'He'"); + _dbus_test_fatal ("didn't find 'He'"); _dbus_assert (i == 0); if (!_dbus_string_find (&str, 0, "Hello", &i)) - _dbus_assert_not_reached ("didn't find 'Hello'"); + _dbus_test_fatal ("didn't find 'Hello'"); _dbus_assert (i == 0); if (!_dbus_string_find (&str, 0, "ello", &i)) - _dbus_assert_not_reached ("didn't find 'ello'"); + _dbus_test_fatal ("didn't find 'ello'"); _dbus_assert (i == 1); if (!_dbus_string_find (&str, 0, "lo", &i)) - _dbus_assert_not_reached ("didn't find 'lo'"); + _dbus_test_fatal ("didn't find 'lo'"); _dbus_assert (i == 3); if (!_dbus_string_find (&str, 2, "lo", &i)) - _dbus_assert_not_reached ("didn't find 'lo'"); + _dbus_test_fatal ("didn't find 'lo'"); _dbus_assert (i == 3); if (_dbus_string_find (&str, 4, "lo", &i)) - _dbus_assert_not_reached ("did find 'lo'"); + _dbus_test_fatal ("did find 'lo'"); if (!_dbus_string_find (&str, 0, "l", &i)) - _dbus_assert_not_reached ("didn't find 'l'"); + _dbus_test_fatal ("didn't find 'l'"); _dbus_assert (i == 2); if (!_dbus_string_find (&str, 0, "H", &i)) - _dbus_assert_not_reached ("didn't find 'H'"); + _dbus_test_fatal ("didn't find 'H'"); _dbus_assert (i == 0); if (!_dbus_string_find (&str, 0, "", &i)) - _dbus_assert_not_reached ("didn't find ''"); + _dbus_test_fatal ("didn't find ''"); _dbus_assert (i == 0); if (_dbus_string_find (&str, 0, "Hello!", NULL)) - _dbus_assert_not_reached ("Did find 'Hello!'"); + _dbus_test_fatal ("Did find 'Hello!'"); if (_dbus_string_find (&str, 0, "Oh, Hello", NULL)) - _dbus_assert_not_reached ("Did find 'Oh, Hello'"); + _dbus_test_fatal ("Did find 'Oh, Hello'"); if (_dbus_string_find (&str, 0, "ill", NULL)) - _dbus_assert_not_reached ("Did find 'ill'"); + _dbus_test_fatal ("Did find 'ill'"); if (_dbus_string_find (&str, 0, "q", NULL)) - _dbus_assert_not_reached ("Did find 'q'"); + _dbus_test_fatal ("Did find 'q'"); if (!_dbus_string_find_to (&str, 0, 2, "He", NULL)) - _dbus_assert_not_reached ("Didn't find 'He'"); + _dbus_test_fatal ("Didn't find 'He'"); if (_dbus_string_find_to (&str, 0, 2, "Hello", NULL)) - _dbus_assert_not_reached ("Did find 'Hello'"); + _dbus_test_fatal ("Did find 'Hello'"); if (!_dbus_string_find_byte_backward (&str, _dbus_string_get_length (&str), 'H', &i)) - _dbus_assert_not_reached ("Did not find 'H'"); + _dbus_test_fatal ("Did not find 'H'"); _dbus_assert (i == 0); if (!_dbus_string_find_byte_backward (&str, _dbus_string_get_length (&str), 'o', &i)) - _dbus_assert_not_reached ("Did not find 'o'"); + _dbus_test_fatal ("Did not find 'o'"); _dbus_assert (i == _dbus_string_get_length (&str) - 1); if (_dbus_string_find_byte_backward (&str, _dbus_string_get_length (&str) - 1, 'o', &i)) - _dbus_assert_not_reached ("Did find 'o'"); + _dbus_test_fatal ("Did find 'o'"); _dbus_assert (i == -1); if (_dbus_string_find_byte_backward (&str, 1, 'e', &i)) - _dbus_assert_not_reached ("Did find 'e'"); + _dbus_test_fatal ("Did find 'e'"); _dbus_assert (i == -1); if (!_dbus_string_find_byte_backward (&str, 2, 'e', &i)) - _dbus_assert_not_reached ("Didn't find 'e'"); + _dbus_test_fatal ("Didn't find 'e'"); _dbus_assert (i == 1); _dbus_string_free (&str); @@ -701,10 +700,10 @@ _dbus_string_test (void) /* Hex encoding */ _dbus_string_init_const (&str, "cafebabe, this is a bogus hex string"); if (!_dbus_string_init (&other)) - _dbus_assert_not_reached ("could not init string"); + _dbus_test_fatal ("could not init string"); if (!_dbus_string_hex_decode (&str, 0, &end, &other, 0)) - _dbus_assert_not_reached ("deccoded bogus hex string with no error"); + _dbus_test_fatal ("deccoded bogus hex string with no error"); _dbus_assert (end == 8); @@ -720,25 +719,25 @@ _dbus_string_test (void) _dbus_string_init_const (&str, "012\r\n567\n90"); if (!_dbus_string_find_eol (&str, 0, &found, &found_len) || found != 3 || found_len != 2) - _dbus_assert_not_reached ("Did not find '\\r\\n'"); - if (found != 3 || found_len != 2) - _dbus_assert_not_reached ("invalid return values"); - - if (!_dbus_string_find_eol (&str, 5, &found, &found_len)) - _dbus_assert_not_reached ("Did not find '\\n'"); - if (found != 8 || found_len != 1) - _dbus_assert_not_reached ("invalid return values"); - - if (_dbus_string_find_eol (&str, 9, &found, &found_len)) - _dbus_assert_not_reached ("Found not expected '\\n'"); - else if (found != 11 || found_len != 0) - _dbus_assert_not_reached ("invalid return values '\\n'"); + _dbus_test_fatal ("Did not find '\\r\\n'"); + if (found != 3 || found_len != 2) + _dbus_test_fatal ("invalid return values"); + + if (!_dbus_string_find_eol (&str, 5, &found, &found_len)) + _dbus_test_fatal ("Did not find '\\n'"); + if (found != 8 || found_len != 1) + _dbus_test_fatal ("invalid return values"); + + if (_dbus_string_find_eol (&str, 9, &found, &found_len)) + _dbus_test_fatal ("Found not expected '\\n'"); + else if (found != 11 || found_len != 0) + _dbus_test_fatal ("invalid return values '\\n'"); found = -1; found_len = -1; _dbus_string_init_const (&str, ""); if (_dbus_string_find_eol (&str, 0, &found, &found_len)) - _dbus_assert_not_reached ("found an eol in an empty string"); + _dbus_test_fatal ("found an eol in an empty string"); _dbus_assert (found == 0); _dbus_assert (found_len == 0); @@ -746,7 +745,7 @@ _dbus_string_test (void) found_len = -1; _dbus_string_init_const (&str, "foobar"); if (_dbus_string_find_eol (&str, 0, &found, &found_len)) - _dbus_assert_not_reached ("found eol in string that lacks one"); + _dbus_test_fatal ("found eol in string that lacks one"); _dbus_assert (found == 6); _dbus_assert (found_len == 0); @@ -754,7 +753,7 @@ _dbus_string_test (void) found_len = -1; _dbus_string_init_const (&str, "foobar\n"); if (!_dbus_string_find_eol (&str, 0, &found, &found_len)) - _dbus_assert_not_reached ("did not find eol in string that has one at end"); + _dbus_test_fatal ("did not find eol in string that has one at end"); _dbus_assert (found == 6); _dbus_assert (found_len == 1); } @@ -769,31 +768,31 @@ _dbus_string_test (void) #define FOURTH_LINE "this is a fourth line" if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_append (&str, FIRST_LINE "\n" SECOND_LINE "\r\n" THIRD_LINE "\n" FOURTH_LINE)) - _dbus_assert_not_reached ("no memory"); - + _dbus_test_fatal ("no memory"); + if (!_dbus_string_init (&line)) - _dbus_assert_not_reached ("no memory"); - + _dbus_test_fatal ("no memory"); + if (!_dbus_string_pop_line (&str, &line)) - _dbus_assert_not_reached ("failed to pop first line"); + _dbus_test_fatal ("failed to pop first line"); _dbus_assert (_dbus_string_equal_c_str (&line, FIRST_LINE)); if (!_dbus_string_pop_line (&str, &line)) - _dbus_assert_not_reached ("failed to pop second line"); + _dbus_test_fatal ("failed to pop second line"); _dbus_assert (_dbus_string_equal_c_str (&line, SECOND_LINE)); if (!_dbus_string_pop_line (&str, &line)) - _dbus_assert_not_reached ("failed to pop third line"); + _dbus_test_fatal ("failed to pop third line"); _dbus_assert (_dbus_string_equal_c_str (&line, THIRD_LINE)); if (!_dbus_string_pop_line (&str, &line)) - _dbus_assert_not_reached ("failed to pop fourth line"); + _dbus_test_fatal ("failed to pop fourth line"); _dbus_assert (_dbus_string_equal_c_str (&line, FOURTH_LINE)); @@ -803,56 +802,56 @@ _dbus_string_test (void) { if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); for (i = 0; i < 10000; i++) if (!_dbus_string_append (&str, "abcdefghijklmnopqrstuvwxyz")) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_set_length (&str, 10)) - _dbus_assert_not_reached ("failed to set length"); + _dbus_test_fatal ("failed to set length"); /* actually compact */ if (!_dbus_string_compact (&str, 2048)) - _dbus_assert_not_reached ("failed to compact after set_length"); + _dbus_test_fatal ("failed to compact after set_length"); /* peek inside to make sure it worked */ if (((DBusRealString *)&str)->allocated > 30) - _dbus_assert_not_reached ("compacting string didn't do anything"); + _dbus_test_fatal ("compacting string didn't do anything"); if (!_dbus_string_equal_c_str (&str, "abcdefghij")) - _dbus_assert_not_reached ("unexpected content after compact"); + _dbus_test_fatal ("unexpected content after compact"); /* compact nothing */ if (!_dbus_string_compact (&str, 2048)) - _dbus_assert_not_reached ("failed to compact 2nd time"); + _dbus_test_fatal ("failed to compact 2nd time"); if (!_dbus_string_equal_c_str (&str, "abcdefghij")) - _dbus_assert_not_reached ("unexpected content after 2nd compact"); + _dbus_test_fatal ("unexpected content after 2nd compact"); /* and make sure it still works...*/ if (!_dbus_string_append (&str, "123456")) - _dbus_assert_not_reached ("failed to append after compact"); + _dbus_test_fatal ("failed to append after compact"); if (!_dbus_string_equal_c_str (&str, "abcdefghij123456")) - _dbus_assert_not_reached ("unexpected content after append"); + _dbus_test_fatal ("unexpected content after append"); /* after growing automatically, this should do nothing */ if (!_dbus_string_compact (&str, 20000)) - _dbus_assert_not_reached ("failed to compact after grow"); + _dbus_test_fatal ("failed to compact after grow"); /* but this one will do something */ if (!_dbus_string_compact (&str, 0)) - _dbus_assert_not_reached ("failed to compact after grow"); + _dbus_test_fatal ("failed to compact after grow"); if (!_dbus_string_equal_c_str (&str, "abcdefghij123456")) - _dbus_assert_not_reached ("unexpected content"); + _dbus_test_fatal ("unexpected content"); if (!_dbus_string_append (&str, "!@#$%")) - _dbus_assert_not_reached ("failed to append after compact"); + _dbus_test_fatal ("failed to append after compact"); if (!_dbus_string_equal_c_str (&str, "abcdefghij123456!@#$%")) - _dbus_assert_not_reached ("unexpected content"); + _dbus_test_fatal ("unexpected content"); _dbus_string_free (&str); } @@ -861,22 +860,22 @@ _dbus_string_test (void) const char two_strings[] = "one\ttwo"; if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_init (&other)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_append (&str, two_strings)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_split_on_byte (&str, '\t', &other)) - _dbus_assert_not_reached ("no memory or delimiter not found"); + _dbus_test_fatal ("no memory or delimiter not found"); if (strcmp (_dbus_string_get_data (&str), "one") != 0) - _dbus_assert_not_reached ("left side after split on tab is wrong"); + _dbus_test_fatal ("left side after split on tab is wrong"); if (strcmp (_dbus_string_get_data (&other), "two") != 0) - _dbus_assert_not_reached ("right side after split on tab is wrong"); + _dbus_test_fatal ("right side after split on tab is wrong"); _dbus_string_free (&str); _dbus_string_free (&other); @@ -888,28 +887,28 @@ _dbus_string_test (void) const char lower2_string[] = "toupperSTRING"; if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_append (&str, upper_string)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); _dbus_string_tolower_ascii (&str, 0, _dbus_string_get_length(&str)); if (!_dbus_string_equal_c_str (&str, lower_string)) - _dbus_assert_not_reached ("_dbus_string_tolower_ascii failed"); + _dbus_test_fatal ("_dbus_string_tolower_ascii failed"); _dbus_string_free (&str); if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_append (&str, upper_string)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); _dbus_string_tolower_ascii (&str, 0, 7); if (!_dbus_string_equal_c_str (&str, lower2_string)) - _dbus_assert_not_reached ("_dbus_string_tolower_ascii failed in partial conversion"); + _dbus_test_fatal ("_dbus_string_tolower_ascii failed in partial conversion"); _dbus_string_free (&str); } @@ -920,28 +919,28 @@ _dbus_string_test (void) const char upper2_string[] = "TOUPPERstring"; if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_append (&str, lower_string)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); _dbus_string_toupper_ascii (&str, 0, _dbus_string_get_length(&str)); if (!_dbus_string_equal_c_str (&str, upper_string)) - _dbus_assert_not_reached ("_dbus_string_toupper_ascii failed"); + _dbus_test_fatal ("_dbus_string_toupper_ascii failed"); _dbus_string_free (&str); if (!_dbus_string_init (&str)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_append (&str, lower_string)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); _dbus_string_toupper_ascii (&str, 0, 7); if (!_dbus_string_equal_c_str (&str, upper2_string)) - _dbus_assert_not_reached ("_dbus_string_toupper_ascii failed in partial conversion"); + _dbus_test_fatal ("_dbus_string_toupper_ascii failed in partial conversion"); _dbus_string_free (&str); } diff --git a/dbus/dbus-sysdeps-util.c b/dbus/dbus-sysdeps-util.c index 44cc6a23..6fbe8dab 100644 --- a/dbus/dbus-sysdeps-util.c +++ b/dbus/dbus-sysdeps-util.c @@ -27,6 +27,7 @@ #include "dbus-internals.h" #include "dbus-string.h" #include "dbus-test.h" +#include #include @@ -92,10 +93,10 @@ check_dirname (const char *filename, _dbus_string_init_const (&f, filename); if (!_dbus_string_init (&d)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_get_dirname (&f, &d)) - _dbus_assert_not_reached ("no memory"); + _dbus_test_fatal ("no memory"); if (!_dbus_string_equal_c_str (&d, dirname)) { diff --git a/dbus/dbus-userdb-util.c b/dbus/dbus-userdb-util.c index edc194cb..5ec68445 100644 --- a/dbus/dbus-userdb-util.c +++ b/dbus/dbus-userdb-util.c @@ -453,16 +453,16 @@ _dbus_userdb_test (const char *test_data_dir) DBusError error; if (!_dbus_username_from_current_process (&username)) - _dbus_assert_not_reached ("didn't get username"); + _dbus_test_fatal ("didn't get username"); if (!_dbus_homedir_from_current_process (&homedir)) - _dbus_assert_not_reached ("didn't get homedir"); + _dbus_test_fatal ("didn't get homedir"); if (!_dbus_get_user_id (username, &uid)) - _dbus_assert_not_reached ("didn't get uid"); + _dbus_test_fatal ("didn't get uid"); if (!_dbus_groups_from_uid (uid, &group_ids, &n_group_ids)) - _dbus_assert_not_reached ("didn't get groups"); + _dbus_test_fatal ("didn't get groups"); _dbus_test_diag (" Current user: %s homedir: %s gids:", _dbus_string_get_const_data (username), -- 2.15.0