+2007-12-05 17:21:05 Tim Janik <timj@imendio.com>
+
+ * glib/glib/gtestutils.c: print out random seed for verbose tests,
+ also adapted test result reporting slightly in verbose mode to allow
+ custom debugging output. support "thorough" as test mode alis for "slow".
+
+ * glib/glib/gtestutils.h: added g_test_thorough().
+
+ * glib/glib/gtester.c: print out the last random seed when tests fail.
+ added result attribute to test case status logging to easily spot
+ failing tests in log files. disabled debugging output when skipping tests.
+
2007-12-05 11:43:22 Tim Janik <timj@imendio.com>
* glib/gtestutils.[hc]: added g_test_add_data_func() to pass data
static gboolean subtest_mode_perf = FALSE;
static gboolean subtest_mode_quick = TRUE;
static const gchar *subtest_seedstr = NULL;
+static gchar *subtest_last_seed = NULL;
static GSList *subtest_paths = NULL;
static GSList *subtest_args = NULL;
static gboolean testcase_open = FALSE;
static void
testcase_close (long double duration,
- guint exit_status,
+ gint exit_status,
guint n_forks)
{
g_return_if_fail (testcase_open > 0);
test_log_printfe ("%s<duration>%.6Lf</duration>\n", sindent (log_indent), duration);
- test_log_printfe ("%s<status exit-status=\"%d\" n-forks=\"%d\"/>\n",
- sindent (log_indent), exit_status, n_forks);
+ test_log_printfe ("%s<status exit-status=\"%d\" n-forks=\"%d\" result=\"%s\"/>\n",
+ sindent (log_indent), exit_status, n_forks,
+ exit_status ? "failed" : "success");
log_indent -= 2;
test_log_printfe ("%s</testcase>\n", sindent (log_indent));
testcase_open--;
if (gtester_verbose)
g_print ("%s\n", exit_status ? "FAIL" : "OK");
+ if (exit_status && subtest_last_seed)
+ g_print ("GTester: last random seed: %s\n", subtest_last_seed);
if (exit_status)
testcase_fail_count += 1;
if (subtest_mode_fatal && testcase_fail_count)
break;
case G_TEST_LOG_START_BINARY:
test_log_printfe ("%s<binary file=\"%s\"/>\n", sindent (log_indent), msg->strings[0]);
- test_log_printfe ("%s<random-seed>%s</random-seed>\n", sindent (log_indent), msg->strings[1]);
+ subtest_last_seed = g_strdup (msg->strings[1]);
+ test_log_printfe ("%s<random-seed>%s</random-seed>\n", sindent (log_indent), subtest_last_seed);
break;
case G_TEST_LOG_LIST_CASE:
g_print ("%s\n", msg->strings[0]);
log_indent += 2;
break;
case G_TEST_LOG_SKIP_CASE:
- if (TRUE && gtester_verbose) // enable to debug test case skipping logic
+ if (FALSE && gtester_verbose) // enable to debug test case skipping logic
{
gchar *sc = g_strconcat (msg->strings[0], ":", NULL);
gchar *sleft = g_strdup_printf ("%-68s", sc);
success &= subtest_exitstatus == 0;
need_restart = testcase_open != 0;
if (testcase_open)
- testcase_close (0, -999, 0);
+ testcase_close (0, -256, 0);
g_timer_stop (btimer);
test_log_printfe ("%s<duration>%.6f</duration>\n", sindent (log_indent), g_timer_elapsed (btimer, NULL));
log_indent -= 2;
test_log_printfe ("%s</testbinary>\n", sindent (log_indent));
+ g_free (subtest_last_seed);
+ subtest_last_seed = NULL;
if (need_restart)
{
/* restart test binary, skipping processed test cases */
switch (lbit)
{
+ case G_TEST_LOG_START_BINARY:
+ if (g_test_verbose())
+ g_print ("GTest: random seed: %s\n", string2);
+ break;
case G_TEST_LOG_STOP_CASE:
- if (!g_test_quiet())
+ if (g_test_verbose())
+ g_print ("GTest: result: %s\n", fail ? "FAIL" : "OK");
+ else if (!g_test_quiet())
g_print ("%s\n", fail ? "FAIL" : "OK");
if (fail && test_mode_fatal)
abort();
switch (lbit)
{
case G_TEST_LOG_START_CASE:
- if (!g_test_quiet())
+ if (g_test_verbose())
+ g_print ("GTest: run: %s\n", string1);
+ else if (!g_test_quiet())
g_print ("%s: ", string1);
break;
default: ;
mutable_test_config_vars.test_perf = TRUE;
else if (strcmp (mode, "slow") == 0)
mutable_test_config_vars.test_quick = FALSE;
+ else if (strcmp (mode, "thorough") == 0)
+ mutable_test_config_vars.test_quick = FALSE;
else if (strcmp (mode, "quick") == 0)
{
mutable_test_config_vars.test_quick = TRUE;
* --verbose run tests verbosely.
* -q, --quiet run tests quietly.
* -p TESTPATH execute all tests matching TESTPATH.
- * -m {perf|slow|quick} execute tests according to this test modes:
+ * -m {perf|slow|thorough|quick}
+ * execute tests according to these test modes:
* perf - performance tests, may take long and report results.
* slow - slow and thorough tests, may take quite long and maximize coverage.
+ * thorough - currently an alias for "slow".
* quick - quick tests, should run really quickly and give good coverage.
* --debug-log debug test logging output.
* -k, --keep-going gtester specific argument.