Selaa lähdekoodia

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

    * 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
Aaron Bockover 19 vuotta sitten
vanhempi
sitoutus
98a764c554
9 muutettua tiedostoa jossa 139 lisäystä ja 82 poistoa
  1. 24 0
      eglib/ChangeLog
  2. 5 5
      eglib/autogen.sh
  3. 0 0
      eglib/configure.ac
  4. 2 2
      eglib/test/Makefile.am
  5. 6 0
      eglib/test/README
  6. 38 42
      eglib/test/driver.c
  7. 5 0
      eglib/test/test-both
  8. 56 31
      eglib/test/test.c
  9. 3 2
      eglib/test/test.h

+ 24 - 0
eglib/ChangeLog

@@ -1,3 +1,27 @@
+2006-08-19  Aaron Bockover  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* Makefile.am: Removed MAINTAINERCLEANFILES that was too

+ 5 - 5
eglib/autogen.sh

@@ -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

+ 0 - 0
eglib/configure.in → eglib/configure.ac


+ 2 - 2
eglib/test/Makefile.am

@@ -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

+ 6 - 0
eglib/test/README

@@ -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
 

+ 38 - 42
eglib/test/driver.c

@@ -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) {

+ 5 - 0
eglib/test/test-both

@@ -0,0 +1,5 @@
+#!/bin/sh
+
+./test-eglib $@
+./test-glib $@
+

+ 56 - 31
eglib/test/test.c

@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <sys/time.h>
 #include <glib.h>
 
 #include "test.h"
@@ -37,56 +38,72 @@
 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;
+}
+

+ 3 - 2
eglib/test/test.h

@@ -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