Skip to content

Commit

Permalink
testutil: allow a failure return from setup_tests that doesn't print …
Browse files Browse the repository at this point in the history
…help

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from #21621)
  • Loading branch information
paulidale committed Aug 4, 2023
1 parent 029ddd1 commit badf3c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion test/README-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ Generic form of C test executables
int setup_tests(void)
{
ADD_TEST(my_test); /* Add each test separately */
return 1; /* Indicate success */
return 1; /* Indicates success. Return 0 */
/* to produce an error with a */
/* usage message and -1 for */
/* failure to set up with no */
/* usage message. */
}

You should use the `TEST_xxx` macros provided by `testutil.h` to test all failure
Expand Down
5 changes: 3 additions & 2 deletions test/testutil/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
int main(int argc, char *argv[])
{
int ret = EXIT_FAILURE;
int setup_res;

test_open_streams();

Expand All @@ -26,11 +27,11 @@ int main(int argc, char *argv[])
if (!setup_test_framework(argc, argv))
goto end;

if (setup_tests()) {
if ((setup_res = setup_tests()) > 0) {
ret = run_tests(argv[0]);
cleanup_tests();
opt_check_usage();
} else {
} else if (setup_res == 0) {
opt_help(test_get_options());
}
end:
Expand Down

0 comments on commit badf3c1

Please sign in to comment.