summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2016-02-08 20:28:21 +0000
committerRalf Habacker <ralf.habacker@freenet.de>2016-02-11 02:37:14 +0100
commitfec99c9b3d8318e3abae432f2aca50802a87f90e (patch)
tree1c2b5f8ac1525653ce8e7d72d13e0bf9190aca42
parent8fd2be6013e3d0ff6a6ff63ea022f9606d9a87c6 (diff)
downloaddbus-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>
-rw-r--r--test/name-test/test-ids.c28
-rw-r--r--test/name-test/test-pending-call-dispatch.c13
-rw-r--r--test/name-test/test-pending-call-timeout.c11
-rw-r--r--test/name-test/test-privserver-client.c10
-rw-r--r--test/name-test/test-privserver.c2
-rw-r--r--test/name-test/test-shutdown.c11
-rw-r--r--test/name-test/test-threads-init.c7
7 files changed, 57 insertions, 25 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;
}
diff --git a/test/name-test/test-pending-call-dispatch.c b/test/name-test/test-pending-call-dispatch.c
index c8b5a467..7785564d 100644
--- a/test/name-test/test-pending-call-dispatch.c
+++ b/test/name-test/test-pending-call-dispatch.c
@@ -56,13 +56,13 @@ _run_iteration (DBusConnection *conn)
if (reply == NULL)
{
- printf ("Failed: Reply is NULL ***\n");
+ printf ("Bail out! Reply is NULL ***\n");
exit (1);
}
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
{
- printf ("Failed: Reply is error: %s ***\n", dbus_message_get_error_name (reply));
+ printf ("Bail out! Reply is error: %s ***\n", dbus_message_get_error_name (reply));
exit (1);
}
@@ -72,6 +72,7 @@ _run_iteration (DBusConnection *conn)
}
+/* This test outputs TAP syntax: http://testanything.org/ */
int
main (int argc, char *argv[])
{
@@ -87,7 +88,7 @@ main (int argc, char *argv[])
but if it does and we are stuck in a poll call then we know the
stuck in poll bug has come back to haunt us */
- printf ("*** Testing stuck in poll\n");
+ printf ("# Testing stuck in poll\n");
dbus_error_init (&error);
@@ -104,10 +105,10 @@ main (int argc, char *argv[])
/* we just care about seconds */
delta = end_tv_sec - start_tv_sec;
- printf ("Iter %i: %lis\n", i, delta);
+ printf ("ok %d - %lis\n", i + 1, delta);
if (delta >= 5)
{
- printf ("Failed: looks like we might have been be stuck in poll ***\n");
+ printf ("Bail out! Looks like we might have been be stuck in poll ***\n");
exit (1);
}
}
@@ -119,6 +120,6 @@ main (int argc, char *argv[])
dbus_connection_send (conn, method, NULL);
dbus_message_unref (method);
- printf ("Success ***\n");
+ printf ("# Testing completed\n1..%d\n", i);
exit (0);
}
diff --git a/test/name-test/test-pending-call-timeout.c b/test/name-test/test-pending-call-timeout.c
index d051faba..be6b849c 100644
--- a/test/name-test/test-pending-call-timeout.c
+++ b/test/name-test/test-pending-call-timeout.c
@@ -39,13 +39,13 @@ _method_call (DBusConnection *conn,
if (reply == NULL)
{
- printf ("Failed: Reply is NULL ***\n");
+ printf ("Bail out! Reply is NULL ***\n");
exit (1);
}
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
{
- printf ("Failed: Reply is error: %s ***\n", dbus_message_get_error_name (reply));
+ printf ("Bail out! Reply is error: %s ***\n", dbus_message_get_error_name (reply));
exit (1);
}
@@ -61,6 +61,7 @@ _run_iteration (DBusConnection *conn)
_method_call (conn, INT_MAX);
}
+/* This test outputs TAP syntax: http://testanything.org/ */
int
main (int argc, char *argv[])
{
@@ -71,7 +72,7 @@ main (int argc, char *argv[])
DBusConnection *conn;
DBusError error;
- printf ("*** Testing pending call timeouts\n");
+ printf ("# Testing pending call timeouts\n");
dbus_error_init (&error);
@@ -88,7 +89,7 @@ main (int argc, char *argv[])
/* we just care about seconds */
delta = end_tv_sec - start_tv_sec;
- printf ("Iter %i: %lis\n", i, delta);
+ printf ("ok %d - %lis\n", i + 1, delta);
}
method = dbus_message_new_method_call ("org.freedesktop.TestSuiteEchoService",
@@ -98,6 +99,6 @@ main (int argc, char *argv[])
dbus_connection_send (conn, method, NULL);
dbus_message_unref (method);
- printf ("Success ***\n");
+ printf ("# Testing completed\n1..%d\n", i);
exit (0);
}
diff --git a/test/name-test/test-privserver-client.c b/test/name-test/test-privserver-client.c
index e7f48960..56b553c0 100644
--- a/test/name-test/test-privserver-client.c
+++ b/test/name-test/test-privserver-client.c
@@ -102,7 +102,7 @@ open_shutdown_private_connection (dbus_bool_t use_guid)
dbus_message_unref (msg);
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &addr, DBUS_TYPE_INVALID))
die ("couldn't parse message replym\n");
- printf ("got private temp address %s\n", addr);
+ printf ("# got private temp address %s\n", addr);
addr = strdup (addr);
if (!use_guid)
{
@@ -145,24 +145,32 @@ open_shutdown_private_connection (dbus_bool_t use_guid)
_dbus_loop_unref (loop);
}
+/* This test outputs TAP syntax: http://testanything.org/ */
int
main (int argc, char *argv[])
{
+ int test_num = 0;
+
open_shutdown_private_connection (TRUE);
dbus_shutdown ();
+ printf ("ok %d\n", ++test_num);
open_shutdown_private_connection (TRUE);
dbus_shutdown ();
+ printf ("ok %d\n", ++test_num);
open_shutdown_private_connection (FALSE);
dbus_shutdown ();
+ printf ("ok %d\n", ++test_num);
open_shutdown_private_connection (FALSE);
dbus_shutdown ();
+ printf ("ok %d\n", ++test_num);
+ printf ("1..%d\n", test_num);
return 0;
}
diff --git a/test/name-test/test-privserver.c b/test/name-test/test-privserver.c
index 39a98b7f..367c8090 100644
--- a/test/name-test/test-privserver.c
+++ b/test/name-test/test-privserver.c
@@ -97,7 +97,7 @@ main (int argc, char *argv[])
if (!server)
die (error.message);
testdata->private_addr = dbus_server_get_address (server);
- printf ("test server listening on %s\n", testdata->private_addr);
+ fprintf (stderr, "test server listening on %s\n", testdata->private_addr);
dbus_server_set_new_connection_function (server, new_connection_callback,
testdata, NULL);
diff --git a/test/name-test/test-shutdown.c b/test/name-test/test-shutdown.c
index 526c1cbc..39612f18 100644
--- a/test/name-test/test-shutdown.c
+++ b/test/name-test/test-shutdown.c
@@ -7,7 +7,7 @@ static DBusLoop *loop;
static void
die (const char *message)
{
- fprintf (stderr, "*** test-shutdown: %s", message);
+ printf ("Bail out! test-shutdown: %s", message);
exit (1);
}
@@ -46,23 +46,28 @@ open_destroy_shared_session_bus_connection (void)
dbus_connection_unref (connection);
}
+/* This test outputs TAP syntax: http://testanything.org/ */
int
main (int argc,
char **argv)
{
+ int test_num = 0;
+
open_destroy_shared_session_bus_connection ();
dbus_shutdown ();
+ printf ("ok %d\n", ++test_num);
open_destroy_shared_session_bus_connection ();
dbus_shutdown ();
+ printf ("ok %d\n", ++test_num);
open_destroy_shared_session_bus_connection ();
dbus_shutdown ();
+ printf ("ok %d\n", ++test_num);
- _dbus_verbose ("*** Test shutdown exiting\n");
-
+ printf ("1..%d\n", test_num);
return 0;
}
diff --git a/test/name-test/test-threads-init.c b/test/name-test/test-threads-init.c
index a517e2a2..62857158 100644
--- a/test/name-test/test-threads-init.c
+++ b/test/name-test/test-threads-init.c
@@ -105,7 +105,7 @@ check_condvar_lock (DBusCondVar *condvar1,
}
}
-
+/* This test outputs TAP syntax: http://testanything.org/ */
int
main (int argc, char *argv[])
{
@@ -116,6 +116,7 @@ main (int argc, char *argv[])
DBusCondVar *dispatch_cond1, *io_path_cond1;
DBusMutex *mutex2, *dispatch_mutex2, *io_path_mutex2;
DBusCondVar *dispatch_cond2, *io_path_cond2;
+ int test_num = 0;
printf ("*** Testing late thread init\n");
@@ -140,6 +141,7 @@ main (int argc, char *argv[])
check_mutex_lock (io_path_mutex1, io_path_mutex2, TRUE);
check_condvar_lock (dispatch_cond1, dispatch_cond2, TRUE);
check_condvar_lock (io_path_cond1, io_path_cond2, TRUE);
+ printf ("ok %d\n", ++test_num);
dbus_threads_init_default ();
@@ -161,6 +163,7 @@ main (int argc, char *argv[])
check_mutex_lock (io_path_mutex1, io_path_mutex2, TRUE);
check_condvar_lock (dispatch_cond1, dispatch_cond2, TRUE);
check_condvar_lock (io_path_cond1, io_path_cond2, TRUE);
+ printf ("ok %d\n", ++test_num);
method = dbus_message_new_method_call ("org.freedesktop.TestSuiteEchoService",
"/org/freedesktop/TestSuite",
@@ -169,6 +172,6 @@ main (int argc, char *argv[])
dbus_connection_send (conn, method, NULL);
dbus_message_unref (method);
- printf ("Success ***\n");
+ printf ("Testing completed\n1..%d\n", test_num);
exit (0);
}