X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=test%2Fverify_extra_test.c;h=83d93cd9a0c20a75e8c992931976b76b1fe8c958;hp=bfbe5c02f15ff0a1d7eab307361e8d094af923cd;hb=7622baf8a7c3e9084f97a4f41406a29ef5d04fc3;hpb=28b86f313b43cc70d11054d3830ef82e7af8290a diff --git a/test/verify_extra_test.c b/test/verify_extra_test.c index bfbe5c02f1..83d93cd9a0 100644 --- a/test/verify_extra_test.c +++ b/test/verify_extra_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -13,6 +13,11 @@ #include #include #include +#include "testutil.h" + +static const char *roots_f; +static const char *untrusted_f; +static const char *bad_f; static STACK_OF(X509) *load_certs_from_file(const char *filename) { @@ -82,9 +87,7 @@ static STACK_OF(X509) *load_certs_from_file(const char *filename) * CA=FALSE, and will therefore incorrectly verify bad * */ -static int test_alt_chains_cert_forgery(const char *roots_f, - const char *untrusted_f, - const char *bad_f) +static int test_alt_chains_cert_forgery(void) { int ret = 0; int i; @@ -132,31 +135,18 @@ static int test_alt_chains_cert_forgery(const char *roots_f, BIO_free(bio); sk_X509_pop_free(untrusted, X509_free); X509_STORE_free(store); - if (ret != 1) - ERR_print_errors_fp(stderr); return ret; } -int main(int argc, char **argv) +int setup_tests(void) { - CRYPTO_set_mem_debug(1); - CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); - - if (argc != 4) { - fprintf(stderr, "usage: verify_extra_test roots.pem untrusted.pem bad.pem\n"); - return 1; + 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))) { + TEST_error("usage: verify_extra_test roots.pem untrusted.pem bad.pem\n"); + return 0; } - if (!test_alt_chains_cert_forgery(argv[1], argv[2], argv[3])) { - fprintf(stderr, "Test alt chains cert forgery failed\n"); - return 1; - } - -#ifndef OPENSSL_NO_CRYPTO_MDEBUG - if (CRYPTO_mem_leaks_fp(stderr) <= 0) - return 1; -#endif - - printf("PASS\n"); - return 0; + ADD_TEST(test_alt_chains_cert_forgery); + return 1; }