X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=test%2Fx509_check_cert_pkey_test.c;h=cf26ed9228435046193900a43bb00379f3c46b8f;hb=2de64666a07cccf8477e6483de62ae31f463df64;hp=003bab86364d3ee112d9a90ffd28529873d8561e;hpb=1efd98f95dd9499854b0685801aa3362d6e14fb2;p=openssl.git diff --git a/test/x509_check_cert_pkey_test.c b/test/x509_check_cert_pkey_test.c index 003bab8636..cf26ed9228 100644 --- a/test/x509_check_cert_pkey_test.c +++ b/test/x509_check_cert_pkey_test.c @@ -1,7 +1,7 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved. * - * Licensed under the OpenSSL license (the "License"). You may not use + * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html @@ -20,8 +20,12 @@ * t: API type, "cert" for X509_ and "req" for X509_REQ_ APIs. * e: expected, "ok" for success, "failed" for what should fail. */ -static int test_x509_check_cert_pkey(const char *c, const char *k, - const char *t, const char *e) +static const char *c; +static const char *k; +static const char *t; +static const char *e; + +static int test_x509_check_cert_pkey(void) { BIO *bio = NULL; X509 *x509 = NULL; @@ -102,13 +106,34 @@ failed: return ret; } -int test_main(int argc, char **argv) +const OPTIONS *test_get_options(void) +{ + enum { OPT_TEST_ENUM }; + static const OPTIONS test_options[] = { + OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("cert key type expected\n"), + { OPT_HELP_STR, 1, '-', "cert\tcertificate or CSR filename in PEM\n" }, + { OPT_HELP_STR, 1, '-', "key\tprivate key filename in PEM\n" }, + { OPT_HELP_STR, 1, '-', "type\t\tvalue must be 'cert' or 'req'\n" }, + { OPT_HELP_STR, 1, '-', "expected\tthe expected return value, either 'ok' or 'failed'\n" }, + { NULL } + }; + return test_options; +} + +int setup_tests(void) { - if (!TEST_int_eq(argc, 5)) { - TEST_info("usage: x509_check_cert_pkey cert.pem|cert.req" - " key.pem cert|req "); - return 1; + 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)) + || !TEST_ptr(e = test_get_argument(3))) { + return 0; } - return !test_x509_check_cert_pkey(argv[1], argv[2], argv[3], argv[4]); + ADD_TEST(test_x509_check_cert_pkey); + return 1; }