Browse Source

2006-08-19 Aaron Bockover <[email protected]>

    * 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


svn path=/trunk/mono/; revision=64064
Aaron Bockover 19 năm trước cách đây
mục cha
commit
ffb4a5d7a3
6 tập tin đã thay đổi với 64 bổ sung12 xóa
  1. 12 0
      eglib/ChangeLog
  2. 2 1
      eglib/test/Makefile.am
  3. 22 4
      eglib/test/driver.c
  4. 19 0
      eglib/test/fake.c
  5. 7 7
      eglib/test/ptrarray.c
  6. 2 0
      eglib/test/tests.h

+ 12 - 0
eglib/ChangeLog

@@ -1,3 +1,15 @@
+2006-08-19  Aaron Bockover  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* test/test-both: added --help

+ 2 - 1
eglib/test/Makefile.am

@@ -11,7 +11,8 @@ SOURCES = \
 	slist.c 	\
 	sizes.c		\
 	ptrarray.c 	\
-	list.c
+	list.c	\
+	fake.c
 
 test_eglib_SOURCES = $(SOURCES)
 test_glib_SOURCES = $(SOURCES)

+ 22 - 4
eglib/test/driver.c

@@ -75,12 +75,16 @@ static void print_help(char *s)
 	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");
@@ -95,16 +99,19 @@ gint main(gint argc, gchar **argv)
 	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;
@@ -120,6 +127,9 @@ gint main(gint argc, gchar **argv)
 			case 'n':
 				no_final_time_labels = TRUE;
 				break;
+			case 'd':
+				debug = TRUE;
+				break;
 		}
 	}
 
@@ -149,6 +159,14 @@ gint main(gint argc, gchar **argv)
 		}
 			
 		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) {

+ 19 - 0
eglib/test/fake.c

@@ -0,0 +1,19 @@
+/*
+ * 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)
+

+ 7 - 7
eglib/test/ptrarray.c

@@ -203,16 +203,16 @@ RESULT ptrarray_sort()
 	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]);
 		}

+ 2 - 0
eglib/test/tests.h

@@ -7,6 +7,7 @@ DEFINE_TEST_GROUP_INIT_H(list_tests_init);
 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}, 
@@ -16,6 +17,7 @@ static Group test_groups [] = {
 	{"list",      list_tests_init},
 	{"hashtable", hashtable_tests_init},
 	{"sizes",     size_tests_init},
+	{"fake",      fake_tests_init},
 	{NULL, NULL}
 };