+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
#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;
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;
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();
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;
}
if(tests_to_run != NULL) {
- g_list_free(tests_to_run);
+ string_array_free(tests_to_run);
}
return 0;
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();
}
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);
}
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