mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-02-14 23:50:28 +01:00
Embedded tests: Emit TAP diagnostics instead of printf
Reviewed-by: Philip Withnall <withnall@endlessm.com> Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103601
This commit is contained in:
parent
5ffb709b42
commit
ed40af9284
16 changed files with 141 additions and 169 deletions
|
|
@ -28,6 +28,7 @@
|
|||
#include "utils.h"
|
||||
#include <dbus/dbus-list.h>
|
||||
#include <dbus/dbus-internals.h>
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
|
|
@ -400,7 +401,7 @@ check_return_values (const DBusString *full_path)
|
|||
dbus_error_init (&error);
|
||||
retval = FALSE;
|
||||
|
||||
printf ("Testing values from: %s\n", _dbus_string_get_const_data (full_path));
|
||||
_dbus_test_diag ("Testing values from: %s", _dbus_string_get_const_data (full_path));
|
||||
|
||||
parser = bus_config_load (full_path, TRUE, NULL, &error);
|
||||
if (parser == NULL)
|
||||
|
|
@ -426,7 +427,7 @@ check_return_values (const DBusString *full_path)
|
|||
_dbus_warn ("User was invalid; '%s'!", user);
|
||||
goto finish;
|
||||
}
|
||||
printf (" <user>dbus</user> OKAY!\n");
|
||||
_dbus_test_diag (" <user>dbus</user> OKAY!");
|
||||
#endif
|
||||
|
||||
/* check type return value is okay */
|
||||
|
|
@ -441,7 +442,7 @@ check_return_values (const DBusString *full_path)
|
|||
_dbus_warn ("Type was invalid; '%s'!", user);
|
||||
goto finish;
|
||||
}
|
||||
printf (" <type>system</type> OKAY!\n");
|
||||
_dbus_test_diag (" <type>system</type> OKAY!");
|
||||
|
||||
/* check dirs return value is okay */
|
||||
dirs = bus_config_parser_get_service_paths (parser);
|
||||
|
|
@ -450,7 +451,7 @@ check_return_values (const DBusString *full_path)
|
|||
_dbus_warn ("Service dirs are NULL!");
|
||||
goto finish;
|
||||
}
|
||||
printf (" <standard_system_service_dirs/> OKAY!\n");
|
||||
_dbus_test_diag (" <standard_system_service_dirs/> OKAY!");
|
||||
/* NOTE: We tested the specific return values in the config-parser tests */
|
||||
|
||||
/* woohoo! */
|
||||
|
|
@ -570,11 +571,11 @@ process_test_valid_subdir (const DBusString *test_base_dir,
|
|||
}
|
||||
|
||||
if (validity == VALID)
|
||||
printf ("Testing valid files:\n");
|
||||
_dbus_test_diag ("Testing valid files:");
|
||||
else if (validity == INVALID)
|
||||
printf ("Testing invalid files:\n");
|
||||
_dbus_test_diag ("Testing invalid files:");
|
||||
else
|
||||
printf ("Testing unknown files:\n");
|
||||
_dbus_test_diag ("Testing unknown files:");
|
||||
|
||||
next:
|
||||
while (_dbus_directory_get_next_file (dir, &filename, &error))
|
||||
|
|
@ -599,7 +600,7 @@ process_test_valid_subdir (const DBusString *test_base_dir,
|
|||
goto next;
|
||||
}
|
||||
|
||||
printf (" %s\n", _dbus_string_get_const_data (&filename));
|
||||
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
|
||||
|
||||
_dbus_verbose (" expecting %s\n",
|
||||
validity == VALID ? "valid" :
|
||||
|
|
@ -695,14 +696,14 @@ check_file_valid (DBusString *full_path,
|
|||
dbus_bool_t retval;
|
||||
|
||||
if (validity == VALID)
|
||||
printf ("Testing valid file:\n");
|
||||
_dbus_test_diag ("Testing valid file:");
|
||||
else if (validity == INVALID)
|
||||
printf ("Testing invalid file:\n");
|
||||
_dbus_test_diag ("Testing invalid file:");
|
||||
else
|
||||
printf ("Testing unknown file:\n");
|
||||
_dbus_test_diag ("Testing unknown file:");
|
||||
|
||||
/* print the filename, just so we match the other output */
|
||||
printf (" %s\n", _dbus_string_get_const_data (full_path));
|
||||
_dbus_test_diag (" %s", _dbus_string_get_const_data (full_path));
|
||||
|
||||
/* only test one file */
|
||||
retval = do_load (full_path, validity, TRUE);
|
||||
|
|
@ -721,7 +722,7 @@ bus_config_parser_trivial_test (const DBusString *test_data_dir)
|
|||
if (test_data_dir == NULL ||
|
||||
_dbus_string_get_length (test_data_dir) == 0)
|
||||
{
|
||||
printf ("No test data\n");
|
||||
_dbus_test_diag ("No test data");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include <dbus/dbus-internals.h>
|
||||
#include <dbus/dbus-misc.h>
|
||||
#include <dbus/dbus-sysdeps.h>
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef enum
|
||||
|
|
@ -3081,7 +3082,7 @@ do_check_own_rules (BusPolicy *policy)
|
|||
_dbus_assert_not_reached ("couldn't append string");
|
||||
|
||||
ret = bus_policy_check_can_own (policy, &service_name);
|
||||
printf (" Check name %s: %s\n", checks[i].name,
|
||||
_dbus_test_diag (" Check name %s: %s", checks[i].name,
|
||||
ret ? "allowed" : "not allowed");
|
||||
if (checks[i].allowed && !ret)
|
||||
{
|
||||
|
|
@ -3216,11 +3217,11 @@ process_test_valid_subdir (const DBusString *test_base_dir,
|
|||
}
|
||||
|
||||
if (validity == VALID)
|
||||
printf ("Testing valid files:\n");
|
||||
_dbus_test_diag ("Testing valid files:");
|
||||
else if (validity == INVALID)
|
||||
printf ("Testing invalid files:\n");
|
||||
_dbus_test_diag ("Testing invalid files:");
|
||||
else
|
||||
printf ("Testing unknown files:\n");
|
||||
_dbus_test_diag ("Testing unknown files:");
|
||||
|
||||
next:
|
||||
while (_dbus_directory_get_next_file (dir, &filename, &error))
|
||||
|
|
@ -3245,7 +3246,7 @@ process_test_valid_subdir (const DBusString *test_base_dir,
|
|||
goto next;
|
||||
}
|
||||
|
||||
printf (" %s\n", _dbus_string_get_const_data (&filename));
|
||||
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
|
||||
|
||||
_dbus_verbose (" expecting %s\n",
|
||||
validity == VALID ? "valid" :
|
||||
|
|
@ -3537,7 +3538,7 @@ all_are_equiv (const DBusString *target_directory)
|
|||
goto finished;
|
||||
}
|
||||
|
||||
printf ("Comparing equivalent files:\n");
|
||||
_dbus_test_diag ("Comparing equivalent files:");
|
||||
|
||||
next:
|
||||
while (_dbus_directory_get_next_file (dir, &filename, &error))
|
||||
|
|
@ -3561,7 +3562,7 @@ all_are_equiv (const DBusString *target_directory)
|
|||
goto next;
|
||||
}
|
||||
|
||||
printf (" %s\n", _dbus_string_get_const_data (&filename));
|
||||
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
|
||||
|
||||
parser = bus_config_load (&full_path, TRUE, NULL, &error);
|
||||
|
||||
|
|
@ -3778,9 +3779,9 @@ test_default_session_servicedirs (const DBusString *test_base_dir)
|
|||
if (dbus_test_builddir == NULL || xdg_data_home == NULL ||
|
||||
xdg_runtime_dir == NULL)
|
||||
{
|
||||
printf ("Not testing default session service directories because a "
|
||||
_dbus_test_diag ("Not testing default session service directories because a "
|
||||
"build-time testing environment variable is not set: "
|
||||
"see AM_TESTS_ENVIRONMENT in tests/Makefile.am\n");
|
||||
"see AM_TESTS_ENVIRONMENT in tests/Makefile.am");
|
||||
ret = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -3832,17 +3833,17 @@ test_default_session_servicedirs (const DBusString *test_base_dir)
|
|||
BusConfigServiceDir *dir = link->data;
|
||||
BusServiceDirFlags expected = BUS_SERVICE_DIR_FLAGS_NONE;
|
||||
|
||||
printf (" test service dir: '%s'\n", dir->path);
|
||||
printf (" current standard service dir: '%s'\n", test_session_service_dir_matches[i]);
|
||||
_dbus_test_diag (" test service dir: '%s'", dir->path);
|
||||
_dbus_test_diag (" current standard service dir: '%s'", test_session_service_dir_matches[i]);
|
||||
if (test_session_service_dir_matches[i] == NULL)
|
||||
{
|
||||
printf ("more directories parsed than in match set\n");
|
||||
_dbus_test_diag ("more directories parsed than in match set");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strcmp (test_session_service_dir_matches[i], dir->path) != 0)
|
||||
{
|
||||
printf ("'%s' directory does not match '%s' in the match set\n",
|
||||
_dbus_test_diag ("'%s' directory does not match '%s' in the match set",
|
||||
dir->path, test_session_service_dir_matches[i]);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -3857,7 +3858,7 @@ test_default_session_servicedirs (const DBusString *test_base_dir)
|
|||
|
||||
if (dir->flags != expected)
|
||||
{
|
||||
printf ("'%s' directory has flags 0x%x, should be 0x%x\n",
|
||||
_dbus_test_diag ("'%s' directory has flags 0x%x, should be 0x%x",
|
||||
dir->path, dir->flags, expected);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -3865,7 +3866,7 @@ test_default_session_servicedirs (const DBusString *test_base_dir)
|
|||
|
||||
if (test_session_service_dir_matches[i] != NULL)
|
||||
{
|
||||
printf ("extra data %s in the match set was not matched\n",
|
||||
_dbus_test_diag ("extra data %s in the match set was not matched",
|
||||
test_session_service_dir_matches[i]);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -3887,20 +3888,20 @@ test_default_session_servicedirs (const DBusString *test_base_dir)
|
|||
link != NULL;
|
||||
link = _dbus_list_get_next_link (&watched_dirs, link), i++)
|
||||
{
|
||||
printf (" watched service dir: '%s'\n", (const char *) link->data);
|
||||
printf (" current standard service dir: '%s'\n",
|
||||
_dbus_test_diag (" watched service dir: '%s'", (const char *) link->data);
|
||||
_dbus_test_diag (" current standard service dir: '%s'",
|
||||
test_session_service_dir_matches[i]);
|
||||
|
||||
if (test_session_service_dir_matches[i] == NULL)
|
||||
{
|
||||
printf ("more directories parsed than in match set\n");
|
||||
_dbus_test_diag ("more directories parsed than in match set");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strcmp (test_session_service_dir_matches[i],
|
||||
(const char *) link->data) != 0)
|
||||
{
|
||||
printf ("'%s' directory does not match '%s' in the match set\n",
|
||||
_dbus_test_diag ("'%s' directory does not match '%s' in the match set",
|
||||
(const char *) link->data,
|
||||
test_session_service_dir_matches[i]);
|
||||
goto out;
|
||||
|
|
@ -3909,7 +3910,7 @@ test_default_session_servicedirs (const DBusString *test_base_dir)
|
|||
|
||||
if (test_session_service_dir_matches[i] != NULL)
|
||||
{
|
||||
printf ("extra data %s in the match set was not matched\n",
|
||||
_dbus_test_diag ("extra data %s in the match set was not matched",
|
||||
test_session_service_dir_matches[i]);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -3957,10 +3958,10 @@ test_default_system_servicedirs (void)
|
|||
i = 0;
|
||||
while ((link = _dbus_list_pop_first_link (&dirs)))
|
||||
{
|
||||
printf (" test service dir: %s\n", (char *)link->data);
|
||||
_dbus_test_diag (" test service dir: %s", (char *)link->data);
|
||||
if (test_system_service_dir_matches[i] == NULL)
|
||||
{
|
||||
printf ("more directories parsed than in match set\n");
|
||||
_dbus_test_diag ("more directories parsed than in match set");
|
||||
dbus_free (link->data);
|
||||
_dbus_list_free_link (link);
|
||||
return FALSE;
|
||||
|
|
@ -3969,7 +3970,7 @@ test_default_system_servicedirs (void)
|
|||
if (strcmp (test_system_service_dir_matches[i],
|
||||
(char *)link->data) != 0)
|
||||
{
|
||||
printf ("%s directory does not match %s in the match set\n",
|
||||
_dbus_test_diag ("%s directory does not match %s in the match set",
|
||||
(char *)link->data,
|
||||
test_system_service_dir_matches[i]);
|
||||
dbus_free (link->data);
|
||||
|
|
@ -3985,7 +3986,7 @@ test_default_system_servicedirs (void)
|
|||
|
||||
if (test_system_service_dir_matches[i] != NULL)
|
||||
{
|
||||
printf ("extra data %s in the match set was not matched\n",
|
||||
_dbus_test_diag ("extra data %s in the match set was not matched",
|
||||
test_system_service_dir_matches[i]);
|
||||
|
||||
return FALSE;
|
||||
|
|
@ -4001,7 +4002,7 @@ bus_config_parser_test (const DBusString *test_data_dir)
|
|||
if (test_data_dir == NULL ||
|
||||
_dbus_string_get_length (test_data_dir) == 0)
|
||||
{
|
||||
printf ("No test data\n");
|
||||
_dbus_test_diag ("No test data");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -4009,7 +4010,7 @@ bus_config_parser_test (const DBusString *test_data_dir)
|
|||
return FALSE;
|
||||
|
||||
#ifdef DBUS_WIN
|
||||
printf("default system service dir skipped\n");
|
||||
_dbus_test_diag ("default system service dir skipped");
|
||||
#else
|
||||
if (!test_default_system_servicedirs())
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -29,31 +29,22 @@
|
|||
#include <stdlib.h>
|
||||
#include <dbus/dbus-internals.h>
|
||||
#include <dbus/dbus-misc.h>
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
#if !defined(DBUS_ENABLE_EMBEDDED_TESTS) || !defined(DBUS_UNIX)
|
||||
#error This file is only relevant for the embedded tests on Unix
|
||||
#endif
|
||||
|
||||
static void die (const char *failure) _DBUS_GNUC_NORETURN;
|
||||
|
||||
static void
|
||||
die (const char *failure)
|
||||
{
|
||||
fprintf (stderr, "Unit test failed: %s\n", failure);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static void
|
||||
check_memleaks (const char *name)
|
||||
{
|
||||
dbus_shutdown ();
|
||||
|
||||
printf ("%s: checking for memleaks\n", name);
|
||||
|
||||
_dbus_test_diag ("%s: checking for memleaks", name);
|
||||
if (_dbus_get_malloc_blocks_outstanding () != 0)
|
||||
{
|
||||
_dbus_warn ("%d dbus_malloc blocks were not freed",
|
||||
_dbus_get_malloc_blocks_outstanding ());
|
||||
die ("memleaks");
|
||||
_dbus_test_fatal ("%d dbus_malloc blocks were not freed",
|
||||
_dbus_get_malloc_blocks_outstanding ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -110,19 +101,14 @@ main (int argc, char **argv)
|
|||
dir = _dbus_getenv ("DBUS_TEST_DATA");
|
||||
|
||||
if (dir == NULL)
|
||||
{
|
||||
fprintf (stderr, "Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable\n");
|
||||
return 1;
|
||||
}
|
||||
_dbus_test_fatal ("Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable");
|
||||
|
||||
printf ("%s: Running launch helper OOM checks\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Running launch helper OOM checks", argv[0]);
|
||||
|
||||
if (!_dbus_string_init (&config_file))
|
||||
return 1;
|
||||
if (!_dbus_string_append (&config_file, dir))
|
||||
return 1;
|
||||
if (!_dbus_string_append (&config_file, "/valid-config-files-system/debug-allow-all-pass.conf"))
|
||||
return 1;
|
||||
if (!_dbus_string_init (&config_file) ||
|
||||
!_dbus_string_append (&config_file, dir) ||
|
||||
!_dbus_string_append (&config_file, "/valid-config-files-system/debug-allow-all-pass.conf"))
|
||||
_dbus_test_fatal ("OOM during initialization");
|
||||
|
||||
/* use a config file that will actually work... */
|
||||
dbus_setenv ("TEST_LAUNCH_HELPER_CONFIG",
|
||||
|
|
@ -133,11 +119,11 @@ main (int argc, char **argv)
|
|||
if (!_dbus_test_oom_handling ("dbus-daemon-launch-helper",
|
||||
bus_activation_helper_oom_test,
|
||||
(char *) "org.freedesktop.DBus.TestSuiteEchoService"))
|
||||
die ("OOM failed");
|
||||
_dbus_test_fatal ("OOM test failed");
|
||||
|
||||
test_post_hook (argv[0]);
|
||||
|
||||
printf ("%s: Success\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Success", argv[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <dbus/dbus-sysdeps.h>
|
||||
#include <dbus/dbus-internals.h>
|
||||
#include <dbus/dbus-message-internal.h>
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include "selinux.h"
|
||||
|
||||
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
|
|
@ -39,26 +40,16 @@
|
|||
# include <dbus/dbus-sysdeps-unix.h>
|
||||
#endif
|
||||
|
||||
static void die (const char *failure) _DBUS_GNUC_NORETURN;
|
||||
|
||||
static void
|
||||
die (const char *failure)
|
||||
{
|
||||
fprintf (stderr, "Unit test failed: %s\n", failure);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static void
|
||||
check_memleaks (const char *name)
|
||||
{
|
||||
dbus_shutdown ();
|
||||
|
||||
printf ("%s: checking for memleaks\n", name);
|
||||
_dbus_test_diag ("%s: checking for memleaks", name);
|
||||
if (_dbus_get_malloc_blocks_outstanding () != 0)
|
||||
{
|
||||
_dbus_warn ("%d dbus_malloc blocks were not freed",
|
||||
_dbus_get_malloc_blocks_outstanding ());
|
||||
die ("memleaks");
|
||||
_dbus_test_fatal ("%d dbus_malloc blocks were not freed",
|
||||
_dbus_get_malloc_blocks_outstanding ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +62,7 @@ test_pre_hook (void)
|
|||
if (_dbus_getenv ("DBUS_TEST_SELINUX")
|
||||
&& (!bus_selinux_pre_init ()
|
||||
|| !bus_selinux_full_init ()))
|
||||
die ("could not init selinux support");
|
||||
_dbus_test_fatal ("Could not init selinux support");
|
||||
|
||||
initial_fds = _dbus_check_fdleaks_enter ();
|
||||
}
|
||||
|
|
@ -109,10 +100,7 @@ main (int argc, char **argv)
|
|||
only = NULL;
|
||||
|
||||
if (dir == NULL)
|
||||
{
|
||||
fprintf (stderr, "Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable\n");
|
||||
return 1;
|
||||
}
|
||||
_dbus_test_fatal ("Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable");
|
||||
|
||||
_dbus_string_init_const (&test_data_dir, dir);
|
||||
|
||||
|
|
@ -122,59 +110,59 @@ main (int argc, char **argv)
|
|||
#endif
|
||||
|
||||
if (!_dbus_threads_init_debug ())
|
||||
die ("initializing debug threads");
|
||||
_dbus_test_fatal ("OOM initializing debug threads");
|
||||
|
||||
if (only == NULL || strcmp (only, "expire-list") == 0)
|
||||
{
|
||||
test_pre_hook ();
|
||||
printf ("%s: Running expire list test\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Running expire list test", argv[0]);
|
||||
if (!bus_expire_list_test (&test_data_dir))
|
||||
die ("expire list");
|
||||
_dbus_test_fatal ("expire list test failed");
|
||||
test_post_hook ();
|
||||
}
|
||||
|
||||
if (only == NULL || strcmp (only, "config-parser") == 0)
|
||||
{
|
||||
test_pre_hook ();
|
||||
printf ("%s: Running config file parser test\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Running config file parser test", argv[0]);
|
||||
if (!bus_config_parser_test (&test_data_dir))
|
||||
die ("parser");
|
||||
_dbus_test_fatal ("parser test failed");
|
||||
test_post_hook ();
|
||||
}
|
||||
|
||||
if (only == NULL || strcmp (only, "signals") == 0)
|
||||
{
|
||||
test_pre_hook ();
|
||||
printf ("%s: Running signals test\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Running signals test", argv[0]);
|
||||
if (!bus_signals_test (&test_data_dir))
|
||||
die ("signals");
|
||||
_dbus_test_fatal ("signals test failed");
|
||||
test_post_hook ();
|
||||
}
|
||||
|
||||
if (only == NULL || strcmp (only, "dispatch-sha1") == 0)
|
||||
{
|
||||
test_pre_hook ();
|
||||
printf ("%s: Running SHA1 connection test\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Running SHA1 connection test", argv[0]);
|
||||
if (!bus_dispatch_sha1_test (&test_data_dir))
|
||||
die ("sha1");
|
||||
_dbus_test_fatal ("sha1 test failed");
|
||||
test_post_hook ();
|
||||
}
|
||||
|
||||
if (only == NULL || strcmp (only, "dispatch") == 0)
|
||||
{
|
||||
test_pre_hook ();
|
||||
printf ("%s: Running message dispatch test\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Running message dispatch test", argv[0]);
|
||||
if (!bus_dispatch_test (&test_data_dir))
|
||||
die ("dispatch");
|
||||
_dbus_test_fatal ("dispatch test failed");
|
||||
test_post_hook ();
|
||||
}
|
||||
|
||||
if (only == NULL || strcmp (only, "activation-service-reload") == 0)
|
||||
{
|
||||
test_pre_hook ();
|
||||
printf ("%s: Running service files reloading test\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Running service files reloading test", argv[0]);
|
||||
if (!bus_activation_service_reload_test (&test_data_dir))
|
||||
die ("service reload");
|
||||
_dbus_test_fatal ("service reload test failed");
|
||||
test_post_hook ();
|
||||
}
|
||||
|
||||
|
|
@ -182,15 +170,14 @@ main (int argc, char **argv)
|
|||
if (only == NULL || strcmp (only, "unix-fds-passing") == 0)
|
||||
{
|
||||
test_pre_hook ();
|
||||
printf ("%s: Running unix fd passing test\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Running unix fd passing test", argv[0]);
|
||||
if (!bus_unix_fds_passing_test (&test_data_dir))
|
||||
die ("unix fd passing");
|
||||
_dbus_test_fatal ("unix fd passing test failed");
|
||||
test_post_hook ();
|
||||
}
|
||||
#endif
|
||||
|
||||
printf ("%s: Success\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Success", argv[0]);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,31 +28,22 @@
|
|||
#include <dbus/dbus-string.h>
|
||||
#include <dbus/dbus-sysdeps.h>
|
||||
#include <dbus/dbus-internals.h>
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
#if !defined(DBUS_ENABLE_EMBEDDED_TESTS) || !defined(DBUS_UNIX)
|
||||
#error This file is only relevant for the embedded tests on Unix
|
||||
#endif
|
||||
|
||||
static void die (const char *failure) _DBUS_GNUC_NORETURN;
|
||||
|
||||
static void
|
||||
die (const char *failure)
|
||||
{
|
||||
fprintf (stderr, "Unit test failed: %s\n", failure);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static void
|
||||
check_memleaks (const char *name)
|
||||
{
|
||||
dbus_shutdown ();
|
||||
|
||||
printf ("%s: checking for memleaks\n", name);
|
||||
_dbus_test_diag ("%s: checking for memleaks", name);
|
||||
if (_dbus_get_malloc_blocks_outstanding () != 0)
|
||||
{
|
||||
_dbus_warn ("%d dbus_malloc blocks were not freed",
|
||||
_dbus_get_malloc_blocks_outstanding ());
|
||||
die ("memleaks");
|
||||
_dbus_test_fatal ("%d dbus_malloc blocks were not freed",
|
||||
_dbus_get_malloc_blocks_outstanding ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,23 +73,20 @@ main (int argc, char **argv)
|
|||
dir = _dbus_getenv ("DBUS_TEST_DATA");
|
||||
|
||||
if (dir == NULL)
|
||||
{
|
||||
fprintf (stderr, "Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable\n");
|
||||
return 1;
|
||||
}
|
||||
_dbus_test_fatal ("Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable");
|
||||
|
||||
_dbus_string_init_const (&test_data_dir, dir);
|
||||
|
||||
if (!_dbus_threads_init_debug ())
|
||||
die ("initializing debug threads");
|
||||
_dbus_test_fatal ("OOM initializing debug threads");
|
||||
|
||||
test_pre_hook ();
|
||||
printf ("%s: Running config file parser (trivial) test\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Running config file parser (trivial) test", argv[0]);
|
||||
if (!bus_config_parser_trivial_test (&test_data_dir))
|
||||
die ("parser");
|
||||
_dbus_test_fatal ("OOM creating parser");
|
||||
test_post_hook ();
|
||||
|
||||
printf ("%s: Success\n", argv[0]);
|
||||
_dbus_test_diag ("%s: Success", argv[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "dbus-hash.h"
|
||||
#include "dbus-credentials.h"
|
||||
#include "dbus-internals.h"
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
/**
|
||||
* @defgroup DBusAuthScript code for running unit test scripts for DBusAuth
|
||||
|
|
@ -346,7 +347,7 @@ _dbus_auth_script_run (const DBusString *filename)
|
|||
"UNIX_ONLY"))
|
||||
{
|
||||
/* skip this file */
|
||||
fprintf (stderr, "skipping unix only auth script\n");
|
||||
_dbus_test_diag ("skipping unix only auth script");
|
||||
retval = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -362,7 +363,7 @@ _dbus_auth_script_run (const DBusString *filename)
|
|||
"WIN_ONLY"))
|
||||
{
|
||||
/* skip this file */
|
||||
fprintf (stderr, "skipping windows only auth script\n");
|
||||
_dbus_test_diag ("skipping windows only auth script");
|
||||
retval = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "dbus-internals.h"
|
||||
#include "dbus-test.h"
|
||||
#include "dbus-auth.h"
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
/**
|
||||
* @addtogroup DBusAuth
|
||||
|
|
@ -76,8 +77,8 @@ process_test_subdir (const DBusString *test_base_dir,
|
|||
goto failed;
|
||||
}
|
||||
|
||||
printf ("Testing %s:\n", subdir);
|
||||
|
||||
_dbus_test_diag ("Testing %s:", subdir);
|
||||
|
||||
next:
|
||||
while (_dbus_directory_get_next_file (dir, &filename, &error))
|
||||
{
|
||||
|
|
@ -100,8 +101,8 @@ process_test_subdir (const DBusString *test_base_dir,
|
|||
goto next;
|
||||
}
|
||||
|
||||
printf (" %s\n", _dbus_string_get_const_data (&filename));
|
||||
|
||||
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
|
||||
|
||||
if (!_dbus_auth_script_run (&full_path))
|
||||
{
|
||||
_dbus_string_free (&full_path);
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
#include "dbus-hash.h"
|
||||
#include "dbus-internals.h"
|
||||
#include "dbus-mempool.h"
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
/**
|
||||
* @defgroup DBusHashTable Hash table
|
||||
|
|
@ -1608,7 +1609,7 @@ _dbus_hash_test (void)
|
|||
_dbus_assert_not_reached ("no memory");
|
||||
}
|
||||
|
||||
printf ("Computing test hash keys...\n");
|
||||
_dbus_test_diag ("Computing test hash keys...");
|
||||
i = 0;
|
||||
while (i < N_HASH_KEYS)
|
||||
{
|
||||
|
|
@ -1618,8 +1619,8 @@ _dbus_hash_test (void)
|
|||
_dbus_assert (*(keys[i] + len) == '\0');
|
||||
++i;
|
||||
}
|
||||
printf ("... done.\n");
|
||||
|
||||
_dbus_test_diag ("... done.");
|
||||
|
||||
table1 = _dbus_hash_table_new (DBUS_HASH_STRING,
|
||||
dbus_free, dbus_free);
|
||||
if (table1 == NULL)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include <dbus/dbus-string.h>
|
||||
#include <dbus/dbus-list.h>
|
||||
#include <dbus/dbus-sysdeps.h>
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
/**
|
||||
* @defgroup DBusKeyring keyring class
|
||||
|
|
@ -1128,7 +1129,7 @@ _dbus_keyring_test (void)
|
|||
++i;
|
||||
}
|
||||
|
||||
printf (" %d keys in test\n", ring1->n_keys);
|
||||
_dbus_test_diag (" %d keys in test", ring1->n_keys);
|
||||
|
||||
/* Test ref/unref */
|
||||
_dbus_keyring_ref (ring1);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
#include "dbus-marshal-byteswap.h"
|
||||
#include "dbus-test.h"
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void
|
||||
|
|
@ -89,7 +90,7 @@ do_byteswap_test (int byte_order)
|
|||
_dbus_string_free (&signature);
|
||||
_dbus_string_free (&body);
|
||||
|
||||
printf (" %d blocks swapped from order '%c' to '%c'\n",
|
||||
_dbus_test_diag (" %d blocks swapped from order '%c' to '%c'",
|
||||
sequence, byte_order, opposite_order);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "dbus-message-private.h"
|
||||
#include "dbus-signature.h"
|
||||
#include "dbus-test.h"
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef enum
|
||||
|
|
@ -1081,7 +1082,7 @@ generate_typecode_changed (DBusMessageDataIter *iter,
|
|||
_dbus_assert (iter->depth == (base_depth + 0));
|
||||
|
||||
#if 0
|
||||
printf ("Changing byte %d in message %d to %c\n",
|
||||
_dbus_test_diag ("Changing byte %d in message %d to %c",
|
||||
byte_seq, iter_get_sequence (iter), typecodes[typecode_seq]);
|
||||
#endif
|
||||
|
||||
|
|
@ -1199,15 +1200,15 @@ generate_uint32_changed (DBusMessageDataIter *iter,
|
|||
}
|
||||
|
||||
#if 0
|
||||
printf ("body %d change %d pos %d ",
|
||||
_dbus_test_diag ("body %d change %d pos %d ",
|
||||
body_seq, change_seq, byte_seq);
|
||||
|
||||
if (change->type == CHANGE_TYPE_ADJUST)
|
||||
printf ("adjust by %d", (int) change->value);
|
||||
_dbus_test_diag ("adjust by %d", (int) change->value);
|
||||
else
|
||||
printf ("set to %u", change->value);
|
||||
_dbus_test_diag ("set to %u", change->value);
|
||||
|
||||
printf (" \t%u -> %u\n",
|
||||
_dbus_test_diag (" \t%u -> %u",
|
||||
_dbus_marshal_read_uint32 (data, byte_seq, byte_order, NULL),
|
||||
v_UINT32);
|
||||
#endif
|
||||
|
|
@ -1279,8 +1280,7 @@ _dbus_message_data_iter_get_and_next (DBusMessageDataIter *iter,
|
|||
|
||||
if (iter_first_in_series (iter))
|
||||
{
|
||||
printf (" testing message loading: %s ", generators[generator].name);
|
||||
fflush (stdout);
|
||||
_dbus_test_diag (" testing message loading: %s ", generators[generator].name);
|
||||
}
|
||||
|
||||
func = generators[generator].func;
|
||||
|
|
@ -1296,7 +1296,7 @@ _dbus_message_data_iter_get_and_next (DBusMessageDataIter *iter,
|
|||
iter_unrecurse (iter);
|
||||
iter_next (iter); /* next generator */
|
||||
_dbus_string_free (&data->data);
|
||||
printf ("%d test loads cumulative\n", iter->count);
|
||||
_dbus_test_diag ("%d test loads cumulative", iter->count);
|
||||
goto restart;
|
||||
}
|
||||
iter_unrecurse (iter);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#ifdef HAVE_UNIX_FD_PASSING
|
||||
#include "dbus-sysdeps-unix.h"
|
||||
#endif
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
#ifdef __linux__
|
||||
/* Necessary for the Linux-specific fd leak checking code only */
|
||||
|
|
@ -134,7 +135,7 @@ print_validities_seen (dbus_bool_t not_seen)
|
|||
;
|
||||
else if ((not_seen && validities_seen[i] == 0) ||
|
||||
(!not_seen && validities_seen[i] > 0))
|
||||
printf ("validity %3d seen %d times\n",
|
||||
_dbus_test_diag ("validity %3d seen %d times",
|
||||
i - _DBUS_NEGATIVE_VALIDITY_COUNT,
|
||||
validities_seen[i]);
|
||||
++i;
|
||||
|
|
@ -640,7 +641,7 @@ process_test_subdir (const DBusString *test_base_dir,
|
|||
goto failed;
|
||||
}
|
||||
|
||||
printf ("Testing %s:\n", subdir);
|
||||
_dbus_test_diag ("Testing %s:", subdir);
|
||||
|
||||
next:
|
||||
while (_dbus_directory_get_next_file (dir, &filename, &error))
|
||||
|
|
@ -662,7 +663,7 @@ process_test_subdir (const DBusString *test_base_dir,
|
|||
{
|
||||
if (_dbus_string_ends_with_c_str (&filename, ".message"))
|
||||
{
|
||||
printf ("SKIP: Could not load %s, message builder language no longer supported\n",
|
||||
_dbus_test_diag ("SKIP: Could not load %s, message builder language no longer supported",
|
||||
_dbus_string_get_const_data (&filename));
|
||||
}
|
||||
|
||||
|
|
@ -672,7 +673,7 @@ process_test_subdir (const DBusString *test_base_dir,
|
|||
goto next;
|
||||
}
|
||||
|
||||
printf (" %s\n",
|
||||
_dbus_test_diag (" %s",
|
||||
_dbus_string_get_const_data (&filename));
|
||||
|
||||
if (! (*function) (&full_path,
|
||||
|
|
@ -1802,7 +1803,7 @@ _dbus_message_test (const char *test_data_dir)
|
|||
count += 1;
|
||||
}
|
||||
|
||||
printf ("%d sample messages tested\n", count);
|
||||
_dbus_test_diag ("%d sample messages tested", count);
|
||||
|
||||
print_validities_seen (FALSE);
|
||||
print_validities_seen (TRUE);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "dbus-internals.h"
|
||||
#include "dbus-sha.h"
|
||||
#include "dbus-marshal-basic.h" /* for byteswap routines */
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <string.h>
|
||||
|
||||
/* The following comments have the history of where this code
|
||||
|
|
@ -628,7 +629,7 @@ decode_compact_string (const DBusString *line,
|
|||
old_byte |= current_b << bit_containing_next_bit;
|
||||
|
||||
#if 0
|
||||
printf ("Appending bit %d to byte %d at bit %d resulting in byte 0x%x\n",
|
||||
_dbus_test_diag ("Appending bit %d to byte %d at bit %d resulting in byte 0x%x",
|
||||
current_b, byte_containing_next_bit,
|
||||
bit_containing_next_bit, old_byte);
|
||||
#endif
|
||||
|
|
@ -816,7 +817,7 @@ process_test_data (const char *test_data_dir)
|
|||
goto next_iteration;
|
||||
else if (_dbus_string_starts_with_c_str (&line, "H>"))
|
||||
{
|
||||
printf ("SHA-1: %s\n", _dbus_string_get_const_data (&line));
|
||||
_dbus_test_diag ("SHA-1: %s", _dbus_string_get_const_data (&line));
|
||||
|
||||
if (_dbus_string_find (&line, 0, "Type 3", NULL))
|
||||
{
|
||||
|
|
@ -826,7 +827,7 @@ process_test_data (const char *test_data_dir)
|
|||
* to use those tests.
|
||||
*/
|
||||
|
||||
printf (" (ending tests due to Type 3 tests seen - this is normal)\n");
|
||||
_dbus_test_diag (" (ending tests due to Type 3 tests seen - this is normal)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -912,7 +913,7 @@ process_test_data (const char *test_data_dir)
|
|||
|
||||
retval = TRUE;
|
||||
|
||||
printf ("Passed the %d SHA-1 tests in the test file\n",
|
||||
_dbus_test_diag ("Passed the %d SHA-1 tests in the test file",
|
||||
success_count);
|
||||
|
||||
out:
|
||||
|
|
@ -943,7 +944,7 @@ _dbus_sha_test (const char *test_data_dir)
|
|||
return FALSE;
|
||||
}
|
||||
else
|
||||
printf ("No test data dir\n");
|
||||
_dbus_test_diag ("No test data dir");
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "dbus-string.h"
|
||||
#define DBUS_CAN_USE_DBUS_STRING_PRIVATE 1
|
||||
#include "dbus-string-private.h"
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
|
||||
/**
|
||||
* @addtogroup DBusString
|
||||
|
|
@ -155,14 +156,15 @@ test_hex_roundtrip (const char *data,
|
|||
{
|
||||
const char *s;
|
||||
|
||||
printf ("Original string %d bytes encoded %d bytes decoded %d bytes\n",
|
||||
|
||||
_dbus_test_diag ("Original string %d bytes encoded %d bytes decoded %d bytes",
|
||||
_dbus_string_get_length (&orig),
|
||||
_dbus_string_get_length (&encoded),
|
||||
_dbus_string_get_length (&decoded));
|
||||
printf ("Original: %s\n", data);
|
||||
_dbus_test_diag ("Original: %s", data);
|
||||
s = _dbus_string_get_const_data (&decoded);
|
||||
printf ("Decoded: %s\n", s);
|
||||
_dbus_assert_not_reached ("original string not the same as string decoded from hex");
|
||||
_dbus_test_diag ("Decoded: %s", s);
|
||||
_dbus_test_fatal ("original string not the same as string decoded from hex");
|
||||
}
|
||||
|
||||
_dbus_string_free (&orig);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "dbus-test.h"
|
||||
#include "dbus-sysdeps.h"
|
||||
#include "dbus-internals.h"
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
@ -43,7 +44,7 @@ check_memleaks (void)
|
|||
{
|
||||
dbus_shutdown ();
|
||||
|
||||
printf ("%s: checking for memleaks\n", "test-dbus");
|
||||
_dbus_test_diag ("%s: checking for memleaks", "test-dbus");
|
||||
if (_dbus_get_malloc_blocks_outstanding () != 0)
|
||||
{
|
||||
_dbus_warn ("%d dbus_malloc blocks were not freed",
|
||||
|
|
@ -62,7 +63,7 @@ run_test (const char *test_name,
|
|||
{
|
||||
if (!specific_test || strcmp (specific_test, test_name) == 0)
|
||||
{
|
||||
printf ("%s: running %s tests\n", "test-dbus", test_name);
|
||||
_dbus_test_diag ("%s: running %s tests", "test-dbus", test_name);
|
||||
if (!test ())
|
||||
die (test_name);
|
||||
|
||||
|
|
@ -78,7 +79,7 @@ run_data_test (const char *test_name,
|
|||
{
|
||||
if (!specific_test || strcmp (specific_test, test_name) == 0)
|
||||
{
|
||||
printf ("%s: running %s tests\n", "test-dbus", test_name);
|
||||
_dbus_test_diag ("%s: running %s tests", "test-dbus", test_name);
|
||||
if (!test (test_data_dir))
|
||||
die (test_name);
|
||||
|
||||
|
|
@ -106,9 +107,9 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir, const char *speci
|
|||
test_data_dir = _dbus_getenv ("DBUS_TEST_DATA");
|
||||
|
||||
if (test_data_dir != NULL)
|
||||
printf ("Test data in %s\n", test_data_dir);
|
||||
_dbus_test_diag ("Test data in %s", test_data_dir);
|
||||
else
|
||||
printf ("No test data!\n");
|
||||
_dbus_test_diag ("No test data!");
|
||||
|
||||
run_test ("string", specific_test, _dbus_string_test);
|
||||
|
||||
|
|
@ -164,7 +165,7 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir, const char *speci
|
|||
|
||||
run_data_test ("auth", specific_test, _dbus_auth_test, test_data_dir);
|
||||
|
||||
printf ("%s: completed successfully\n", "test-dbus");
|
||||
_dbus_test_diag ("%s: completed successfully", "test-dbus");
|
||||
}
|
||||
|
||||
#endif /* DBUS_ENABLE_EMBEDDED_TESTS */
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "dbus-test.h"
|
||||
#include "dbus-internals.h"
|
||||
#include "dbus-protocol.h"
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
|
|
@ -463,23 +464,21 @@ _dbus_userdb_test (const char *test_data_dir)
|
|||
if (!_dbus_groups_from_uid (uid, &group_ids, &n_group_ids))
|
||||
_dbus_assert_not_reached ("didn't get groups");
|
||||
|
||||
printf (" Current user: %s homedir: %s gids:",
|
||||
_dbus_test_diag (" Current user: %s homedir: %s gids:",
|
||||
_dbus_string_get_const_data (username),
|
||||
_dbus_string_get_const_data (homedir));
|
||||
|
||||
for (i=0; i<n_group_ids; i++)
|
||||
printf(" %ld", group_ids[i]);
|
||||
|
||||
printf ("\n");
|
||||
_dbus_test_diag ("- %ld", group_ids[i]);
|
||||
|
||||
dbus_error_init (&error);
|
||||
printf ("Is Console user: %i\n",
|
||||
_dbus_test_diag ("Is Console user: %i",
|
||||
_dbus_is_console_user (uid, &error));
|
||||
printf ("Invocation was OK: %s\n", error.message ? error.message : "yes");
|
||||
_dbus_test_diag ("Invocation was OK: %s", error.message ? error.message : "yes");
|
||||
dbus_error_free (&error);
|
||||
printf ("Is Console user 4711: %i\n",
|
||||
_dbus_test_diag ("Is Console user 4711: %i",
|
||||
_dbus_is_console_user (4711, &error));
|
||||
printf ("Invocation was OK: %s\n", error.message ? error.message : "yes");
|
||||
_dbus_test_diag ("Invocation was OK: %s", error.message ? error.message : "yes");
|
||||
dbus_error_free (&error);
|
||||
|
||||
dbus_free (group_ids);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue