diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2016-02-08 20:28:21 +0000 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2016-02-11 02:37:14 +0100 |
commit | fec99c9b3d8318e3abae432f2aca50802a87f90e (patch) | |
tree | 1c2b5f8ac1525653ce8e7d72d13e0bf9190aca42 /test/name-test/test-ids.c | |
parent | 8fd2be6013e3d0ff6a6ff63ea022f9606d9a87c6 (diff) | |
download | dbus-fec99c9b3d8318e3abae432f2aca50802a87f90e.tar.gz |
name-test C tests: produce structured (TAP) output
Similar to commit 58eefa1031e14cb402ed0aae85e6bce1ba030a28.
test-privserver is a helper executable, not a test. I moved its output
from stdout to stderr so it can't be misinterpreted as the test's
stdout.
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92899
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Diffstat (limited to 'test/name-test/test-ids.c')
-rw-r--r-- | test/name-test/test-ids.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/test/name-test/test-ids.c b/test/name-test/test-ids.c index 8f63d044..f73a505f 100644 --- a/test/name-test/test-ids.c +++ b/test/name-test/test-ids.c @@ -11,10 +11,13 @@ static void die (const char *message) { - fprintf (stderr, "*** test-ids: %s", message); + printf ("Bail out! test-ids: %s\n", message); exit (1); } +static int test_num = 0; + +/* This test outputs TAP syntax: http://testanything.org/ */ int main (int argc, char **argv) @@ -23,7 +26,7 @@ main (int argc, DBusConnection *connection; char *id; char *server_id; - + dbus_error_init (&error); connection = dbus_bus_get (DBUS_BUS_SESSION, &error); if (connection == NULL) @@ -33,24 +36,35 @@ main (int argc, dbus_error_free (&error); return 1; } + printf ("ok %d - connected to session bus\n", ++test_num); server_id = dbus_connection_get_server_id (connection); + if (server_id == NULL) die ("No bus server ID retrieved\n"); - /* printf("'%s'\n", server_id); */ + + printf ("ok %d - session bus server ID is %s\n", ++test_num, server_id); + if (strlen (server_id) != 32) die ("Bus server id should have length 32\n"); + + printf ("ok %d - session bus server ID length is 32\n", ++test_num); + dbus_free (server_id); id = dbus_bus_get_id (connection, NULL); if (id == NULL) die ("No bus ID retrieved\n"); - /* printf("'%s'\n", id); */ + + printf ("ok %d - session bus ID is %s\n", ++test_num, id); + if (strlen (id) != 32) die ("Bus ID should have length 32\n"); + + printf ("ok %d - session bus ID length is 32\n", ++test_num); + dbus_free (id); - - _dbus_verbose ("*** Test IDs exiting\n"); - + + printf ("1..%d\n", test_num); return 0; } |