dbus/dbus dbus-test.h, 1.30, 1.31 dbus-test.c, 1.40,
1.41 dbus-test-main.c, 1.7, 1.8
Colin Walters
walters at freedesktop.org
Mon Feb 21 11:38:08 PST 2005
Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv21523/dbus
Modified Files:
dbus-test.h dbus-test.c dbus-test-main.c
Log Message:
2005-02-21 Colin Walters <walters at verbum.org>
* dbus/dbus-test-main.c (main): Take optional specific test
argument.
* dbus/dbus-test.c (run_test): New function, runs a test function
with no data directory.
(run_data_test): Like above, but takes data directory.
(dbus_internal_do_not_use_run_tests): Take
specific test argument. Replace lots of cut n' paste code
with run_test and run_data_test.
* dbus/dbus-test.h: Update prototype for
dbus_internal_do_not_use_run_tests.
Index: dbus-test.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-test.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- dbus-test.h 27 Jan 2005 23:39:26 -0000 1.30
+++ dbus-test.h 21 Feb 2005 19:38:06 -0000 1.31
@@ -53,7 +53,8 @@
dbus_bool_t _dbus_object_tree_test (void);
dbus_bool_t _dbus_pending_call_test (const char *test_data_dir);
-void dbus_internal_do_not_use_run_tests (const char *test_data_dir);
+void dbus_internal_do_not_use_run_tests (const char *test_data_dir,
+ const char *specific_test);
dbus_bool_t dbus_internal_do_not_use_try_message_file (const DBusString *filename,
DBusValidity expected_validity);
dbus_bool_t dbus_internal_do_not_use_try_message_data (const DBusString *data,
Index: dbus-test.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-test.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- dbus-test.c 11 Feb 2005 01:13:45 -0000 1.40
+++ dbus-test.c 21 Feb 2005 19:38:06 -0000 1.41
@@ -52,6 +52,40 @@
#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
@@ -62,7 +96,7 @@
* @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 ())
@@ -76,47 +110,19 @@
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");
-
- check_memleaks ();
-
- printf ("%s: running server listen tests\n", "dbus-test");
- if (!_dbus_server_test ())
- die ("server listen");
+ run_test ("address", specific_test, _dbus_address_test);
- 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");
-
- check_memleaks ();
+ run_test ("object-tree", specific_test, _dbus_object_tree_test);
- 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");
@@ -128,73 +134,29 @@
_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");
-
- check_memleaks ();
-
- printf ("%s: running validation tests\n", "dbus-test");
- if (!_dbus_marshal_validate_test ())
- die ("validation");
-
- check_memleaks ();
+ run_test ("list", specific_test, _dbus_list_test);
- printf ("%s: running header marshal tests\n", "dbus-test");
- if (!_dbus_marshal_header_test ())
- die ("header marshal");
+ run_test ("marshal-validate", specific_test, _dbus_marshal_validate_test);
- 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");
-
- check_memleaks ();
-
- printf ("%s: running spawn tests\n", "dbus-test");
- if (!_dbus_spawn_test (test_data_dir))
- die ("spawn");
+ run_test ("hash", specific_test, _dbus_hash_test);
- 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");
@@ -204,23 +166,11 @@
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");
-
- check_memleaks ();
-
- printf ("%s: running pending call tests\n", "dbus-test");
- if (!_dbus_pending_call_test (test_data_dir))
- die ("auth");
+ run_data_test ("auth", specific_test, _dbus_auth_test, test_data_dir);
- check_memleaks ();
+ run_data_test ("pending-call", specific_test, _dbus_pending_call_test, test_data_dir);
printf ("%s: completed successfully\n", "dbus-test");
#else
Index: dbus-test-main.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-test-main.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbus-test-main.c 10 Aug 2004 03:07:00 -0000 1.7
+++ dbus-test-main.c 21 Feb 2005 19:38:06 -0000 1.8
@@ -33,6 +33,7 @@
char **argv)
{
const char *test_data_dir;
+ const char *specific_test;
setlocale(LC_ALL, "");
@@ -41,8 +42,13 @@
test_data_dir = argv[1];
else
test_data_dir = NULL;
+
+ if (argc > 2)
+ specific_test = argv[2];
+ else
+ specific_test = NULL;
- dbus_internal_do_not_use_run_tests (test_data_dir);
+ dbus_internal_do_not_use_run_tests (test_data_dir, specific_test);
return 0;
}
More information about the dbus-commit
mailing list