提交 a743b817 编写于 作者: R Richard Levitte

test/testutil.c: Flush stdout when running tests

Because stdout is usually buffered and stderr isn't, error output
might get printed in one bunch and all the lines saying which test
failed all in one bunch, making it difficult to see exactly what error
output belongs to what test.  Flushing stdout makes sure the runner
output is displayed together with the corresponding error output.
Reviewed-by: NRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3198)
上级 4833caed
...@@ -114,6 +114,7 @@ int run_tests(const char *test_prog_name) ...@@ -114,6 +114,7 @@ int run_tests(const char *test_prog_name)
printf("%s: %d test case%s\n", test_prog_name, num_test_cases, printf("%s: %d test case%s\n", test_prog_name, num_test_cases,
num_test_cases == 1 ? "" : "s"); num_test_cases == 1 ? "" : "s");
fflush(stdout);
for (i = 0; i != num_tests; ++i) { for (i = 0; i != num_tests; ++i) {
if (all_tests[i].num == -1) { if (all_tests[i].num == -1) {
...@@ -122,6 +123,7 @@ int run_tests(const char *test_prog_name) ...@@ -122,6 +123,7 @@ int run_tests(const char *test_prog_name)
if (!ret) { if (!ret) {
printf("** %s failed **\n--------\n", printf("** %s failed **\n--------\n",
all_tests[i].test_case_name); all_tests[i].test_case_name);
fflush(stdout);
++num_failed; ++num_failed;
} }
finalize(ret); finalize(ret);
...@@ -132,6 +134,7 @@ int run_tests(const char *test_prog_name) ...@@ -132,6 +134,7 @@ int run_tests(const char *test_prog_name)
if (!ret) { if (!ret) {
printf("** %s failed test %d\n--------\n", printf("** %s failed test %d\n--------\n",
all_tests[i].test_case_name, j); all_tests[i].test_case_name, j);
fflush(stdout);
++num_failed; ++num_failed;
} }
finalize(ret); finalize(ret);
...@@ -142,9 +145,11 @@ int run_tests(const char *test_prog_name) ...@@ -142,9 +145,11 @@ int run_tests(const char *test_prog_name)
if (num_failed != 0) { if (num_failed != 0) {
printf("%s: %d test%s failed (out of %d)\n", test_prog_name, printf("%s: %d test%s failed (out of %d)\n", test_prog_name,
num_failed, num_failed != 1 ? "s" : "", num_test_cases); num_failed, num_failed != 1 ? "s" : "", num_test_cases);
fflush(stdout);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
printf(" All tests passed.\n"); printf(" All tests passed.\n");
fflush(stdout);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册