2006-08-19 Aaron Bockover <abockover@novell.com>
authorAaron Bockover <abockover@novell.com>
Sat, 19 Aug 2006 19:33:12 +0000 (19:33 -0000)
committerAaron Bockover <abockover@novell.com>
Sat, 19 Aug 2006 19:33:12 +0000 (19:33 -0000)
    * test/test.c: Perform iterations at the test level, only output one
    report for all iterations of tests in a group to produce more usable
    output; add timing for the tests and group; added get_timestamp for
    easy code timing

    * test/test.h: Removed run_test as it should only be called from
    run_group, added get_timestamp

    * test/Makefile.am: Added -DDRIVER_NAME

    * test/test-both: simple script to run both drivers with the same options

    * test/driver.c: Iterations are now run at the test level, show a global
    status (OK/FAIL) indicator

    * test/README: Updated

    * configure.ac: Renamed from configure.in as configure.in naming
    convention is deprecated in favor of configure.ac

    * autogen.sh: s/configure.in/configure.ac/

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

eglib/ChangeLog
eglib/autogen.sh
eglib/configure.ac [new file with mode: 0644]
eglib/configure.in [deleted file]
eglib/test/Makefile.am
eglib/test/README
eglib/test/driver.c
eglib/test/test-both [new file with mode: 0755]
eglib/test/test.c
eglib/test/test.h

index f96d4ddfb49009b393ae43a05b6f8cbb32764378..23124bfb3174abb2947f24fa0ff60b28b56822b7 100644 (file)
@@ -1,3 +1,27 @@
+2006-08-19  Aaron Bockover  <abockover@novell.com>
+
+       * test/test.c: Perform iterations at the test level, only output one
+       report for all iterations of tests in a group to produce more usable
+       output; add timing for the tests and group; added get_timestamp for
+       easy code timing
+
+       * test/test.h: Removed run_test as it should only be called from 
+       run_group, added get_timestamp
+
+       * test/Makefile.am: Added -DDRIVER_NAME 
+
+       * test/test-both: simple script to run both drivers with the same options
+
+       * test/driver.c: Iterations are now run at the test level, show a global
+       status (OK/FAIL) indicator
+
+       * test/README: Updated
+
+       * configure.ac: Renamed from configure.in as configure.in naming 
+       convention is deprecated in favor of configure.ac
+
+       * autogen.sh: s/configure.in/configure.ac/
+
 2006-08-19  Miguel de Icaza  <miguel@novell.com>
 
        * Makefile.am: Removed MAINTAINERCLEANFILES that was too
index cf078cefa09de6a5abf487a5e654bf824b4c512e..bce3a516ee66adcc1229be328b1e74d1a60ebc03 100755 (executable)
@@ -37,7 +37,7 @@ if [ -z "$LIBTOOL" ]; then
   fi
 fi
 
-(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && {
+(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && {
   ($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
     echo
     echo "**Error**: You must have \`libtool' installed to compile Mono."
@@ -47,8 +47,8 @@ fi
   }
 }
 
-grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && {
-  grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
+grep "^AM_GNU_GETTEXT" $srcdir/configure.ac >/dev/null && {
+  grep "sed.*POTFILES" $srcdir/configure.ac >/dev/null || \
   (gettext --version) < /dev/null > /dev/null 2>&1 || {
     echo
     echo "**Error**: You must have \`gettext' installed to compile Mono."
@@ -95,7 +95,7 @@ xlc )
 esac
 
 
-if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then
+if grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null; then
   if test -z "$NO_LIBTOOLIZE" ; then 
     echo "Running libtoolize..."
     ${LIBTOOL}ize --force --copy
@@ -113,7 +113,7 @@ aclocal $ACLOCAL_FLAGS || {
   exit 1
 }
 
-if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
+if grep "^AM_CONFIG_HEADER" configure.ac >/dev/null; then
   echo "Running autoheader..."
   autoheader || { echo "**Error**: autoheader failed."; exit 1; }
 fi
diff --git a/eglib/configure.ac b/eglib/configure.ac
new file mode 100644 (file)
index 0000000..a016d73
--- /dev/null
@@ -0,0 +1,81 @@
+AC_INIT(README)
+AC_CANONICAL_SYSTEM
+
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(eglib,0.1)
+AM_MAINTAINER_MODE
+
+AC_PROG_CC
+AM_PROG_LIBTOOL
+CFLAGS='-g -O0'
+AC_SUBST(CFLAGS)
+
+GNUC_PRETTY=
+GNUC_UNUSED=
+BREAKPOINT=
+if test x$GCC = xyes; then
+   GNUC_PRETTY=__PRETTY_FUNCTION__
+   GNUC_UNUSED='__attribute__((__unused__))'
+   GNUC_NORETURN='__attribute__((__noreturn__))'
+   case $target in
+     i[3456]86-*)
+       BREAKPOINT="G_STMT_START { __asm__ ("int $03"); } G_STMT_END"
+     ;;
+   esac
+fi
+AC_SUBST(GNUC_PRETTY)
+AC_SUBST(GNUC_UNUSED)
+AC_SUBST(GNUC_NORETURN)
+AC_SUBST(BREAKPOINT)
+
+AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
+AC_SUBST(ORDER)
+
+case $host in
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+    PATHSEP='\\'
+    SEARCHSEP=';'
+    OS="WIN32"
+    ;;
+*)
+    PATHSEP='/'
+    SEARCHSEP=':'
+    OS="UNIX"
+    ;;
+esac
+
+AC_SUBST(PATHSEP)
+AC_SUBST(SEARCHSEP)
+AC_SUBST(OS)
+
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(void *)
+
+if test $ac_cv_sizeof_void_p != $ac_cv_sizeof_int; then
+   GPOINTER_TO_INT="((gint)(long) (ptr))"
+   GPOINTER_TO_UINT="((guint)(long) (ptr))"
+   GINT_TO_POINTER="((gpointer)(glong) (v))"
+   GUINT_TO_POINTER="((gpointer)(gulong) (v))"
+   GSIZE="long"
+   GSIZE_FORMAT='"lu"'
+else
+   GPOINTER_TO_INT="((gint) (ptr))"
+   GPOINTER_TO_UINT="((guint) (ptr))"
+   GINT_TO_POINTER="((gpointer) (v))"
+   GUINT_TO_POINTER="((gpointer) (v))"
+   GSIZE="int"
+   GSIZE_FORMAT='"u"'
+fi
+AC_SUBST(GPOINTER_TO_INT)
+AC_SUBST(GPOINTER_TO_UINT)
+AC_SUBST(GINT_TO_POINTER)
+AC_SUBST(GUINT_TO_POINTER)
+AC_SUBST(GSIZE)
+AC_SUBST(GSIZE_FORMAT)
+
+AC_OUTPUT([
+Makefile
+src/Makefile
+src/eglib-config.h
+test/Makefile
+])
\ No newline at end of file
diff --git a/eglib/configure.in b/eglib/configure.in
deleted file mode 100644 (file)
index a016d73..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-AC_INIT(README)
-AC_CANONICAL_SYSTEM
-
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(eglib,0.1)
-AM_MAINTAINER_MODE
-
-AC_PROG_CC
-AM_PROG_LIBTOOL
-CFLAGS='-g -O0'
-AC_SUBST(CFLAGS)
-
-GNUC_PRETTY=
-GNUC_UNUSED=
-BREAKPOINT=
-if test x$GCC = xyes; then
-   GNUC_PRETTY=__PRETTY_FUNCTION__
-   GNUC_UNUSED='__attribute__((__unused__))'
-   GNUC_NORETURN='__attribute__((__noreturn__))'
-   case $target in
-     i[3456]86-*)
-       BREAKPOINT="G_STMT_START { __asm__ ("int $03"); } G_STMT_END"
-     ;;
-   esac
-fi
-AC_SUBST(GNUC_PRETTY)
-AC_SUBST(GNUC_UNUSED)
-AC_SUBST(GNUC_NORETURN)
-AC_SUBST(BREAKPOINT)
-
-AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
-AC_SUBST(ORDER)
-
-case $host in
-*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
-    PATHSEP='\\'
-    SEARCHSEP=';'
-    OS="WIN32"
-    ;;
-*)
-    PATHSEP='/'
-    SEARCHSEP=':'
-    OS="UNIX"
-    ;;
-esac
-
-AC_SUBST(PATHSEP)
-AC_SUBST(SEARCHSEP)
-AC_SUBST(OS)
-
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(void *)
-
-if test $ac_cv_sizeof_void_p != $ac_cv_sizeof_int; then
-   GPOINTER_TO_INT="((gint)(long) (ptr))"
-   GPOINTER_TO_UINT="((guint)(long) (ptr))"
-   GINT_TO_POINTER="((gpointer)(glong) (v))"
-   GUINT_TO_POINTER="((gpointer)(gulong) (v))"
-   GSIZE="long"
-   GSIZE_FORMAT='"lu"'
-else
-   GPOINTER_TO_INT="((gint) (ptr))"
-   GPOINTER_TO_UINT="((guint) (ptr))"
-   GINT_TO_POINTER="((gpointer) (v))"
-   GUINT_TO_POINTER="((gpointer) (v))"
-   GSIZE="int"
-   GSIZE_FORMAT='"u"'
-fi
-AC_SUBST(GPOINTER_TO_INT)
-AC_SUBST(GPOINTER_TO_UINT)
-AC_SUBST(GINT_TO_POINTER)
-AC_SUBST(GUINT_TO_POINTER)
-AC_SUBST(GSIZE)
-AC_SUBST(GSIZE_FORMAT)
-
-AC_OUTPUT([
-Makefile
-src/Makefile
-src/eglib-config.h
-test/Makefile
-])
\ No newline at end of file
index 98cdb89e604270e7c48f5c848152a6c43edacc0e..3cc40f3032fa81eeaf4d1e5a6788802436a4300a 100644 (file)
@@ -16,10 +16,10 @@ SOURCES = \
 test_eglib_SOURCES = $(SOURCES)
 test_glib_SOURCES = $(SOURCES)
 
-test_eglib_CFLAGS = -Wall -Werror -D_FORTIFY_SOURCE=2 -I$(srcdir)/../src
+test_eglib_CFLAGS = -Wall -Werror -D_FORTIFY_SOURCE=2 -I$(srcdir)/../src -DDRIVER_NAME=\"EGlib\"
 test_eglib_LDADD = -L../src -leglib
 
-test_glib_CFLAGS = `pkg-config --cflags glib-2.0`
+test_glib_CFLAGS = `pkg-config --cflags glib-2.0` -DDRIVER_NAME=\"GLib\"
 test_glib_LDFLAGS = `pkg-config --libs glib-2.0`
 
 MAINTAINERCLEANFILES = Makefile.in
index 08c35babc4415fa69eb1daa344a587acade58dc8..61eed46dc779b9ca9f993b87772d95bb3ab2c243 100644 (file)
@@ -89,4 +89,10 @@ Example: show test output of all available groups
 
        ./test-eglib
 
+The 'test-both' script can be used to run both test-eglib and test-glib
+with the same options back to back:
+
+       $./test-both -tqi 100000 ptrarray
+       EGlib Total Time: 1.1961s
+       GLib Total Time: 0.955957s
 
index dea1cd21d3a3882355c64a6c8573ce2b69c48b2e..e7bd581816aefe0abcf1fb93c3b6210c1f736d2c 100644 (file)
@@ -28,8 +28,6 @@
  
 #include <stdio.h>
 #include <glib.h>
-#include <stddef.h>
-#include <sys/time.h>
 #include <getopt.h>
 
 #include "test.h"
@@ -39,18 +37,17 @@ static void print_help(char *s)
 {
        gint i;
        
-       printf("Usage: %s [options] [test1 test2 ... testN]\n\n", s);
-       printf(" options are:\n");
-       printf("   --help|-h          show this help\n");
-       printf("   --time|-t          time the tests\n");
-       printf("   --iterations|-i    number of times to run tests\n");
-       printf("   --quiet|-q         do not print test results; if -t\n");
-       printf("                      is passed, the time will print\n\n");
-       printf(" test1..testN  name of test to run (all run by default)\n\n");
-       printf(" available tests:\n");
+       printf("Usage: %s [OPTION]... [TESTGROUP]...\n\n", s);
+       printf("OPTIONS are:\n");
+       printf("  -h, --help          show this help\n");
+       printf("  -t, --time          time the tests\n");
+       printf("  -i, --iterations    number of times to run tests\n");
+       printf("  -q, --quiet         do not print test results; "
+               "time always prints\n\n");
+       printf("TESTGROUPS available:\n");
 
        for(i = 0; test_groups[i].name != NULL; i++) {
-               printf("   %s\n", test_groups[i].name);
+               printf("  %s\n", test_groups[i].name);
        }
 
        printf("\n");
@@ -60,14 +57,15 @@ gint main(gint argc, gchar **argv)
 {
        gint i, j, c, iterations = 1;
        GList *tests_to_run = NULL;
-       double time_start, time_end;
-       struct timeval tp;
+       gdouble time_start;
        gboolean report_time = FALSE;
        gboolean quiet = FALSE;
+       gboolean global_failure = FALSE;
        
        static struct option long_options [] = {
-               {"help", no_argument, 0, 'h'},
-               {"time", no_argument, 0, 't'},
+               {"help",       no_argument,       0, 'h'},
+               {"time",       no_argument,       0, 't'},
+               {"quiet",      no_argument,       0, 'q'},
                {"iterations", required_argument, 0, 'i'},
                {0, 0, 0, 0}
        };
@@ -96,42 +94,40 @@ gint main(gint argc, gchar **argv)
                tests_to_run = g_list_append(tests_to_run, argv[i]);
        }
 
-       gettimeofday(&tp, NULL);
-       time_start = (double)tp.tv_sec + (1.e-6) * tp.tv_usec;
-
-       for(i = 0; i < iterations; i++) {
-               for(j = 0; test_groups[j].name != NULL; j++) {
-                       gboolean run = TRUE;
+       time_start = get_timestamp();
+       
+       for(j = 0; test_groups[j].name != NULL; j++) {
+               gboolean run = TRUE;
                        
-                       if(tests_to_run != NULL) {
-                               gint k, n;
-                               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), 
-                                               test_groups[j].name) == 0) {
-                                               run = TRUE;
-                                               break;
-                                       }
+               if(tests_to_run != NULL) {
+                       gint k, n;
+                       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), 
+                                       test_groups[j].name) == 0) {
+                                       run = TRUE;
+                                       break;
                                }
                        }
+               }
                        
-                       if(run) {
-                               gint total, passed;
-                               run_group(&(test_groups[j]), &total, &passed, quiet);
-                               if(!quiet) {
-                                       printf("  -- %d / %d (%g%%) --\n", passed, total,
-                                               ((gdouble)passed / (gdouble)total) * 100.0);
-                               }
+               if(run) {
+                       gboolean passed = run_group(&(test_groups[j]), 
+                               iterations, quiet, report_time);
+                       if(!passed && !global_failure) {
+                               global_failure = TRUE;
                        }
                }
        }
        
-       gettimeofday(&tp, NULL);
-       time_end = (double)tp.tv_sec + (1.e-6) * tp.tv_usec;
+       if(!quiet) {
+               printf("=============================\n");
+               printf("Overall result: %s\n", global_failure ? "FAILED" : "OK");
+       }
        
        if(report_time) {
-               gdouble duration = time_end - time_start;
-               printf("Total Time: %gs\n", duration);
+               gdouble duration = get_timestamp() - time_start;
+               printf("%s Total Time: %g\n", DRIVER_NAME, duration);
        }
 
        if(tests_to_run != NULL) {
diff --git a/eglib/test/test-both b/eglib/test/test-both
new file mode 100755 (executable)
index 0000000..a006a43
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+./test-eglib $@
+./test-glib $@
+
index 9e6e87707df3a6d901041d98047bc326d7e35f75..7cd8b80ac61798a2818e90fe4721fe5d8be616dc 100644 (file)
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <sys/time.h>
 #include <glib.h>
 
 #include "test.h"
 static gchar *last_result = NULL;
 
 gboolean 
-run_test(Test *test, gboolean quiet)
+run_test(Test *test, gchar **result_out)
 {
        gchar *result; 
-       
-       if(!quiet) {
-               printf("  %s: ", test->name);
-               fflush(stdout);
-       }
-       
+
        if((result = test->handler()) == NULL) {
-               if(!quiet) {
-                       printf("OK\n");
-               }
-               
+               *result_out = NULL;
                return TRUE;
        } else {
-               if(!quiet) {
-                       printf("FAILED (%s)\n", result);
-               }
-               
-               if(last_result == result) {
-                       last_result = NULL;
-                       g_free(result);
-               }
-               
+               *result_out = result;   
                return FALSE;
        }
 }
 
-void
-run_group(Group *group, gint *total, gint *passed, gboolean quiet)
+gboolean
+run_group(Group *group, gint iterations, gboolean quiet, gboolean time)
 {
        Test *tests = group->handler();
-       gint i, _passed = 0;
-
+       gint i, j, _passed = 0;
+       gdouble start_time_group, start_time_test;
+       
        if(!quiet) {
-               printf("[%s]\n", group->name);
+               printf("[%s] (%dx)\n", group->name, iterations);
        }
 
+       start_time_group = get_timestamp();
+
        for(i = 0; tests[i].name != NULL; i++) {
-               _passed += run_test(&(tests[i]), quiet);
-       }
+               gchar *result;
+               gboolean iter_pass;
+               
+               if(!quiet) {
+                       printf("  %s: ", tests[i].name);
+               }
+
+               start_time_test = get_timestamp();
+               
+               for(j = 0; j < iterations; j++) {
+                       iter_pass = run_test(&(tests[i]), &result);
+                       if(!iter_pass) {
+                               break;
+                       }
+               }
 
-       if(total != NULL) {
-               *total = i;
+               if(iter_pass) {
+                       _passed++;
+                       if(!quiet) {
+                               printf("OK (%g)\n", get_timestamp() - start_time_test);
+                       }
+               } else  {                       
+                       if(!quiet) {
+                               printf("FAILED (%s)\n", result);
+                       }
+                       if(last_result == result) {
+                               last_result = NULL;
+                               g_free(result);
+                       }
+               }
        }
 
-       if(passed != NULL) {
-               *passed = _passed;
+       if(!quiet) {
+               printf("  -- %d / %d (%g%%, %g)--\n", _passed, i,
+                       ((gdouble)_passed / (gdouble)i) * 100.0,
+                       get_timestamp() - start_time_group);
        }
+
+       return _passed == i;
 }
 
 RESULT
@@ -109,3 +126,11 @@ FAILED(const gchar *format, ...)
        return ret;
 }
 
+gdouble
+get_timestamp()
+{
+       struct timeval tp;
+       gettimeofday(&tp, NULL);
+       return (gdouble)tp.tv_sec + (1.e-6) * tp.tv_usec;
+}
+
index cfe81ca82595d0b6818c7588b094058fa7f3034e..33a1c1f9c8fa206f607ffb31190c92b6afdd40ea 100644 (file)
@@ -50,9 +50,10 @@ struct _Group {
        LoadGroupHandler handler;
 };
 
-gboolean run_test(Test *test, gboolean quiet);
-void run_group(Group *group, gint *total, gint *passed, gboolean quiet);
+gboolean run_group(Group *group, gint iterations, gboolean quiet, 
+       gboolean time);
 RESULT FAILED(const gchar *format, ...);
+gdouble get_timestamp();
 
 #define OK NULL