+2006-08-19 Aaron Bockover <abockover@novell.com>
+
+ * test/driver.c: Added --debug mode that allows for testing all paths
+ of the driver without actually running real tests; runs only the 'fake'
+ test, which does nothing; useful for running the driver through valgrind
+
+ * test/Makefile.am:
+ * test/tests.h:
+ * test/fake.c: Added fake test for valgrinding the driver
+
+ * test/ptrarray.c: update sort test
+
2006-08-19 Aaron Bockover <abockover@novell.com>
* test/test-both: added --help
slist.c \
sizes.c \
ptrarray.c \
- list.c
+ list.c \
+ fake.c
test_eglib_SOURCES = $(SOURCES)
test_glib_SOURCES = $(SOURCES)
printf(" -i, --iterations number of times to run tests\n");
printf(" -q, --quiet do not print test results; "
"final time always prints\n");
- printf(" -n print final time without labels, "
- "nice for scripts\n\n");
+ printf(" -n, --no-labels print final time without labels, "
+ "nice for scripts\n");
+ printf(" -d, --debug do not run tests, "
+ "debug the driver itself for valgrind\n\n");
printf("TESTGROUPS available:\n");
for(i = 0; test_groups[i].name != NULL; i++) {
- printf(" %s\n", test_groups[i].name);
+ if(test_groups[i].handler != fake_tests_init) {
+ printf(" %s\n", test_groups[i].name);
+ }
}
printf("\n");
gboolean quiet = FALSE;
gboolean global_failure = FALSE;
gboolean no_final_time_labels = FALSE;
+ gboolean debug = FALSE;
static struct option long_options [] = {
{"help", no_argument, 0, 'h'},
{"time", no_argument, 0, 't'},
{"quiet", no_argument, 0, 'q'},
{"iterations", required_argument, 0, 'i'},
+ {"debug", no_argument, 0, 'd'},
+ {"no-labels", no_argument, 0, 'n'},
{0, 0, 0, 0}
};
- while((c = getopt_long(argc, argv, "htqni:", long_options, NULL)) != -1) { switch(c) {
+ while((c = getopt_long(argc, argv, "dhtqni:", long_options, NULL)) != -1) { switch(c) {
case 'h':
print_help(argv[0]);
return 1;
case 'n':
no_final_time_labels = TRUE;
break;
+ case 'd':
+ debug = TRUE;
+ break;
}
}
}
if(run) {
+ if(debug && test_groups[j].handler != fake_tests_init) {
+ printf("Skipping %s, in driver debug mode\n",
+ test_groups[j].name);
+ continue;
+ } else if(!debug && test_groups[j].handler == fake_tests_init) {
+ continue;
+ }
+
gboolean passed = run_group(&(test_groups[j]),
iterations, quiet, report_time);
if(!passed && !global_failure) {
--- /dev/null
+/*
+ * Fake test allows debugging of the driver itself
+ */
+
+#include "test.h"
+
+RESULT
+test_fake()
+{
+ return OK;
+}
+
+static Test fake_tests [] = {
+ {"test_fake", test_fake},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(fake_tests_init, fake_tests)
+
gint i;
static const gchar *letters [] = { "A", "B", "C", "D", "E" };
- g_ptr_array_add(array, "E");
- g_ptr_array_add(array, "C");
- g_ptr_array_add(array, "A");
- g_ptr_array_add(array, "D");
- g_ptr_array_add(array, "B");
-
+ g_ptr_array_add(array, (gpointer)letters[1]);
+ g_ptr_array_add(array, (gpointer)letters[3]);
+ g_ptr_array_add(array, (gpointer)letters[0]);
+ g_ptr_array_add(array, (gpointer)letters[2]);
+ g_ptr_array_add(array, (gpointer)letters[4]);
+
g_ptr_array_sort(array, ptrarray_sort_compare);
for(i = 0; i < array->len; i++) {
- if(strcmp((gchar *)array->pdata[i], letters[i]) != 0) {
+ if(strcmp((const gchar *)array->pdata[i], letters[i]) == 0) {
return FAILED("Array out of order, expected %s got %s",
(gchar *)array->pdata[i], letters[i]);
}
DEFINE_TEST_GROUP_INIT_H(hashtable_tests_init);
DEFINE_TEST_GROUP_INIT_H(ptrarray_tests_init);
DEFINE_TEST_GROUP_INIT_H(size_tests_init);
+DEFINE_TEST_GROUP_INIT_H(fake_tests_init);
static Group test_groups [] = {
{"string", string_tests_init},
{"list", list_tests_init},
{"hashtable", hashtable_tests_init},
{"sizes", size_tests_init},
+ {"fake", fake_tests_init},
{NULL, NULL}
};