2005-02-21 Colin Walters <walters@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.
This commit is contained in:
Colin Walters 2005-02-21 19:38:06 +00:00
parent 209a5011f7
commit f9a7bcc2fc
4 changed files with 80 additions and 108 deletions

View file

@ -1,3 +1,18 @@
2005-02-21 Colin Walters <walters@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.
2005-02-20 Havoc Pennington <hp@redhat.com>
Fix bugs reported by Daniel P. Berrange

View file

@ -33,6 +33,7 @@ main (int argc,
char **argv)
{
const char *test_data_dir;
const char *specific_test;
setlocale(LC_ALL, "");
@ -41,8 +42,13 @@ main (int argc,
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;
}

View file

@ -52,6 +52,40 @@ check_memleaks (void)
#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 @@ check_memleaks (void)
* @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 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir)
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 ();
run_test ("server", specific_test, _dbus_server_test);
printf ("%s: running server listen tests\n", "dbus-test");
if (!_dbus_server_test ())
die ("server listen");
check_memleaks ();
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");
@ -128,73 +134,29 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir)
_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 ();
run_test ("byteswap", specific_test, _dbus_marshal_byteswap_test);
printf ("%s: running memory tests\n", "dbus-test");
if (!_dbus_memory_test ())
die ("memory");
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");
@ -204,23 +166,11 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir)
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

View file

@ -53,7 +53,8 @@ dbus_bool_t _dbus_memory_test (void);
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,