mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-04-24 13:50:40 +02:00
Merge branch 'test-main-boilerplate' into 'master'
Consolidate boilerplate from embedded tests' main() See merge request dbus/dbus!73 Reviewed-by: Ralf Habacker
This commit is contained in:
commit
6b71e92fd6
37 changed files with 403 additions and 414 deletions
|
|
@ -2733,12 +2733,15 @@ do_service_reload_test (const DBusString *test_data_dir,
|
|||
}
|
||||
|
||||
dbus_bool_t
|
||||
bus_activation_service_reload_test (const DBusString *test_data_dir)
|
||||
bus_activation_service_reload_test (const char *test_data_dir_cstr)
|
||||
{
|
||||
DBusString test_data_dir;
|
||||
DBusString directory;
|
||||
const char *tmp;
|
||||
dbus_bool_t ret = FALSE;
|
||||
|
||||
_dbus_string_init_const (&test_data_dir, test_data_dir_cstr);
|
||||
|
||||
if (!_dbus_string_init (&directory))
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -2758,7 +2761,7 @@ bus_activation_service_reload_test (const DBusString *test_data_dir)
|
|||
if (!init_service_reload_test (&directory))
|
||||
_dbus_test_fatal ("could not initiate service reload test");
|
||||
|
||||
if (!do_service_reload_test (test_data_dir, &directory, FALSE))
|
||||
if (!do_service_reload_test (&test_data_dir, &directory, FALSE))
|
||||
{
|
||||
/* Do nothing? */
|
||||
}
|
||||
|
|
@ -2770,7 +2773,7 @@ bus_activation_service_reload_test (const DBusString *test_data_dir)
|
|||
if (!init_service_reload_test (&directory))
|
||||
_dbus_test_fatal ("could not initiate service reload test");
|
||||
|
||||
if (!do_service_reload_test (test_data_dir, &directory, TRUE))
|
||||
if (!do_service_reload_test (&test_data_dir, &directory, TRUE))
|
||||
{
|
||||
/* Do nothing? */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -687,36 +687,41 @@ check_file_valid (DBusString *full_path,
|
|||
}
|
||||
|
||||
dbus_bool_t
|
||||
bus_config_parser_trivial_test (const DBusString *test_data_dir)
|
||||
bus_config_parser_trivial_test (const char *test_data_dir_cstr)
|
||||
{
|
||||
DBusString test_data_dir;
|
||||
DBusString full_path;
|
||||
dbus_bool_t retval;
|
||||
|
||||
retval = FALSE;
|
||||
|
||||
if (test_data_dir == NULL ||
|
||||
_dbus_string_get_length (test_data_dir) == 0)
|
||||
if (test_data_dir_cstr == NULL || test_data_dir_cstr[0] == '\0')
|
||||
{
|
||||
_dbus_test_diag ("No test data");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
_dbus_string_init_const (&test_data_dir, test_data_dir_cstr);
|
||||
|
||||
/* We already test default_session_servicedirs and default_system_servicedirs
|
||||
* in bus_config_parser_test() */
|
||||
if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
|
||||
if (!process_test_valid_subdir (&test_data_dir, "valid-config-files",
|
||||
VALID))
|
||||
goto finish;
|
||||
|
||||
#ifndef DBUS_WIN
|
||||
/* We already test default_session_servicedirs and default_system_servicedirs
|
||||
* in bus_config_parser_test() */
|
||||
if (!process_test_valid_subdir (test_data_dir, "valid-config-files-system", VALID))
|
||||
if (!process_test_valid_subdir (&test_data_dir,
|
||||
"valid-config-files-system", VALID))
|
||||
goto finish;
|
||||
#endif
|
||||
|
||||
/* we don't process all the invalid files, as the trivial parser can't hope
|
||||
* to validate them all for all different syntaxes. We just check one broken
|
||||
* file to see if junk is received */
|
||||
if (!make_full_path (test_data_dir, "invalid-config-files", "not-well-formed.conf", &full_path))
|
||||
if (!make_full_path (&test_data_dir, "invalid-config-files",
|
||||
"not-well-formed.conf", &full_path))
|
||||
goto finish;
|
||||
if (!check_file_valid (&full_path, INVALID))
|
||||
goto finish;
|
||||
|
|
@ -724,7 +729,8 @@ bus_config_parser_trivial_test (const DBusString *test_data_dir)
|
|||
|
||||
#ifndef DBUS_WIN
|
||||
/* just test if the check_file_valid works okay and we got sane values */
|
||||
if (!make_full_path (test_data_dir, "valid-config-files-system", "system.conf", &full_path))
|
||||
if (!make_full_path (&test_data_dir, "valid-config-files-system",
|
||||
"system.conf", &full_path))
|
||||
goto finish;
|
||||
if (!check_file_valid (&full_path, VALID))
|
||||
goto finish;
|
||||
|
|
|
|||
|
|
@ -3990,16 +3990,19 @@ test_default_system_servicedirs (void)
|
|||
#endif
|
||||
|
||||
dbus_bool_t
|
||||
bus_config_parser_test (const DBusString *test_data_dir)
|
||||
bus_config_parser_test (const char *test_data_dir_cstr)
|
||||
{
|
||||
if (test_data_dir == NULL ||
|
||||
_dbus_string_get_length (test_data_dir) == 0)
|
||||
DBusString test_data_dir;
|
||||
|
||||
if (test_data_dir_cstr == NULL || test_data_dir_cstr[0] == '\0')
|
||||
{
|
||||
_dbus_test_diag ("No test data");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!test_default_session_servicedirs (test_data_dir))
|
||||
_dbus_string_init_const (&test_data_dir, test_data_dir_cstr);
|
||||
|
||||
if (!test_default_session_servicedirs (&test_data_dir))
|
||||
return FALSE;
|
||||
|
||||
#ifdef DBUS_WIN
|
||||
|
|
@ -4009,18 +4012,21 @@ bus_config_parser_test (const DBusString *test_data_dir)
|
|||
return FALSE;
|
||||
#endif
|
||||
|
||||
if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
|
||||
if (!process_test_valid_subdir (&test_data_dir, "valid-config-files",
|
||||
VALID))
|
||||
return FALSE;
|
||||
|
||||
#ifndef DBUS_WIN
|
||||
if (!process_test_valid_subdir (test_data_dir, "valid-config-files-system", VALID))
|
||||
if (!process_test_valid_subdir (&test_data_dir,
|
||||
"valid-config-files-system", VALID))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
if (!process_test_valid_subdir (test_data_dir, "invalid-config-files", INVALID))
|
||||
if (!process_test_valid_subdir (&test_data_dir, "invalid-config-files",
|
||||
INVALID))
|
||||
return FALSE;
|
||||
|
||||
if (!process_test_equiv_subdir (test_data_dir, "equiv-config-files"))
|
||||
if (!process_test_equiv_subdir (&test_data_dir, "equiv-config-files"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -5023,23 +5023,27 @@ bus_dispatch_test_conf_fail (const DBusString *test_data_dir,
|
|||
#endif
|
||||
|
||||
dbus_bool_t
|
||||
bus_dispatch_test (const DBusString *test_data_dir)
|
||||
bus_dispatch_test (const char *test_data_dir_cstr)
|
||||
{
|
||||
DBusString test_data_dir;
|
||||
|
||||
_dbus_string_init_const (&test_data_dir, test_data_dir_cstr);
|
||||
|
||||
/* run normal activation tests */
|
||||
_dbus_verbose ("Normal activation tests\n");
|
||||
if (!bus_dispatch_test_conf (test_data_dir,
|
||||
if (!bus_dispatch_test_conf (&test_data_dir,
|
||||
"valid-config-files/debug-allow-all.conf", FALSE))
|
||||
return FALSE;
|
||||
|
||||
#ifndef DBUS_WIN
|
||||
/* run launch-helper activation tests */
|
||||
_dbus_verbose ("Launch helper activation tests\n");
|
||||
if (!bus_dispatch_test_conf (test_data_dir,
|
||||
if (!bus_dispatch_test_conf (&test_data_dir,
|
||||
"valid-config-files-system/debug-allow-all-pass.conf", TRUE))
|
||||
return FALSE;
|
||||
|
||||
/* run select launch-helper activation tests on broken service files */
|
||||
if (!bus_dispatch_test_conf_fail (test_data_dir,
|
||||
if (!bus_dispatch_test_conf_fail (&test_data_dir,
|
||||
"valid-config-files-system/debug-allow-all-fail.conf"))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
|
@ -5048,18 +5052,20 @@ bus_dispatch_test (const DBusString *test_data_dir)
|
|||
}
|
||||
|
||||
dbus_bool_t
|
||||
bus_dispatch_sha1_test (const DBusString *test_data_dir)
|
||||
bus_dispatch_sha1_test (const char *test_data_dir_cstr)
|
||||
{
|
||||
DBusString test_data_dir;
|
||||
BusContext *context;
|
||||
DBusConnection *foo;
|
||||
DBusError error;
|
||||
|
||||
_dbus_string_init_const (&test_data_dir, test_data_dir_cstr);
|
||||
dbus_error_init (&error);
|
||||
|
||||
/* Test SHA1 authentication */
|
||||
_dbus_verbose ("Testing SHA1 context\n");
|
||||
|
||||
context = bus_context_new_test (test_data_dir,
|
||||
context = bus_context_new_test (&test_data_dir,
|
||||
"valid-config-files/debug-allow-all-sha1.conf");
|
||||
if (context == NULL)
|
||||
return FALSE;
|
||||
|
|
@ -5092,11 +5098,11 @@ bus_dispatch_sha1_test (const DBusString *test_data_dir)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_UNIX_FD_PASSING
|
||||
|
||||
dbus_bool_t
|
||||
bus_unix_fds_passing_test(const DBusString *test_data_dir)
|
||||
bus_unix_fds_passing_test (const char *test_data_dir_cstr)
|
||||
{
|
||||
#ifdef HAVE_UNIX_FD_PASSING
|
||||
DBusString test_data_dir;
|
||||
BusContext *context;
|
||||
DBusConnection *foo, *bar;
|
||||
DBusError error;
|
||||
|
|
@ -5105,9 +5111,11 @@ bus_unix_fds_passing_test(const DBusString *test_data_dir)
|
|||
int x, y, z;
|
||||
char r;
|
||||
|
||||
_dbus_string_init_const (&test_data_dir, test_data_dir_cstr);
|
||||
dbus_error_init (&error);
|
||||
|
||||
context = bus_context_new_test (test_data_dir, "valid-config-files/debug-allow-all.conf");
|
||||
context = bus_context_new_test (&test_data_dir,
|
||||
"valid-config-files/debug-allow-all.conf");
|
||||
if (context == NULL)
|
||||
_dbus_test_fatal ("could not alloc context");
|
||||
|
||||
|
|
@ -5239,8 +5247,10 @@ bus_unix_fds_passing_test(const DBusString *test_data_dir)
|
|||
|
||||
bus_context_unref (context);
|
||||
|
||||
#else
|
||||
_dbus_test_skip ("fd-passing not supported on this platform");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DBUS_ENABLE_EMBEDDED_TESTS */
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ time_add_milliseconds (long *tv_sec,
|
|||
}
|
||||
|
||||
dbus_bool_t
|
||||
bus_expire_list_test (const DBusString *test_data_dir)
|
||||
bus_expire_list_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusLoop *loop;
|
||||
BusExpireList *list;
|
||||
|
|
|
|||
|
|
@ -2963,7 +2963,7 @@ test_matching_path_namespace (void)
|
|||
}
|
||||
|
||||
dbus_bool_t
|
||||
bus_signals_test (const DBusString *test_data_dir)
|
||||
bus_signals_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
BusMatchmaker *matchmaker;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,11 +25,9 @@
|
|||
#include "test.h"
|
||||
#include "activation-helper.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dbus/dbus-internals.h>
|
||||
#include <dbus/dbus-misc.h>
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <dbus/dbus-test-wrappers.h>
|
||||
|
||||
#if !defined(DBUS_ENABLE_EMBEDDED_TESTS) || !defined(DBUS_UNIX)
|
||||
#error This file is only relevant for the embedded tests on Unix
|
||||
|
|
@ -72,24 +70,13 @@ bus_activation_helper_oom_test (void *data,
|
|||
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
static dbus_bool_t
|
||||
bus_activation_helper_test (const char *test_data_dir)
|
||||
{
|
||||
const char *dir;
|
||||
DBusString config_file;
|
||||
|
||||
if (argc > 1 && strcmp (argv[1], "--tap") != 0)
|
||||
dir = argv[1];
|
||||
else
|
||||
dir = _dbus_getenv ("DBUS_TEST_DATA");
|
||||
|
||||
if (dir == NULL)
|
||||
_dbus_test_fatal ("Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable");
|
||||
|
||||
_dbus_test_diag ("%s: Running launch helper OOM checks", argv[0]);
|
||||
|
||||
if (!_dbus_string_init (&config_file) ||
|
||||
!_dbus_string_append (&config_file, dir) ||
|
||||
!_dbus_string_append (&config_file, test_data_dir) ||
|
||||
!_dbus_string_append (&config_file, "/valid-config-files-system/debug-allow-all-pass.conf"))
|
||||
_dbus_test_fatal ("OOM during initialization");
|
||||
|
||||
|
|
@ -105,9 +92,20 @@ main (int argc, char **argv)
|
|||
_dbus_test_fatal ("OOM test failed");
|
||||
|
||||
/* ... otherwise it must have passed */
|
||||
_dbus_test_ok ("%s", argv[0]);
|
||||
|
||||
_dbus_test_check_memleaks (argv[0]);
|
||||
|
||||
return _dbus_test_done_testing ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static DBusTestCase test =
|
||||
{
|
||||
"activation-helper",
|
||||
bus_activation_helper_test,
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
return _dbus_test_main (argc, argv, 1, &test,
|
||||
(DBUS_TEST_FLAGS_REQUIRE_DATA |
|
||||
DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS),
|
||||
NULL, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,104 +22,48 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "test.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dbus/dbus-string.h>
|
||||
#include <dbus/dbus-sysdeps.h>
|
||||
#include <dbus/dbus-internals.h>
|
||||
#include <dbus/dbus-message-internal.h>
|
||||
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <dbus/dbus-test-wrappers.h>
|
||||
|
||||
#include "selinux.h"
|
||||
|
||||
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
#error This file is only relevant for the embedded tests
|
||||
#endif
|
||||
|
||||
#ifdef DBUS_UNIX
|
||||
# include <dbus/dbus-sysdeps-unix.h>
|
||||
#endif
|
||||
|
||||
static const char *only;
|
||||
static DBusInitialFDs *initial_fds = NULL;
|
||||
static DBusString test_data_dir;
|
||||
|
||||
static void
|
||||
test_pre_hook (void)
|
||||
{
|
||||
initial_fds = _dbus_check_fdleaks_enter ();
|
||||
}
|
||||
|
||||
static void
|
||||
test_post_hook (const char *name)
|
||||
test_post_hook (void)
|
||||
{
|
||||
if (_dbus_getenv ("DBUS_TEST_SELINUX"))
|
||||
bus_selinux_shutdown ();
|
||||
|
||||
_dbus_test_check_memleaks (name);
|
||||
_dbus_check_fdleaks_leave (initial_fds);
|
||||
initial_fds = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
test_one (const char *name,
|
||||
dbus_bool_t (*func) (const DBusString *))
|
||||
static DBusTestCase tests[] =
|
||||
{
|
||||
if (only != NULL && strcmp (only, name) != 0)
|
||||
{
|
||||
_dbus_test_skip ("%s - Only intending to run %s", name, only);
|
||||
return;
|
||||
}
|
||||
|
||||
_dbus_test_diag ("Running test: %s", name);
|
||||
|
||||
test_pre_hook ();
|
||||
|
||||
if (func (&test_data_dir))
|
||||
_dbus_test_ok ("%s", name);
|
||||
else
|
||||
_dbus_test_not_ok ("%s", name);
|
||||
|
||||
test_post_hook (name);
|
||||
}
|
||||
{ "expire-list", bus_expire_list_test },
|
||||
{ "config-parser", bus_config_parser_test },
|
||||
{ "signals", bus_signals_test },
|
||||
{ "dispatch-sha1", bus_dispatch_sha1_test },
|
||||
{ "dispatch", bus_dispatch_test },
|
||||
{ "activation-service-reload", bus_activation_service_reload_test },
|
||||
{ "unix-fds-passing", bus_unix_fds_passing_test },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
const char *dir;
|
||||
|
||||
if (argc > 1 && strcmp (argv[1], "--tap") != 0)
|
||||
dir = argv[1];
|
||||
else
|
||||
dir = _dbus_getenv ("DBUS_TEST_DATA");
|
||||
|
||||
if (argc > 2)
|
||||
only = argv[2];
|
||||
else
|
||||
only = _dbus_getenv ("DBUS_TEST_ONLY");
|
||||
|
||||
if (dir == NULL)
|
||||
_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);
|
||||
|
||||
#ifdef DBUS_UNIX
|
||||
/* close any inherited fds so dbus-spawn's check for close-on-exec works */
|
||||
_dbus_close_all ();
|
||||
#endif
|
||||
|
||||
test_one ("expire-list", bus_expire_list_test);
|
||||
test_one ("config-parser", bus_config_parser_test);
|
||||
test_one ("signals", bus_signals_test);
|
||||
test_one ("dispatch-sha1", bus_dispatch_sha1_test);
|
||||
test_one ("dispatch", bus_dispatch_test);
|
||||
test_one ("activation-service-reload", bus_activation_service_reload_test);
|
||||
|
||||
#ifdef HAVE_UNIX_FD_PASSING
|
||||
test_one ("unix-fds-passing", bus_unix_fds_passing_test);
|
||||
#else
|
||||
_dbus_test_skip ("fd-passing not supported on this platform");
|
||||
#endif
|
||||
|
||||
return _dbus_test_done_testing ();
|
||||
return _dbus_test_main (argc, argv, _DBUS_N_ELEMENTS (tests), tests,
|
||||
(DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
|
||||
DBUS_TEST_FLAGS_CHECK_FD_LEAKS |
|
||||
DBUS_TEST_FLAGS_REQUIRE_DATA),
|
||||
test_pre_hook, test_post_hook);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,56 +22,27 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "test.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dbus/dbus-string.h>
|
||||
#include <dbus/dbus-sysdeps.h>
|
||||
#include <dbus/dbus-internals.h>
|
||||
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <dbus/dbus-test-wrappers.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
|
||||
test_pre_hook (void)
|
||||
static DBusTestCase test =
|
||||
{
|
||||
}
|
||||
|
||||
static const char *progname = "";
|
||||
static void
|
||||
test_post_hook (void)
|
||||
{
|
||||
_dbus_test_check_memleaks (progname);
|
||||
}
|
||||
"config-parser-trivial",
|
||||
bus_config_parser_trivial_test
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
const char *dir;
|
||||
DBusString test_data_dir;
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
if (argc > 1 && strcmp (argv[1], "--tap") != 0)
|
||||
dir = argv[1];
|
||||
else
|
||||
dir = _dbus_getenv ("DBUS_TEST_DATA");
|
||||
|
||||
if (dir == NULL)
|
||||
_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);
|
||||
|
||||
test_pre_hook ();
|
||||
_dbus_test_diag ("%s: Running config file parser (trivial) test", argv[0]);
|
||||
if (!bus_config_parser_trivial_test (&test_data_dir))
|
||||
_dbus_test_fatal ("OOM creating parser");
|
||||
|
||||
/* All failure modes for this test are currently fatal */
|
||||
_dbus_test_ok ("%s", argv[0]);
|
||||
test_post_hook ();
|
||||
|
||||
return _dbus_test_done_testing ();
|
||||
return _dbus_test_main (argc, argv, 1, &test,
|
||||
(DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS |
|
||||
DBUS_TEST_FLAGS_REQUIRE_DATA),
|
||||
NULL, NULL);
|
||||
}
|
||||
|
|
|
|||
19
bus/test.h
19
bus/test.h
|
|
@ -33,13 +33,13 @@
|
|||
typedef dbus_bool_t (* BusConnectionForeachFunction) (DBusConnection *connection,
|
||||
void *data);
|
||||
|
||||
dbus_bool_t bus_dispatch_test (const DBusString *test_data_dir);
|
||||
dbus_bool_t bus_dispatch_sha1_test (const DBusString *test_data_dir);
|
||||
dbus_bool_t bus_config_parser_test (const DBusString *test_data_dir);
|
||||
dbus_bool_t bus_config_parser_trivial_test (const DBusString *test_data_dir);
|
||||
dbus_bool_t bus_signals_test (const DBusString *test_data_dir);
|
||||
dbus_bool_t bus_expire_list_test (const DBusString *test_data_dir);
|
||||
dbus_bool_t bus_activation_service_reload_test (const DBusString *test_data_dir);
|
||||
dbus_bool_t bus_dispatch_test (const char *test_data_dir_cstr);
|
||||
dbus_bool_t bus_dispatch_sha1_test (const char *test_data_dir_cstr);
|
||||
dbus_bool_t bus_config_parser_test (const char *test_data_dir_cstr);
|
||||
dbus_bool_t bus_config_parser_trivial_test (const char *test_data_dir_cstr);
|
||||
dbus_bool_t bus_signals_test (const char *test_data_dir);
|
||||
dbus_bool_t bus_expire_list_test (const char *test_data_dir);
|
||||
dbus_bool_t bus_activation_service_reload_test (const char *test_data_dir_cstr);
|
||||
dbus_bool_t bus_setup_debug_client (DBusConnection *connection);
|
||||
void bus_test_clients_foreach (BusConnectionForeachFunction function,
|
||||
void *data);
|
||||
|
|
@ -50,10 +50,7 @@ void bus_test_run_clients_loop (dbus_bool_t block);
|
|||
void bus_test_run_everything (BusContext *context);
|
||||
BusContext* bus_context_new_test (const DBusString *test_data_dir,
|
||||
const char *filename);
|
||||
|
||||
#ifdef HAVE_UNIX_FD_PASSING
|
||||
dbus_bool_t bus_unix_fds_passing_test (const DBusString *test_data_dir);
|
||||
#endif
|
||||
dbus_bool_t bus_unix_fds_passing_test (const char *test_data_dir_cstr);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -171,8 +171,8 @@ set (DBUS_UTIL_SOURCES
|
|||
if (DBUS_ENABLE_EMBEDDED_TESTS)
|
||||
set (DBUS_UTIL_SOURCES
|
||||
${DBUS_UTIL_SOURCES}
|
||||
${DBUS_DIR}/dbus-test.c
|
||||
${DBUS_DIR}/dbus-spawn-test.c
|
||||
${DBUS_DIR}/dbus-test-wrappers.c
|
||||
)
|
||||
endif (DBUS_ENABLE_EMBEDDED_TESTS)
|
||||
|
||||
|
|
@ -185,6 +185,7 @@ set (DBUS_UTIL_HEADERS
|
|||
${DBUS_DIR}/dbus-socket-set.h
|
||||
${DBUS_DIR}/dbus-spawn.h
|
||||
${DBUS_DIR}/dbus-test.h
|
||||
${DBUS_DIR}/dbus-test-wrappers.h
|
||||
)
|
||||
|
||||
### platform specific settings
|
||||
|
|
|
|||
|
|
@ -266,11 +266,14 @@ DBUS_UTIL_SOURCES= \
|
|||
dbus-spawn.h \
|
||||
dbus-string-util.c \
|
||||
dbus-sysdeps-util.c \
|
||||
dbus-test.c \
|
||||
dbus-test.h
|
||||
|
||||
if DBUS_ENABLE_EMBEDDED_TESTS
|
||||
DBUS_UTIL_SOURCES += dbus-spawn-test.c
|
||||
DBUS_UTIL_SOURCES += \
|
||||
dbus-spawn-test.c \
|
||||
dbus-test-wrappers.c \
|
||||
dbus-test-wrappers.h \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
libdbus_1_la_SOURCES= \
|
||||
|
|
|
|||
|
|
@ -698,7 +698,7 @@ static const char* invalid_escaped_values[] = {
|
|||
};
|
||||
|
||||
dbus_bool_t
|
||||
_dbus_address_test (void)
|
||||
_dbus_address_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusAddressEntry **entries;
|
||||
int len;
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ test_free_slot_data_func (void *data)
|
|||
* Test function for data slots
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_data_slot_test (void)
|
||||
_dbus_data_slot_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusDataSlotAllocator allocator;
|
||||
DBusDataSlotList list;
|
||||
|
|
|
|||
|
|
@ -1631,7 +1631,7 @@ steal (void *ptr)
|
|||
* @returns #TRUE on success.
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_hash_test (void)
|
||||
_dbus_hash_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
int i;
|
||||
DBusHashTable *table1;
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ _dbus_keyring_get_hex_key (DBusKeyring *keyring,
|
|||
#include <stdio.h>
|
||||
|
||||
dbus_bool_t
|
||||
_dbus_keyring_test (void)
|
||||
_dbus_keyring_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusString context;
|
||||
DBusKeyring *ring1;
|
||||
|
|
|
|||
|
|
@ -972,7 +972,7 @@ lists_equal (DBusList **list1,
|
|||
* @returns #TRUE on success.
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_list_test (void)
|
||||
_dbus_list_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusList *list1;
|
||||
DBusList *list2;
|
||||
|
|
|
|||
|
|
@ -1663,7 +1663,7 @@ swap_test_array (void *array,
|
|||
} while (0)
|
||||
|
||||
dbus_bool_t
|
||||
_dbus_marshal_test (void)
|
||||
_dbus_marshal_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
int alignment;
|
||||
DBusString str;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ do_byteswap_test (int byte_order)
|
|||
}
|
||||
|
||||
dbus_bool_t
|
||||
_dbus_marshal_byteswap_test (void)
|
||||
_dbus_marshal_byteswap_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
do_byteswap_test (DBUS_LITTLE_ENDIAN);
|
||||
do_byteswap_test (DBUS_BIG_ENDIAN);
|
||||
|
|
|
|||
|
|
@ -2041,7 +2041,7 @@ out:
|
|||
}
|
||||
|
||||
dbus_bool_t
|
||||
_dbus_marshal_recursive_test (void)
|
||||
_dbus_marshal_recursive_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
make_and_run_test_nodes ();
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ static const ValidityTest signature_tests[] = {
|
|||
};
|
||||
|
||||
dbus_bool_t
|
||||
_dbus_marshal_validate_test (void)
|
||||
_dbus_marshal_validate_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusString str;
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
#ifndef DBUS_MARSHAL_VALIDATE_H
|
||||
#define DBUS_MARSHAL_VALIDATE_H
|
||||
|
||||
#include <dbus/dbus-string.h>
|
||||
|
||||
/**
|
||||
* @addtogroup DBusMarshal
|
||||
*
|
||||
|
|
|
|||
|
|
@ -930,7 +930,7 @@ dbus_shutdown (void)
|
|||
* @returns #TRUE on success.
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_memory_test (void)
|
||||
_dbus_memory_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
dbus_bool_t old_guards;
|
||||
void *p;
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@ time_for_size (int size)
|
|||
* @returns #TRUE on success.
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_mem_pool_test (void)
|
||||
_dbus_mem_pool_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
int i;
|
||||
int element_sizes[] = { 4, 8, 16, 50, 124 };
|
||||
|
|
|
|||
|
|
@ -1187,7 +1187,7 @@ verify_test_message_memleak (DBusMessage *message)
|
|||
* @returns #TRUE on success.
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_message_test (const char *test_data_dir)
|
||||
_dbus_message_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusMessage *message, *message_without_unix_fds;
|
||||
DBusMessageLoader *loader;
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ dbus_get_version (int *major_version_p,
|
|||
|
||||
|
||||
dbus_bool_t
|
||||
_dbus_misc_test (void)
|
||||
_dbus_misc_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
int major, minor, micro;
|
||||
DBusString str;
|
||||
|
|
|
|||
|
|
@ -2319,7 +2319,7 @@ object_tree_test_iteration (void *data,
|
|||
* @returns #TRUE on success.
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_object_tree_test (void)
|
||||
_dbus_object_tree_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
return _dbus_test_oom_handling ("object tree",
|
||||
object_tree_test_iteration,
|
||||
|
|
|
|||
|
|
@ -1199,7 +1199,7 @@ dbus_server_get_data (DBusServer *server,
|
|||
#include <string.h>
|
||||
|
||||
dbus_bool_t
|
||||
_dbus_server_test (void)
|
||||
_dbus_server_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
const char *valid_addresses[] = {
|
||||
"tcp:port=1234",
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ dbus_type_is_valid (int typecode)
|
|||
* @returns #TRUE on success.
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_signature_test (void)
|
||||
_dbus_signature_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusSignatureIter iter;
|
||||
DBusSignatureIter subiter;
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ _DBUS_STRING_DEFINE_STATIC (test_static_string, "hello");
|
|||
* @returns #TRUE on success.
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_string_test (void)
|
||||
_dbus_string_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusString str = _DBUS_STRING_INIT_INVALID;
|
||||
DBusString other;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ check_path_absolute (const char *path,
|
|||
* @returns #TRUE on success.
|
||||
*/
|
||||
dbus_bool_t
|
||||
_dbus_sysdeps_test (void)
|
||||
_dbus_sysdeps_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
#ifdef DBUS_WIN
|
||||
check_dirname ("foo\\bar", "foo");
|
||||
|
|
|
|||
|
|
@ -21,48 +21,53 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "dbus-types.h"
|
||||
|
||||
#include "dbus-internals.h"
|
||||
#include "dbus-test.h"
|
||||
#include "dbus-test-tap.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#include "dbus-test-wrappers.h"
|
||||
|
||||
static DBusTestCase tests[] =
|
||||
{
|
||||
{ "string", _dbus_string_test },
|
||||
{ "sysdeps", _dbus_sysdeps_test },
|
||||
{ "data-slot", _dbus_data_slot_test },
|
||||
{ "misc", _dbus_misc_test },
|
||||
{ "address", _dbus_address_test },
|
||||
{ "server", _dbus_server_test },
|
||||
{ "object-tree", _dbus_object_tree_test },
|
||||
{ "signature", _dbus_signature_test },
|
||||
{ "marshalling", _dbus_marshal_test },
|
||||
{ "marshal-recursive" , _dbus_marshal_recursive_test },
|
||||
{ "byteswap", _dbus_marshal_byteswap_test },
|
||||
{ "memory", _dbus_memory_test },
|
||||
{ "mem-pool", _dbus_mem_pool_test },
|
||||
{ "list", _dbus_list_test },
|
||||
{ "marshal-validate", _dbus_marshal_validate_test },
|
||||
{ "message", _dbus_message_test },
|
||||
{ "hash", _dbus_hash_test },
|
||||
{ "credentials", _dbus_credentials_test },
|
||||
{ "keyring", _dbus_keyring_test },
|
||||
{ "sha", _dbus_sha_test },
|
||||
{ "auth", _dbus_auth_test },
|
||||
|
||||
#if defined(DBUS_UNIX)
|
||||
{ "userdb", _dbus_userdb_test },
|
||||
{ "transport-unix", _dbus_transport_unix_test },
|
||||
#endif
|
||||
|
||||
#ifdef DBUS_UNIX
|
||||
# include <dbus/dbus-sysdeps-unix.h>
|
||||
#if !defined(DBUS_WINCE)
|
||||
{ "spawn", _dbus_spawn_test },
|
||||
#endif
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
const char *test_data_dir;
|
||||
const char *specific_test;
|
||||
|
||||
#ifdef DBUS_UNIX
|
||||
/* close any inherited fds so dbus-spawn's check for close-on-exec works */
|
||||
_dbus_close_all ();
|
||||
#endif
|
||||
|
||||
#if HAVE_SETLOCALE
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
|
||||
if (argc > 1 && strcmp (argv[1], "--tap") != 0)
|
||||
test_data_dir = argv[1];
|
||||
else
|
||||
test_data_dir = NULL;
|
||||
|
||||
if (argc > 2)
|
||||
specific_test = argv[2];
|
||||
else
|
||||
specific_test = _dbus_getenv ("DBUS_TEST_ONLY");
|
||||
|
||||
_dbus_run_tests (test_data_dir, specific_test);
|
||||
return _dbus_test_done_testing ();
|
||||
return _dbus_test_main (argc, argv, _DBUS_N_ELEMENTS (tests), tests,
|
||||
DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
|
|
|||
147
dbus/dbus-test-wrappers.c
Normal file
147
dbus/dbus-test-wrappers.c
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* Copyright 2002-2009 Red Hat Inc.
|
||||
* Copyright 2011-2018 Collabora Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "dbus/dbus-test-wrappers.h"
|
||||
|
||||
#ifndef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
#error This file is only relevant for the embedded tests
|
||||
#endif
|
||||
|
||||
#include "dbus/dbus-message-internal.h"
|
||||
#include "dbus/dbus-test-tap.h"
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#ifdef DBUS_UNIX
|
||||
# include <dbus/dbus-sysdeps-unix.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* _dbus_test_main:
|
||||
* @argc: number of command-line arguments
|
||||
* @argv: array of @argc arguments
|
||||
* @n_tests: length of @tests
|
||||
* @tests: array of @n_tests tests
|
||||
* @flags: flags affecting all tests
|
||||
* @test_pre_hook: if not %NULL, called before each test
|
||||
* @test_post_hook: if not %NULL, called after each test
|
||||
*
|
||||
* Wrapper for dbus tests that do not use GLib. Processing of @tests
|
||||
* can be terminated early by an entry with @name = NULL, which is a
|
||||
* convenient way to put a trailing comma on every "real" test entry
|
||||
* without breaking compilation on pedantic C compilers.
|
||||
*/
|
||||
int
|
||||
_dbus_test_main (int argc,
|
||||
char **argv,
|
||||
size_t n_tests,
|
||||
const DBusTestCase *tests,
|
||||
DBusTestFlags flags,
|
||||
void (*test_pre_hook) (void),
|
||||
void (*test_post_hook) (void))
|
||||
{
|
||||
const char *test_data_dir;
|
||||
const char *specific_test;
|
||||
size_t i;
|
||||
|
||||
#ifdef DBUS_UNIX
|
||||
/* close any inherited fds so dbus-spawn's check for close-on-exec works */
|
||||
_dbus_close_all ();
|
||||
#endif
|
||||
|
||||
#if HAVE_SETLOCALE
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
|
||||
if (argc > 1 && strcmp (argv[1], "--tap") != 0)
|
||||
test_data_dir = argv[1];
|
||||
else
|
||||
test_data_dir = _dbus_getenv ("DBUS_TEST_DATA");
|
||||
|
||||
if (test_data_dir != NULL)
|
||||
_dbus_test_diag ("Test data in %s", test_data_dir);
|
||||
else if (flags & DBUS_TEST_FLAGS_REQUIRE_DATA)
|
||||
_dbus_test_fatal ("Must specify test data directory as argv[1] or "
|
||||
"in DBUS_TEST_DATA environment variable");
|
||||
else
|
||||
_dbus_test_diag ("No test data!");
|
||||
|
||||
if (argc > 2)
|
||||
specific_test = argv[2];
|
||||
else
|
||||
specific_test = _dbus_getenv ("DBUS_TEST_ONLY");
|
||||
|
||||
for (i = 0; i < n_tests; i++)
|
||||
{
|
||||
long before, after;
|
||||
DBusInitialFDs *initial_fds = NULL;
|
||||
|
||||
if (tests[i].name == NULL)
|
||||
break;
|
||||
|
||||
if (n_tests > 1 &&
|
||||
specific_test != NULL &&
|
||||
strcmp (specific_test, tests[i].name) != 0)
|
||||
{
|
||||
_dbus_test_skip ("%s - Only intending to run %s",
|
||||
tests[i].name, specific_test);
|
||||
continue;
|
||||
}
|
||||
|
||||
_dbus_test_diag ("Running test: %s", tests[i].name);
|
||||
_dbus_get_monotonic_time (&before, NULL);
|
||||
|
||||
if (test_pre_hook)
|
||||
test_pre_hook ();
|
||||
|
||||
if (flags & DBUS_TEST_FLAGS_CHECK_FD_LEAKS)
|
||||
initial_fds = _dbus_check_fdleaks_enter ();
|
||||
|
||||
if (tests[i].func (test_data_dir))
|
||||
_dbus_test_ok ("%s", tests[i].name);
|
||||
else
|
||||
_dbus_test_not_ok ("%s", tests[i].name);
|
||||
|
||||
_dbus_get_monotonic_time (&after, NULL);
|
||||
|
||||
_dbus_test_diag ("%s test took %ld seconds",
|
||||
tests[i].name, after - before);
|
||||
|
||||
if (test_post_hook)
|
||||
test_post_hook ();
|
||||
|
||||
if (flags & DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS)
|
||||
_dbus_test_check_memleaks (tests[i].name);
|
||||
|
||||
if (flags & DBUS_TEST_FLAGS_CHECK_FD_LEAKS)
|
||||
_dbus_check_fdleaks_leave (initial_fds);
|
||||
}
|
||||
|
||||
return _dbus_test_done_testing ();
|
||||
}
|
||||
55
dbus/dbus-test-wrappers.h
Normal file
55
dbus/dbus-test-wrappers.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/*
|
||||
* Copyright © 2017 Collabora Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef DBUS_TEST_WRAPPERS_H
|
||||
#define DBUS_TEST_WRAPPERS_H
|
||||
|
||||
#include <dbus/dbus-types.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
dbus_bool_t (*func) (const char *test_data_dir);
|
||||
} DBusTestCase;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DBUS_TEST_FLAGS_REQUIRE_DATA = (1 << 0),
|
||||
DBUS_TEST_FLAGS_CHECK_MEMORY_LEAKS = (1 << 1),
|
||||
DBUS_TEST_FLAGS_CHECK_FD_LEAKS = (1 << 2),
|
||||
DBUS_TEST_FLAGS_NONE = 0
|
||||
} DBusTestFlags;
|
||||
|
||||
int _dbus_test_main (int argc,
|
||||
char **argv,
|
||||
size_t n_tests,
|
||||
const DBusTestCase *tests,
|
||||
DBusTestFlags flags,
|
||||
void (*test_pre_hook) (void),
|
||||
void (*test_post_hook) (void));
|
||||
|
||||
#endif
|
||||
156
dbus/dbus-test.c
156
dbus/dbus-test.c
|
|
@ -1,156 +0,0 @@
|
|||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
/* dbus-test.c Program to run all tests
|
||||
*
|
||||
* Copyright (C) 2002, 2003, 2004, 2005 Red Hat Inc.
|
||||
*
|
||||
* Licensed under the Academic Free License version 2.1
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "dbus-test.h"
|
||||
#include "dbus-sysdeps.h"
|
||||
#include "dbus-internals.h"
|
||||
#include <dbus/dbus-test-tap.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
typedef dbus_bool_t (*TestFunc)(void);
|
||||
typedef dbus_bool_t (*TestDataFunc)(const char *data);
|
||||
|
||||
static void
|
||||
run_test (const char *test_name,
|
||||
const char *specific_test,
|
||||
TestFunc test)
|
||||
{
|
||||
if (specific_test != NULL && strcmp (specific_test, test_name) != 0)
|
||||
{
|
||||
_dbus_test_skip ("%s - Only intending to run %s", test_name, specific_test);
|
||||
return;
|
||||
}
|
||||
|
||||
_dbus_test_diag ("%s: running %s tests", "test-dbus", test_name);
|
||||
|
||||
if (test ())
|
||||
_dbus_test_ok ("%s", test_name);
|
||||
else
|
||||
_dbus_test_not_ok ("%s", test_name);
|
||||
|
||||
_dbus_test_check_memleaks (test_name);
|
||||
}
|
||||
|
||||
static void
|
||||
run_data_test (const char *test_name,
|
||||
const char *specific_test,
|
||||
TestDataFunc test,
|
||||
const char *test_data_dir)
|
||||
{
|
||||
if (specific_test != NULL && strcmp (specific_test, test_name) != 0)
|
||||
{
|
||||
_dbus_test_skip ("%s - Only intending to run %s", test_name, specific_test);
|
||||
return;
|
||||
}
|
||||
|
||||
_dbus_test_diag ("%s: running %s tests", "test-dbus", test_name);
|
||||
|
||||
if (test (test_data_dir))
|
||||
_dbus_test_ok ("%s", test_name);
|
||||
else
|
||||
_dbus_test_not_ok ("%s", test_name);
|
||||
|
||||
_dbus_test_check_memleaks (test_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* An exported symbol to be run in order to execute
|
||||
* unit tests. Should not be used by
|
||||
* any app other than our test app, this symbol
|
||||
* won't exist in some builds of the library.
|
||||
* (with --enable-tests=no)
|
||||
*
|
||||
* @param test_data_dir the directory with test data (test/data normally)
|
||||
* @param specific_test run specific test or #NULL to run all tests
|
||||
*/
|
||||
void
|
||||
_dbus_run_tests (const char *test_data_dir,
|
||||
const char *specific_test)
|
||||
{
|
||||
if (test_data_dir == NULL)
|
||||
test_data_dir = _dbus_getenv ("DBUS_TEST_DATA");
|
||||
|
||||
if (test_data_dir != NULL)
|
||||
_dbus_test_diag ("Test data in %s", test_data_dir);
|
||||
else
|
||||
_dbus_test_diag ("No test data!");
|
||||
|
||||
run_test ("string", specific_test, _dbus_string_test);
|
||||
|
||||
run_test ("sysdeps", specific_test, _dbus_sysdeps_test);
|
||||
|
||||
run_test ("data-slot", specific_test, _dbus_data_slot_test);
|
||||
|
||||
run_test ("misc", specific_test, _dbus_misc_test);
|
||||
|
||||
run_test ("address", specific_test, _dbus_address_test);
|
||||
|
||||
run_test ("server", specific_test, _dbus_server_test);
|
||||
|
||||
run_test ("object-tree", specific_test, _dbus_object_tree_test);
|
||||
|
||||
run_test ("signature", specific_test, _dbus_signature_test);
|
||||
|
||||
run_test ("marshalling", specific_test, _dbus_marshal_test);
|
||||
|
||||
run_test ("marshal-recursive", specific_test, _dbus_marshal_recursive_test);
|
||||
|
||||
run_test ("byteswap", specific_test, _dbus_marshal_byteswap_test);
|
||||
|
||||
run_test ("memory", specific_test, _dbus_memory_test);
|
||||
|
||||
#if 1
|
||||
run_test ("mem-pool", specific_test, _dbus_mem_pool_test);
|
||||
#endif
|
||||
|
||||
run_test ("list", specific_test, _dbus_list_test);
|
||||
|
||||
run_test ("marshal-validate", specific_test, _dbus_marshal_validate_test);
|
||||
|
||||
run_data_test ("message", specific_test, _dbus_message_test, test_data_dir);
|
||||
|
||||
run_test ("hash", specific_test, _dbus_hash_test);
|
||||
|
||||
#if !defined(DBUS_WINCE)
|
||||
run_data_test ("spawn", specific_test, _dbus_spawn_test, test_data_dir);
|
||||
#endif
|
||||
|
||||
run_data_test ("credentials", specific_test, _dbus_credentials_test, test_data_dir);
|
||||
|
||||
#ifdef DBUS_UNIX
|
||||
run_data_test ("userdb", specific_test, _dbus_userdb_test, test_data_dir);
|
||||
|
||||
run_test ("transport-unix", specific_test, _dbus_transport_unix_test);
|
||||
#endif
|
||||
|
||||
run_test ("keyring", specific_test, _dbus_keyring_test);
|
||||
|
||||
run_data_test ("sha", specific_test, _dbus_sha_test, test_data_dir);
|
||||
|
||||
run_data_test ("auth", specific_test, _dbus_auth_test, test_data_dir);
|
||||
}
|
||||
|
||||
#endif /* DBUS_ENABLE_EMBEDDED_TESTS */
|
||||
|
|
@ -38,34 +38,34 @@
|
|||
*/
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_hash_test (void);
|
||||
dbus_bool_t _dbus_hash_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_list_test (void);
|
||||
dbus_bool_t _dbus_list_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_marshal_test (void);
|
||||
dbus_bool_t _dbus_marshal_test (const char *test_data_dir);
|
||||
|
||||
dbus_bool_t _dbus_marshal_recursive_test (void);
|
||||
dbus_bool_t _dbus_marshal_byteswap_test (void);
|
||||
dbus_bool_t _dbus_marshal_validate_test (void);
|
||||
dbus_bool_t _dbus_marshal_recursive_test (const char *test_data_dir);
|
||||
dbus_bool_t _dbus_marshal_byteswap_test (const char *test_data_dir);
|
||||
dbus_bool_t _dbus_marshal_validate_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_misc_test (void);
|
||||
dbus_bool_t _dbus_misc_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_signature_test (void);
|
||||
dbus_bool_t _dbus_signature_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_mem_pool_test (void);
|
||||
dbus_bool_t _dbus_mem_pool_test (const char *test_data_dir);
|
||||
|
||||
dbus_bool_t _dbus_string_test (void);
|
||||
dbus_bool_t _dbus_string_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_address_test (void);
|
||||
dbus_bool_t _dbus_address_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_server_test (void);
|
||||
dbus_bool_t _dbus_server_test (const char *test_data_dir);
|
||||
|
||||
dbus_bool_t _dbus_message_test (const char *test_data_dir);
|
||||
dbus_bool_t _dbus_auth_test (const char *test_data_dir);
|
||||
|
|
@ -74,31 +74,28 @@ DBUS_PRIVATE_EXPORT
|
|||
dbus_bool_t _dbus_sha_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_keyring_test (void);
|
||||
dbus_bool_t _dbus_keyring_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_data_slot_test (void);
|
||||
dbus_bool_t _dbus_data_slot_test (const char *test_data_dir);
|
||||
|
||||
dbus_bool_t _dbus_sysdeps_test (void);
|
||||
dbus_bool_t _dbus_sysdeps_test (const char *test_data_dir);
|
||||
dbus_bool_t _dbus_spawn_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_userdb_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_transport_unix_test (void);
|
||||
dbus_bool_t _dbus_transport_unix_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_memory_test (void);
|
||||
dbus_bool_t _dbus_memory_test (const char *test_data_dir);
|
||||
|
||||
DBUS_PRIVATE_EXPORT
|
||||
dbus_bool_t _dbus_object_tree_test (void);
|
||||
dbus_bool_t _dbus_object_tree_test (const char *test_data_dir);
|
||||
|
||||
dbus_bool_t _dbus_credentials_test (const char *test_data_dir);
|
||||
|
||||
void _dbus_run_tests (const char *test_data_dir,
|
||||
const char *specific_test);
|
||||
|
||||
dbus_bool_t _dbus_test_generate_bodies (int sequence,
|
||||
int byte_order,
|
||||
DBusString *signature,
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry,
|
|||
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
|
||||
|
||||
dbus_bool_t
|
||||
_dbus_transport_unix_test (void)
|
||||
_dbus_transport_unix_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
|
||||
{
|
||||
DBusConnection *c;
|
||||
DBusError error;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue