add a run_test to test.c to improve the log_info output
authorTero Marttila <terom@fixme.fi>
Fri, 08 May 2009 00:12:15 +0300
changeset 188 6fd4706a4180
parent 187 5d100c79521a
child 189 f351facab1f0
add a run_test to test.c to improve the log_info output
src/test/test.c
--- a/src/test/test.c	Fri May 08 00:11:35 2009 +0300
+++ b/src/test/test.c	Fri May 08 00:12:15 2009 +0300
@@ -75,6 +75,18 @@
 }
 
 /**
+ * Run the given test, updating the given counter
+ */
+static void run_test (const struct test *test, size_t *test_count)
+{
+    log_info("%s", test->name);
+
+    // count and run
+    (*test_count)++;
+    test->func();
+}
+
+/**
  * Run the given NULL-terminated list of tests, optionally filtering against the given filter.
  *
  * Returns the number of tests run, which may be zero.
@@ -89,12 +101,9 @@
         // filter out if given
         if ((filter && strcmp(test->name, filter)) || (!filter && test->optional))
             continue;
-
-        log_info("Running test: %s", test->name);
         
-        // count and run
-        test_count++;
-        test->func();
+        // run it
+        run_test(test, &test_count);
     }
     
     return test_count;