#endif /* DBUS_BUILD_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 || strcmp (specific_test, test_name) == 0)
+ {
+ printf ("%s: running %s tests\n", "dbus-test", test_name);
+ if (!test ())
+ die (test_name);
+ }
+
+ check_memleaks ();
+}
+
+static void
+run_data_test (const char *test_name,
+ const char *specific_test,
+ TestDataFunc test,
+ const char *test_data_dir)
+{
+ if (!specific_test || strcmp (specific_test, test_name) == 0)
+ {
+ printf ("%s: running %s tests\n", "dbus-test", test_name);
+ if (!test (test_data_dir))
+ die (test_name);
+ }
+
+ check_memleaks ();
+}
+
/**
* An exported symbol to be run in order to execute
* unit tests. Should not be used by
* @param test_data_dir the directory with test data (test/data normally)
*/
void
-dbus_internal_do_not_use_run_tests (const char *test_data_dir)
+dbus_internal_do_not_use_run_tests (const char *test_data_dir, const char *specific_test)
{
#ifdef DBUS_BUILD_TESTS
if (!_dbus_threads_init_debug ())
else
printf ("No test data!\n");
- printf ("%s: running string tests\n", "dbus-test");
- if (!_dbus_string_test ())
- die ("strings");
-
- check_memleaks ();
+ run_test ("string", specific_test, _dbus_string_test);
- printf ("%s: running sysdeps tests\n", "dbus-test");
- if (!_dbus_sysdeps_test ())
- die ("sysdeps");
-
- check_memleaks ();
+ run_test ("sysdeps", specific_test, _dbus_sysdeps_test);
- printf ("%s: running data slot tests\n", "dbus-test");
- if (!_dbus_data_slot_test ())
- die ("dataslot");
-
- check_memleaks ();
+ run_test ("data-slot", specific_test, _dbus_data_slot_test);
- printf ("%s: running address parse tests\n", "dbus-test");
- if (!_dbus_address_test ())
- die ("address parsing");
+ run_test ("address", specific_test, _dbus_address_test);
- check_memleaks ();
-
- printf ("%s: running server listen tests\n", "dbus-test");
- if (!_dbus_server_test ())
- die ("server listen");
-
- check_memleaks ();
+ run_test ("server", specific_test, _dbus_server_test);
- printf ("%s: running object tree tests\n", "dbus-test");
- if (!_dbus_object_tree_test ())
- die ("object tree");
+ run_test ("object-tree", specific_test, _dbus_object_tree_test);
- check_memleaks ();
-
- printf ("%s: running marshalling tests\n", "dbus-test");
- if (!_dbus_marshal_test ())
- die ("marshalling");
-
- check_memleaks ();
+ run_test ("marshalling", specific_test, _dbus_marshal_test);
#if 0
printf ("%s: running recursive marshalling tests\n", "dbus-test");
_dbus_warn ("recursive marshal tests disabled\n");
#endif
- printf ("%s: running byteswap tests\n", "dbus-test");
- if (!_dbus_marshal_byteswap_test ())
- die ("byteswap marshaled data");
-
- check_memleaks ();
-
- printf ("%s: running memory tests\n", "dbus-test");
- if (!_dbus_memory_test ())
- die ("memory");
+ run_test ("byteswap", specific_test, _dbus_marshal_byteswap_test);
- check_memleaks ();
+ run_test ("memory", specific_test, _dbus_memory_test);
#if 1
- printf ("%s: running memory pool tests\n", "dbus-test");
- if (!_dbus_mem_pool_test ())
- die ("memory pools");
-
- check_memleaks ();
+ run_test ("mem-pool", specific_test, _dbus_mem_pool_test);
#endif
- printf ("%s: running linked list tests\n", "dbus-test");
- if (!_dbus_list_test ())
- die ("lists");
+ run_test ("list", specific_test, _dbus_list_test);
- check_memleaks ();
+ run_test ("marshal-validate", specific_test, _dbus_marshal_validate_test);
- printf ("%s: running validation tests\n", "dbus-test");
- if (!_dbus_marshal_validate_test ())
- die ("validation");
-
- check_memleaks ();
-
- printf ("%s: running header marshal tests\n", "dbus-test");
- if (!_dbus_marshal_header_test ())
- die ("header marshal");
-
- check_memleaks ();
+ run_test ("marshal-header", specific_test, _dbus_marshal_header_test);
- printf ("%s: running message tests\n", "dbus-test");
- if (!_dbus_message_test (test_data_dir))
- die ("messages");
-
- check_memleaks ();
+ run_data_test ("message", specific_test, _dbus_message_test, test_data_dir);
- printf ("%s: running hash table tests\n", "dbus-test");
- if (!_dbus_hash_test ())
- die ("hash tables");
+ run_test ("hash", specific_test, _dbus_hash_test);
- check_memleaks ();
-
- printf ("%s: running spawn tests\n", "dbus-test");
- if (!_dbus_spawn_test (test_data_dir))
- die ("spawn");
-
- check_memleaks ();
+ run_data_test ("spawn", specific_test, _dbus_spawn_test, test_data_dir);
- printf ("%s: running user database tests\n", "dbus-test");
- if (!_dbus_userdb_test (test_data_dir))
- die ("user database");
-
- check_memleaks ();
+ run_data_test ("userdb", specific_test, _dbus_userdb_test, test_data_dir);
- printf ("%s: running keyring tests\n", "dbus-test");
- if (!_dbus_keyring_test ())
- die ("keyring");
-
- check_memleaks ();
+ run_test ("keyring", specific_test, _dbus_keyring_test);
#if 0
printf ("%s: running md5 tests\n", "dbus-test");
check_memleaks ();
#endif
- printf ("%s: running SHA-1 tests\n", "dbus-test");
- if (!_dbus_sha_test (test_data_dir))
- die ("SHA-1");
-
- check_memleaks ();
+ run_data_test ("sha", specific_test, _dbus_sha_test, test_data_dir);
- printf ("%s: running auth tests\n", "dbus-test");
- if (!_dbus_auth_test (test_data_dir))
- die ("auth");
+ run_data_test ("auth", specific_test, _dbus_auth_test, test_data_dir);
- check_memleaks ();
-
- printf ("%s: running pending call tests\n", "dbus-test");
- if (!_dbus_pending_call_test (test_data_dir))
- die ("auth");
-
- check_memleaks ();
+ run_data_test ("pending-call", specific_test, _dbus_pending_call_test, test_data_dir);
printf ("%s: completed successfully\n", "dbus-test");
#else