-/* -*- mode: C; c-file-style: "gnu" -*- */
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-test.c Program to run all tests
*
- * Copyright (C) 2002, 2003 Red Hat Inc.
+ * Copyright (C) 2002, 2003, 2004, 2005 Red Hat Inc.
*
- * Licensed under the Academic Free License version 1.2
+ * Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
}
}
+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 ();
+ }
+}
+
#endif /* DBUS_BUILD_TESTS */
/**
* @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 ())
+ die ("debug threads init");
+
if (test_data_dir == NULL)
test_data_dir = _dbus_getenv ("DBUS_TEST_DATA");
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);
+
+ run_test ("sysdeps", specific_test, _dbus_sysdeps_test);
+
+ run_test ("data-slot", specific_test, _dbus_data_slot_test);
- printf ("%s: running sysdeps tests\n", "dbus-test");
- if (!_dbus_sysdeps_test ())
- die ("sysdeps");
+ run_test ("misc", specific_test, _dbus_misc_test);
+
+ run_test ("address", specific_test, _dbus_address_test);
- check_memleaks ();
+ run_test ("server", specific_test, _dbus_server_test);
- printf ("%s: running spawn tests\n", "dbus-test");
- if (!_dbus_spawn_test (test_data_dir))
- die ("spawn");
+ run_test ("object-tree", specific_test, _dbus_object_tree_test);
- check_memleaks ();
+ run_test ("signature", specific_test, _dbus_signature_test);
- printf ("%s: running data slot tests\n", "dbus-test");
- if (!_dbus_data_slot_test ())
- die ("dataslot");
+ run_test ("marshalling", specific_test, _dbus_marshal_test);
- check_memleaks ();
-
- printf ("%s: running keyring tests\n", "dbus-test");
- if (!_dbus_keyring_test ())
- die ("keyring");
+ run_test ("marshal-recursive", specific_test, _dbus_marshal_recursive_test);
- check_memleaks ();
+ run_test ("byteswap", specific_test, _dbus_marshal_byteswap_test);
-#if 0
- printf ("%s: running md5 tests\n", "dbus-test");
- if (!_dbus_md5_test ())
- die ("md5");
+ run_test ("memory", specific_test, _dbus_memory_test);
- check_memleaks ();
+#if 1
+ run_test ("mem-pool", specific_test, _dbus_mem_pool_test);
#endif
- printf ("%s: running SHA-1 tests\n", "dbus-test");
- if (!_dbus_sha_test (test_data_dir))
- die ("SHA-1");
-
- check_memleaks ();
-
- printf ("%s: running auth tests\n", "dbus-test");
- if (!_dbus_auth_test (test_data_dir))
- die ("auth");
+ run_test ("list", specific_test, _dbus_list_test);
- check_memleaks ();
-
- printf ("%s: running address parse tests\n", "dbus-test");
- if (!_dbus_address_test ())
- die ("address parsing");
+ run_test ("marshal-validate", specific_test, _dbus_marshal_validate_test);
- check_memleaks ();
+ run_data_test ("message", specific_test, _dbus_message_test, test_data_dir);
- printf ("%s: running marshalling tests\n", "dbus-test");
- if (!_dbus_marshal_test ())
- die ("marshalling");
+ run_test ("hash", specific_test, _dbus_hash_test);
- check_memleaks ();
-
- printf ("%s: running message tests\n", "dbus-test");
- if (!_dbus_message_test (test_data_dir))
- die ("messages");
-
- check_memleaks ();
+#if !defined(DBUS_WINCE)
+ run_data_test ("spawn", specific_test, _dbus_spawn_test, test_data_dir);
+#endif
- printf ("%s: running memory pool tests\n", "dbus-test");
- if (!_dbus_mem_pool_test ())
- die ("memory pools");
+ run_data_test ("credentials", specific_test, _dbus_credentials_test, test_data_dir);
- check_memleaks ();
-
- printf ("%s: running linked list tests\n", "dbus-test");
- if (!_dbus_list_test ())
- die ("lists");
+#ifdef DBUS_UNIX
+ run_data_test ("userdb", specific_test, _dbus_userdb_test, test_data_dir);
- check_memleaks ();
+ run_test ("transport-unix", specific_test, _dbus_transport_unix_test);
+#endif
- printf ("%s: running hash table tests\n", "dbus-test");
- if (!_dbus_hash_test ())
- die ("hash tables");
+ run_test ("keyring", specific_test, _dbus_keyring_test);
- check_memleaks ();
+ run_data_test ("sha", specific_test, _dbus_sha_test, test_data_dir);
- printf ("%s: running dict tests\n", "dbus-test");
- if (!_dbus_dict_test ())
- die ("dicts");
+ run_data_test ("auth", specific_test, _dbus_auth_test, test_data_dir);
- check_memleaks ();
-
printf ("%s: completed successfully\n", "dbus-test");
#else
printf ("Not compiled with unit tests, not running any\n");
#endif
}
-