+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
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."
}
}
-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."
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
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
--- /dev/null
+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
+++ /dev/null
-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
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
./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
#include <stdio.h>
#include <glib.h>
-#include <stddef.h>
-#include <sys/time.h>
#include <getopt.h>
#include "test.h"
{
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");
{
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}
};
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) {
--- /dev/null
+#!/bin/sh
+
+./test-eglib $@
+./test-glib $@
+
#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
return ret;
}
+gdouble
+get_timestamp()
+{
+ struct timeval tp;
+ gettimeofday(&tp, NULL);
+ return (gdouble)tp.tv_sec + (1.e-6) * tp.tv_usec;
+}
+
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