2006-08-19 Aaron Bockover <abockover@novell.com>
authorAaron Bockover <abockover@novell.com>
Sat, 19 Aug 2006 20:07:35 +0000 (20:07 -0000)
committerAaron Bockover <abockover@novell.com>
Sat, 19 Aug 2006 20:07:35 +0000 (20:07 -0000)
    * test/test.c: do not print times if -t is not passed

    * test/driver.c: removed use of GList from the driver to avoid skews due
    to performance differences between GLib and EGLib

svn path=/trunk/mono/; revision=64052

eglib/ChangeLog
eglib/test/driver.c
eglib/test/test.c

index 23124bfb3174abb2947f24fa0ff60b28b56822b7..3d5aaac567793834b4a0fdba59197e92ed8dd79e 100644 (file)
@@ -1,3 +1,10 @@
+2006-08-19  Aaron Bockover  <abockover@novell.com>
+
+       * test/test.c: do not print times if -t is not passed
+
+       * test/driver.c: removed use of GList from the driver to avoid skews due
+       to performance differences between GLib and EGLib
+       
 2006-08-19  Aaron Bockover  <abockover@novell.com>
 
        * test/test.c: Perform iterations at the test level, only output one
index e7bd581816aefe0abcf1fb93c3b6210c1f736d2c..2319be28570a771a42f5d22467b16ccbf71dc42c 100644 (file)
 #include "test.h"
 #include "tests.h"
 
+typedef struct _StringArray {
+       gchar **strings;
+       gint length;
+} StringArray;
+
+static StringArray *
+string_array_append(StringArray *array, gchar *string)
+{
+       if(array == NULL) {
+               array = g_new0(StringArray, 1);
+               array->length = 1;
+               array->strings = g_malloc(sizeof(gchar *) * 2);
+       } else {
+               array->length++;
+               array->strings = g_realloc(array->strings, sizeof(gchar *) 
+                       * (array->length + 1));
+       }
+       
+       array->strings[array->length - 1] = string;
+       array->strings[array->length] = NULL;
+
+       return array;
+}
+
+static void
+string_array_free(StringArray *array)
+{
+       g_free(array->strings);
+       g_free(array);
+}
+
 static void print_help(char *s)
 {
        gint i;
@@ -56,7 +87,7 @@ static void print_help(char *s)
 gint main(gint argc, gchar **argv)
 {
        gint i, j, c, iterations = 1;
-       GList *tests_to_run = NULL;
+       StringArray *tests_to_run = NULL;
        gdouble time_start;
        gboolean report_time = FALSE;
        gboolean quiet = FALSE;
@@ -91,7 +122,7 @@ gint main(gint argc, gchar **argv)
                        continue;
                }
 
-               tests_to_run = g_list_append(tests_to_run, argv[i]);
+               tests_to_run = string_array_append(tests_to_run, argv[i]);
        }
 
        time_start = get_timestamp();
@@ -100,10 +131,10 @@ gint main(gint argc, gchar **argv)
                gboolean run = TRUE;
                        
                if(tests_to_run != NULL) {
-                       gint k, n;
+                       gint k;
                        run = FALSE;
-                       for(k = 0, n = g_list_length(tests_to_run); k < n; k++) {
-                               if(strcmp((char *)g_list_nth_data(tests_to_run, k)
+                       for(k = 0; k < tests_to_run->length; k++) {
+                               if(strcmp((char *)tests_to_run->strings[k]
                                        test_groups[j].name) == 0) {
                                        run = TRUE;
                                        break;
@@ -131,7 +162,7 @@ gint main(gint argc, gchar **argv)
        }
 
        if(tests_to_run != NULL) {
-               g_list_free(tests_to_run);
+               string_array_free(tests_to_run);
        }
 
        return 0;
index 7cd8b80ac61798a2818e90fe4721fe5d8be616dc..8400cde0fa0b1281c6bcee9a8628bc575b898f8a 100644 (file)
@@ -55,11 +55,15 @@ gboolean
 run_group(Group *group, gint iterations, gboolean quiet, gboolean time)
 {
        Test *tests = group->handler();
-       gint i, j, _passed = 0;
+       gint i, j, passed = 0;
        gdouble start_time_group, start_time_test;
        
        if(!quiet) {
-               printf("[%s] (%dx)\n", group->name, iterations);
+               if(iterations > 1) {
+                       printf("[%s] (%dx)\n", group->name, iterations);
+               } else {
+                       printf("[%s]\n", group->name);
+               }
        }
 
        start_time_group = get_timestamp();
@@ -82,14 +86,19 @@ run_group(Group *group, gint iterations, gboolean quiet, gboolean time)
                }
 
                if(iter_pass) {
-                       _passed++;
+                       passed++;
                        if(!quiet) {
-                               printf("OK (%g)\n", get_timestamp() - start_time_test);
+                               if(time) {
+                                       printf("OK (%g)\n", get_timestamp() - start_time_test);
+                               } else {
+                                       printf("OK\n");
+                               }
                        }
                } else  {                       
                        if(!quiet) {
                                printf("FAILED (%s)\n", result);
                        }
+                       
                        if(last_result == result) {
                                last_result = NULL;
                                g_free(result);
@@ -98,12 +107,16 @@ run_group(Group *group, gint iterations, gboolean quiet, gboolean time)
        }
 
        if(!quiet) {
-               printf("  -- %d / %d (%g%%, %g)--\n", _passed, i,
-                       ((gdouble)_passed / (gdouble)i) * 100.0,
-                       get_timestamp() - start_time_group);
+               gdouble pass_percentage = ((gdouble)passed / (gdouble)i) * 100.0;
+               if(time) {
+                       printf("  %d / %d (%g%%, %g)\n", passed, i,
+                               pass_percentage, get_timestamp() - start_time_group);
+               } else {
+                       printf("  %d / %d (%g%%)\n", passed, i, pass_percentage);
+               }
        }
 
-       return _passed == i;
+       return passed == i;
 }
 
 RESULT