/*
- * 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
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/err.h>
+#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)
{
* 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;
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;
}