diff --git a/test/asynciotest.c b/test/asynciotest.c index bf0a20561e7a5..dcdee1068dc2d 100644 --- a/test/asynciotest.c +++ b/test/asynciotest.c @@ -397,6 +397,11 @@ OPT_TEST_DECLARE_USAGE("certname privkey\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(cert = test_get_argument(0)) || !TEST_ptr(privkey = test_get_argument(1))) return 0; diff --git a/test/clienthellotest.c b/test/clienthellotest.c index b4563b5beb243..9a7537444ca1a 100644 --- a/test/clienthellotest.c +++ b/test/clienthellotest.c @@ -250,6 +250,11 @@ OPT_TEST_DECLARE_USAGE("sessionfile\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(sessionfile = test_get_argument(0))) return 0; diff --git a/test/cmp_msg_test.c b/test/cmp_msg_test.c index 463c60789ba9d..7fa0619284f93 100644 --- a/test/cmp_msg_test.c +++ b/test/cmp_msg_test.c @@ -538,6 +538,11 @@ void cleanup_tests(void) int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(server_cert_f = test_get_argument(0)) || !TEST_ptr(pkcs10_f = test_get_argument(1))) { TEST_error("usage: cmp_msg_test server.crt pkcs10.der\n"); diff --git a/test/cmp_protect_test.c b/test/cmp_protect_test.c index 89be39f7fcf97..d17a8ef1e857a 100644 --- a/test/cmp_protect_test.c +++ b/test/cmp_protect_test.c @@ -455,6 +455,11 @@ int setup_tests(void) char *root_f; char *intermediate_f; + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + RAND_bytes(rand_data, OSSL_CMP_TRANSACTIONID_LENGTH); if (!TEST_ptr(server_f = test_get_argument(0)) || !TEST_ptr(ir_protected_f = test_get_argument(1)) diff --git a/test/cmsapitest.c b/test/cmsapitest.c index 2ea8af58b3e4b..3ab1b82f963d0 100644 --- a/test/cmsapitest.c +++ b/test/cmsapitest.c @@ -65,6 +65,11 @@ int setup_tests(void) char *certin = NULL, *privkeyin = NULL; BIO *certbio = NULL, *privkeybio = NULL; + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(certin = test_get_argument(0)) || !TEST_ptr(privkeyin = test_get_argument(1))) return 0; diff --git a/test/d2i_test.c b/test/d2i_test.c index 3ce38485bd221..84ba30fbcc626 100644 --- a/test/d2i_test.c +++ b/test/d2i_test.c @@ -127,6 +127,11 @@ int setup_tests(void) {"compare", ASN1_COMPARE} }; + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(test_type_name = test_get_argument(0)) || !TEST_ptr(expected_error_string = test_get_argument(1)) || !TEST_ptr(test_file = test_get_argument(2))) diff --git a/test/danetest.c b/test/danetest.c index 2c228ecc52b53..9b61699999b1f 100644 --- a/test/danetest.c +++ b/test/danetest.c @@ -413,6 +413,11 @@ OPT_TEST_DECLARE_USAGE("basedomain CAfile tlsafile\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(basedomain = test_get_argument(0)) || !TEST_ptr(CAfile = test_get_argument(1)) || !TEST_ptr(tlsafile = test_get_argument(2))) diff --git a/test/dtlstest.c b/test/dtlstest.c index 022b4c0149665..607768832b19c 100644 --- a/test/dtlstest.c +++ b/test/dtlstest.c @@ -332,6 +332,11 @@ OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(cert = test_get_argument(0)) || !TEST_ptr(privkey = test_get_argument(1))) return 0; diff --git a/test/evp_test.c b/test/evp_test.c index e4d30fb20d138..df6c5b8016caa 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -3258,8 +3258,14 @@ OPT_TEST_DECLARE_USAGE("file...\n") int setup_tests(void) { - size_t n = test_get_argument_count(); + size_t n; + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + + n = test_get_argument_count(); if (n == 0) return 0; diff --git a/test/fatalerrtest.c b/test/fatalerrtest.c index 0f18c1b67bc67..184392cff260c 100644 --- a/test/fatalerrtest.c +++ b/test/fatalerrtest.c @@ -86,6 +86,11 @@ OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(cert = test_get_argument(0)) || !TEST_ptr(privkey = test_get_argument(1))) return 0; diff --git a/test/gosttest.c b/test/gosttest.c index a03521d8a339a..7737a68f5f910 100644 --- a/test/gosttest.c +++ b/test/gosttest.c @@ -82,6 +82,11 @@ OPT_TEST_DECLARE_USAGE("certfile1 privkeyfile1 certfile2 privkeyfile2\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(cert1 = test_get_argument(0)) || !TEST_ptr(privkey1 = test_get_argument(1)) || !TEST_ptr(cert2 = test_get_argument(2)) diff --git a/test/ocspapitest.c b/test/ocspapitest.c index 355bd448aebfa..358eb54fadfd0 100644 --- a/test/ocspapitest.c +++ b/test/ocspapitest.c @@ -215,6 +215,11 @@ OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(certstr = test_get_argument(0)) || !TEST_ptr(privkeystr = test_get_argument(1))) return 0; diff --git a/test/params_conversion_test.c b/test/params_conversion_test.c index d6490833a9775..838eefa2123cc 100644 --- a/test/params_conversion_test.c +++ b/test/params_conversion_test.c @@ -328,8 +328,14 @@ OPT_TEST_DECLARE_USAGE("file...\n") int setup_tests(void) { - size_t n = test_get_argument_count(); + size_t n; + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + + n = test_get_argument_count(); if (n == 0) return 0; diff --git a/test/recordlentest.c b/test/recordlentest.c index 9be354bea81fb..01cc53469b809 100644 --- a/test/recordlentest.c +++ b/test/recordlentest.c @@ -185,6 +185,11 @@ OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(cert = test_get_argument(0)) || !TEST_ptr(privkey = test_get_argument(1))) return 0; diff --git a/test/servername_test.c b/test/servername_test.c index 3d19265db93b1..33e62a169bf2e 100644 --- a/test/servername_test.c +++ b/test/servername_test.c @@ -239,6 +239,11 @@ static int test_servername(int test) int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(cert = test_get_argument(0)) || !TEST_ptr(privkey = test_get_argument(1))) return 0; diff --git a/test/ssl_test.c b/test/ssl_test.c index e54e84182793f..e6ce9a674151c 100644 --- a/test/ssl_test.c +++ b/test/ssl_test.c @@ -506,6 +506,11 @@ int setup_tests(void) { long num_tests; + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(conf = NCONF_new(NULL)) /* argv[1] should point to the test conf file */ || !TEST_int_gt(NCONF_load(conf, test_get_argument(0), NULL), 0) diff --git a/test/ssl_test_ctx_test.c b/test/ssl_test_ctx_test.c index 5f54d1ef24800..fc7ec68f29d16 100644 --- a/test/ssl_test_ctx_test.c +++ b/test/ssl_test_ctx_test.c @@ -244,6 +244,11 @@ OPT_TEST_DECLARE_USAGE("conf_file\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(conf = NCONF_new(NULL))) return 0; /* argument should point to test/ssl_test_ctx_test.conf */ diff --git a/test/sslapitest.c b/test/sslapitest.c index cf0fd3f37d112..0fd569a15399e 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -6972,6 +6972,11 @@ OPT_TEST_DECLARE_USAGE("certfile privkeyfile srpvfile tmpfile\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(certsdir = test_get_argument(0)) || !TEST_ptr(srpvfile = test_get_argument(1)) || !TEST_ptr(tmpfilename = test_get_argument(2))) diff --git a/test/sslbuffertest.c b/test/sslbuffertest.c index 163beafb2f81b..3bce667b462be 100644 --- a/test/sslbuffertest.c +++ b/test/sslbuffertest.c @@ -156,6 +156,11 @@ int setup_tests(void) { char *cert, *pkey; + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(cert = test_get_argument(0)) || !TEST_ptr(pkey = test_get_argument(1))) return 0; diff --git a/test/sslcorrupttest.c b/test/sslcorrupttest.c index 66f8cd142c2a7..d201cd2b27220 100644 --- a/test/sslcorrupttest.c +++ b/test/sslcorrupttest.c @@ -250,6 +250,11 @@ int setup_tests(void) { int n; + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(cert = test_get_argument(0)) || !TEST_ptr(privkey = test_get_argument(1))) return 0; diff --git a/test/testutil.h b/test/testutil.h index 57ab15356c1ce..2a2857a741d4c 100644 --- a/test/testutil.h +++ b/test/testutil.h @@ -193,6 +193,12 @@ char *test_get_argument(size_t n); /* Return the number of additional non optional command line arguments */ size_t test_get_argument_count(void); +/* + * Skip over common test options. Should be called before calling + * test_get_argument() + */ +int test_skip_common_options(void); + /* * Internal helpers. Test programs shouldn't use these directly, but should * rather link to one of the helper main() methods. diff --git a/test/testutil/options.c b/test/testutil/options.c index 9a32d1fb9441f..b5c0739db72a4 100644 --- a/test/testutil/options.c +++ b/test/testutil/options.c @@ -15,6 +15,21 @@ static int used[100] = { 0 }; +int test_skip_common_options(void) +{ + OPTION_CHOICE_DEFAULT o; + + while ((o = (OPTION_CHOICE_DEFAULT)opt_next()) != OPT_EOF) { + switch (o) { + case OPT_TEST_CASES: + break; + default: + case OPT_ERR: + return 0; + } + } + return 1; +} size_t test_get_argument_count(void) { diff --git a/test/tls13ccstest.c b/test/tls13ccstest.c index 999ca5700a25d..2820a0e8fa387 100644 --- a/test/tls13ccstest.c +++ b/test/tls13ccstest.c @@ -492,6 +492,11 @@ OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(cert = test_get_argument(0)) || !TEST_ptr(privkey = test_get_argument(1))) return 0; diff --git a/test/v3ext.c b/test/v3ext.c index 2c8ac6bb20d9e..5cf7581c51691 100644 --- a/test/v3ext.c +++ b/test/v3ext.c @@ -41,6 +41,11 @@ OPT_TEST_DECLARE_USAGE("cert.pem\n") int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(infile = test_get_argument(0))) return 0; diff --git a/test/verify_extra_test.c b/test/verify_extra_test.c index d1da7303b72ce..91ed31b374809 100644 --- a/test/verify_extra_test.c +++ b/test/verify_extra_test.c @@ -263,6 +263,11 @@ static int test_req_sm2_id(void) int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(roots_f = test_get_argument(0)) || !TEST_ptr(untrusted_f = test_get_argument(1)) || !TEST_ptr(bad_f = test_get_argument(2)) diff --git a/test/x509_check_cert_pkey_test.c b/test/x509_check_cert_pkey_test.c index 6c1587b847a3b..b1b6b9c9bfd4c 100644 --- a/test/x509_check_cert_pkey_test.c +++ b/test/x509_check_cert_pkey_test.c @@ -122,6 +122,11 @@ const OPTIONS *test_get_options(void) int setup_tests(void) { + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + if (!TEST_ptr(c = test_get_argument(0)) || !TEST_ptr(k = test_get_argument(1)) || !TEST_ptr(t = test_get_argument(2)) diff --git a/test/x509_dup_cert_test.c b/test/x509_dup_cert_test.c index ebea488b10ea2..b0bf1b9598c0f 100644 --- a/test/x509_dup_cert_test.c +++ b/test/x509_dup_cert_test.c @@ -37,8 +37,14 @@ OPT_TEST_DECLARE_USAGE("cert.pem...\n") int setup_tests(void) { - size_t n = test_get_argument_count(); + size_t n; + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + + n = test_get_argument_count(); if (!TEST_int_gt(n, 0)) return 0; diff --git a/test/x509aux.c b/test/x509aux.c index 1489428d5256f..49b6745d55251 100644 --- a/test/x509aux.c +++ b/test/x509aux.c @@ -165,7 +165,14 @@ OPT_TEST_DECLARE_USAGE("certfile...\n") int setup_tests(void) { - size_t n = test_get_argument_count(); + size_t n; + + if (!test_skip_common_options()) { + TEST_error("Error parsing test options\n"); + return 0; + } + + n = test_get_argument_count(); if (n == 0) return 0;