2006-08-19 Aaron Bockover <abockover@novell.com>
authorAaron Bockover <abockover@novell.com>
Sat, 19 Aug 2006 22:24:24 +0000 (22:24 -0000)
committerAaron Bockover <abockover@novell.com>
Sat, 19 Aug 2006 22:24:24 +0000 (22:24 -0000)
    * 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

eglib/ChangeLog
eglib/test/Makefile.am
eglib/test/driver.c
eglib/test/fake.c [new file with mode: 0644]
eglib/test/ptrarray.c
eglib/test/tests.h

index cf5e5d4a79163cbceec69c9fcb2872bfe52509f1..e5f6a986bf877b988b97a0736e6d9f2fdf65c02b 100644 (file)
@@ -1,3 +1,15 @@
+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
index 3cc40f3032fa81eeaf4d1e5a6788802436a4300a..bd9229f98cb1c67b874fb016172deb4bfdbf79a6 100644 (file)
@@ -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)
index 9bd3d80d31b6f9666472e826deb4f5e2c58ef46a..fa6a950476e2df1e321ea7a282626521960bc475 100644 (file)
@@ -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) {
diff --git a/eglib/test/fake.c b/eglib/test/fake.c
new file mode 100644 (file)
index 0000000..5ceb65d
--- /dev/null
@@ -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)
+
index 778eb1f9a4b1989e5d6edfb22cebd5674d900cc0..238d3f56400b06f93fe8e86f2031e5d7a554a0c0 100644 (file)
@@ -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]);
                }
index 0b143d0664a7bb40cd7f8e1b3754b1a5d5633fab..b94f3020a4071d38275338bd901444bab0e151ee 100644 (file)
@@ -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}
 };