From d01f682f32fb753df0652bb950fecaa47ee1b618 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 18 Apr 2021 12:13:39 +0100 Subject: [PATCH] test_split_into_argv: report test results sensibly. Now we say how many tests failed, and we also propagate the overall status into the exit code. --- windows/utils/split_into_argv.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/windows/utils/split_into_argv.c b/windows/utils/split_into_argv.c index c09f20da..b8ced4c4 100644 --- a/windows/utils/split_into_argv.c +++ b/windows/utils/split_into_argv.c @@ -646,10 +646,12 @@ int main(int argc, char **argv) * If we get here, we were invoked with no arguments, so just * run the tests. */ + int passes = 0, fails = 0; for (i = 0; i < lenof(argv_tests); i++) { int ac; char **av; + bool failed = false; split_into_argv((char *)argv_tests[i].cmdline, &ac, &av, NULL); @@ -658,6 +660,7 @@ int main(int argc, char **argv) printf("failed test %d (|%s|) arg %d: |%s| should be |%s|\n", i, argv_tests[i].cmdline, j, av[j], argv_tests[i].argv[j]); + failed = true; } #ifdef VERBOSE else { @@ -667,15 +670,33 @@ int main(int argc, char **argv) } #endif } - if (j < ac) + if (j < ac) { printf("failed test %d (|%s|): %d args returned, should be %d\n", i, argv_tests[i].cmdline, ac, j); - if (argv_tests[i].argv[j]) + failed = true; + } + if (argv_tests[i].argv[j]) { printf("failed test %d (|%s|): %d args returned, should be more\n", i, argv_tests[i].cmdline, ac); + failed = true; + } + + if (failed) + fails++; + else + passes++; } - return 0; + printf("passed %d failed %d (%s mode)\n", + passes, fails, +#if MOD3 + "mod 3" +#else + "mod 2" +#endif + ); + + return fails != 0; } #endif /* TEST */