]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
testutil: allow a failure return from setup_tests that doesn't print help
authorPauli <pauli@openssl.org>
Wed, 2 Aug 2023 00:40:23 +0000 (10:40 +1000)
committerPauli <pauli@openssl.org>
Fri, 4 Aug 2023 01:58:06 +0000 (11:58 +1000)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/21621)

(cherry picked from commit badf3c162d2b67635beee3fc948db32f13d274af)

test/README-dev.md
test/testutil/main.c

index d015bcf5bfb01981deb7fe17ada210446e40ce70..d8922de000800f0c6590d39f539d64b978968916 100644 (file)
@@ -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
index 6716750a30535f6962403b3830c6e88f79376979..2945bb52b8e58817ac10319b6edcdf43c6689996 100644 (file)
@@ -15,6 +15,7 @@
 int main(int argc, char *argv[])
 {
     int ret = EXIT_FAILURE;
+    int setup_res;
 
     test_open_streams();
 
@@ -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: