summaryrefslogtreecommitdiff
path: root/bus/test-system.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2017-11-14 14:09:59 +0000
committerSimon McVittie <smcv@collabora.com>2017-11-15 12:11:54 +0000
commited40af9284b4ea658b8b7debfa42530a1c28bbf1 (patch)
treedd2b770ecec0a6437808ecc1fd7ce4efc6d24e5c /bus/test-system.c
parent5ffb709b42783b0d13a49b8c9a84c75f556c88a2 (diff)
downloaddbus-ed40af9284b4ea658b8b7debfa42530a1c28bbf1.tar.gz
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
Diffstat (limited to 'bus/test-system.c')
-rw-r--r--bus/test-system.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/bus/test-system.c b/bus/test-system.c
index de1f003b..a434b6fa 100644
--- a/bus/test-system.c
+++ b/bus/test-system.c
@@ -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;
}