test: Move stat-printing into its own function

Add a function to show the stats, so we can decide when to print it.

This slightly adjusts the output, so that any 'test not found' message
appears on its own line after all other output.

The 'failures' message now appears in lower case so update pytest
accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/test/test-main.c b/test/test-main.c
index e36bc37..d02ab79 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -673,6 +673,18 @@
 	return uts->cur.fail_count ? -EBADF : 0;
 }
 
+void ut_report(struct ut_stats *stats, int run_count)
+{
+	if (run_count > 1)
+		printf("Suites run: %d, total tests", run_count);
+	else
+		printf("Tests");
+	printf(" run: %d, ", stats->test_count);
+	if (stats->skip_count)
+		printf("skipped: %d, ", stats->skip_count);
+	printf("failures: %d\n", stats->fail_count);
+}
+
 int ut_run_list(struct unit_test_state *uts, const char *category,
 		const char *prefix, struct unit_test *tests, int count,
 		const char *select_name, int runs_per_test, bool force_run,
@@ -718,13 +730,9 @@
 	if (has_dm_tests)
 		dm_test_restore(uts->of_root);
 
-	printf("Tests run: %d, ", uts->cur.test_count);
-	if (uts->cur.skip_count)
-		printf("Skipped: %d, ", uts->cur.skip_count);
+	ut_report(&uts->cur, 1);
 	if (ret == -ENOENT)
 		printf("Test '%s' not found\n", select_name);
-	else
-		printf("Failures: %d\n", uts->cur.fail_count);
 
 	return ret;
 }