Update the test framework so that the need for test_main is removed. Everything
that needed test_main now works using the same infrastructure as tests that used register_tests. This meant: * renaming register_tests to setup_tests and giving it a success/failure return. * renaming the init_test function to setup_test_framework. * renaming the finish_test function to pulldown_test_framework. * adding a user provided global_init function that runs before the test frame work is initialised. It returns a failure indication that stops the stest. * adding helper functions that permit tests to access their command line args. * spliting the BIO initialisation and finalisation out from the test setup and teardown. * hiding some of the now test internal functions. * fix the comments in testutil.h Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3953)
This commit is contained in:
parent
d445302418
commit
ad887416f1
92 changed files with 627 additions and 555 deletions
|
@ -123,9 +123,10 @@ Generic form of C test executables
|
|||
return testresult;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(my_test); /* Add each test separately */
|
||||
return 1; /* Indicate success */
|
||||
}
|
||||
|
||||
You should use the TEST_xxx macros provided by testutil.h to test all failure
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -85,21 +85,20 @@ static int test_afalg_aes_128_cbc(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
int global_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
#ifdef OPENSSL_NO_ENGINE
|
||||
setup_test();
|
||||
ret = run_tests(argv[0]);
|
||||
#else
|
||||
ENGINE_load_builtin_engines();
|
||||
# ifndef OPENSSL_NO_STATIC_ENGINE
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL);
|
||||
# endif
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
setup_test();
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if ((e = ENGINE_by_id("afalg")) == NULL) {
|
||||
/* Probably a platform env issue, not a test failure. */
|
||||
TEST_info("Can't load AFALG engine");
|
||||
|
@ -108,9 +107,14 @@ int main(int argc, char **argv)
|
|||
ADD_TEST(test_afalg_aes_128_cbc);
|
||||
# endif
|
||||
}
|
||||
ret = run_tests(argv[0]);
|
||||
ENGINE_free(e);
|
||||
#endif
|
||||
|
||||
return finish_test(ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
ENGINE_free(e);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -853,7 +853,7 @@ static int test_uint64(void)
|
|||
return test_intern(&uint64_test_package);
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#if OPENSSL_API_COMPAT < 0x10200000L
|
||||
ADD_TEST(test_long_32bit);
|
||||
|
@ -863,4 +863,5 @@ void register_tests(void)
|
|||
ADD_TEST(test_uint32);
|
||||
ADD_TEST(test_int64);
|
||||
ADD_TEST(test_uint64);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -91,8 +91,9 @@ static int test_standard_methods()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_tbl_standard);
|
||||
ADD_TEST(test_standard_methods);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL licenses, (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -362,22 +362,17 @@ static int test_asyncio(int test)
|
|||
return testresult;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int testresult = 0;
|
||||
|
||||
if (!TEST_int_eq(argc, 3))
|
||||
goto end;
|
||||
|
||||
cert = argv[1];
|
||||
privkey = argv[2];
|
||||
if (!TEST_ptr(cert = test_get_argument(0))
|
||||
|| !TEST_ptr(privkey = test_get_argument(1)))
|
||||
return 0;
|
||||
|
||||
ADD_ALL_TESTS(test_asyncio, 2);
|
||||
|
||||
testresult = run_tests(argv[0]);
|
||||
|
||||
end:
|
||||
BIO_meth_free(methods_async);
|
||||
|
||||
return testresult;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
BIO_meth_free(methods_async);
|
||||
}
|
||||
|
|
|
@ -581,7 +581,8 @@ static int test_bad_dtls(void)
|
|||
return testresult;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_bad_dtls);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -435,7 +435,7 @@ static int test_bf_ofb64(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_BF
|
||||
# ifdef CHARSET_EBCDIC
|
||||
|
@ -447,15 +447,16 @@ int test_main(int argc, char *argv[])
|
|||
}
|
||||
# endif
|
||||
|
||||
if (test_get_argument(0) != NULL) {
|
||||
print_test_data();
|
||||
} else {
|
||||
ADD_ALL_TESTS(test_bf_ecb_raw, 2);
|
||||
ADD_ALL_TESTS(test_bf_ecb, NUM_TESTS);
|
||||
ADD_ALL_TESTS(test_bf_set_key, KEY_TEST_NUM-1);
|
||||
ADD_TEST(test_bf_cbc);
|
||||
ADD_TEST(test_bf_cfb64);
|
||||
ADD_TEST(test_bf_ofb64);
|
||||
|
||||
if (argc > 1)
|
||||
return print_test_data();
|
||||
}
|
||||
#endif
|
||||
return run_tests(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -212,7 +212,7 @@ static int test_bio_enc_chacha20_poly1305(int idx)
|
|||
return do_test_bio_cipher(EVP_chacha20_poly1305(), idx);
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_ALL_TESTS(test_bio_enc_aes_128_cbc, 2);
|
||||
ADD_ALL_TESTS(test_bio_enc_aes_128_ctr, 2);
|
||||
|
@ -224,4 +224,5 @@ void register_tests(void)
|
|||
ADD_ALL_TESTS(test_bio_enc_chacha20_poly1305, 2);
|
||||
# endif
|
||||
# endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -253,17 +253,15 @@ static int test_big(void)
|
|||
}
|
||||
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (argc == 2 && strcmp(argv[1], "-expected") == 0)
|
||||
justprint = 1;
|
||||
justprint = test_has_option("-expected");
|
||||
|
||||
ADD_TEST(test_big);
|
||||
ADD_ALL_TESTS(test_fp, nelem(pw_params));
|
||||
ADD_ALL_TESTS(test_zu, nelem(zu_data));
|
||||
ADD_ALL_TESTS(test_j, nelem(jf_data));
|
||||
|
||||
return run_tests(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-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
|
||||
|
@ -2003,16 +2003,15 @@ static int file_test_run(STANZA *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char * const *testfiles;
|
||||
|
||||
static int run_file_tests(int i)
|
||||
{
|
||||
STANZA *s = NULL;
|
||||
char *testfile = test_get_argument(i);
|
||||
int c;
|
||||
|
||||
if (!TEST_ptr(s = OPENSSL_zalloc(sizeof(*s))))
|
||||
return 0;
|
||||
if (!test_start_file(s, testfiles[i])) {
|
||||
if (!test_start_file(s, testfile)) {
|
||||
OPENSSL_free(s);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2034,18 +2033,17 @@ static int run_file_tests(int i)
|
|||
}
|
||||
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
static const char rnd_seed[] =
|
||||
"If not seeded, BN_generate_prime might fail";
|
||||
int result = EXIT_FAILURE;
|
||||
int n = test_get_argument_count();
|
||||
|
||||
|
||||
RAND_seed(rnd_seed, sizeof rnd_seed);
|
||||
RAND_seed(rnd_seed, sizeof(rnd_seed));
|
||||
if (!TEST_ptr(ctx = BN_CTX_new()))
|
||||
goto end;
|
||||
return 0;
|
||||
|
||||
if (argc < 2) {
|
||||
if (n == 0) {
|
||||
ADD_TEST(test_sub);
|
||||
ADD_TEST(test_div_recip);
|
||||
ADD_TEST(test_mod);
|
||||
|
@ -2074,13 +2072,12 @@ int test_main(int argc, char *argv[])
|
|||
#endif
|
||||
ADD_TEST(test_3_is_prime);
|
||||
} else {
|
||||
testfiles = &argv[1];
|
||||
ADD_ALL_TESTS(run_file_tests, argc - 1);
|
||||
ADD_ALL_TESTS(run_file_tests, n);
|
||||
}
|
||||
|
||||
result = run_tests(argv[0]);
|
||||
|
||||
end:
|
||||
BN_CTX_free(ctx);
|
||||
return result;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ IF[{- !$disabled{tests} -}]
|
|||
testutil/driver.c testutil/tests.c testutil/cb.c testutil/stanza.c \
|
||||
testutil/format_output.c testutil/tap_bio.c \
|
||||
{- rebase_files("../apps", $target{apps_aux_src}) -} \
|
||||
testutil/test_main.c testutil/main.c
|
||||
testutil/test_cleanup.c testutil/main.c testutil/init.c
|
||||
INCLUDE[libtestutil.a]=.. ../include
|
||||
DEPEND[libtestutil.a]=../libcrypto
|
||||
|
||||
|
@ -159,7 +159,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
|
|||
DEPEND[evp_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[evp_extra_test]=evp_extra_test.c
|
||||
INCLUDE[evp_extra_test]=../include
|
||||
INCLUDE[evp_extra_test]=.. ../include
|
||||
DEPEND[evp_extra_test]=../libcrypto libtestutil.a
|
||||
|
||||
SOURCE[igetest]=igetest.c
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-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
|
||||
|
@ -102,10 +102,11 @@ static int cast_test_iterations(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
ADD_ALL_TESTS(cast_test_vector, OSSL_NELEM(k_len));
|
||||
ADD_TEST(cast_test_iterations);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -179,11 +179,12 @@ static int test_cha_cha_internal(int n)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifdef CPUID_OBJ
|
||||
OPENSSL_cpuid_setup();
|
||||
#endif
|
||||
|
||||
ADD_ALL_TESTS(test_cha_cha_internal, sizeof(ref));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -42,7 +42,8 @@ static int cipher_overhead(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(cipher_overhead);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -129,22 +129,21 @@ err:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!TEST_ptr(ctx = SSL_CTX_new(TLS_server_method()))
|
||||
|| !TEST_ptr(s = SSL_new(ctx)))
|
||||
return EXIT_FAILURE;
|
||||
return 0;
|
||||
|
||||
ADD_TEST(test_empty);
|
||||
ADD_TEST(test_unsupported);
|
||||
ADD_TEST(test_v2);
|
||||
ADD_TEST(test_v3);
|
||||
ret = run_tests(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
SSL_free(s);
|
||||
SSL_CTX_free(ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -201,8 +201,9 @@ static int test_default_cipherlist_explicit()
|
|||
EXECUTE_CIPHERLIST_TEST();
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
ADD_TEST(test_default_cipherlist_implicit);
|
||||
ADD_TEST(test_default_cipherlist_explicit);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -463,7 +463,8 @@ err:
|
|||
return ret;
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_cipher_name);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -215,14 +215,11 @@ end:
|
|||
return testresult;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (argc != 2)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
sessionfile = argv[1];
|
||||
if (!TEST_ptr(sessionfile = test_get_argument(0)))
|
||||
return 0;
|
||||
|
||||
ADD_ALL_TESTS(test_client_hello, TOTAL_NUM_TESTS);
|
||||
|
||||
return run_tests(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2014-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
|
||||
|
@ -327,11 +327,12 @@ static int test_64values(int i)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_sizeofs);
|
||||
ADD_ALL_TESTS(test_binops, OSSL_NELEM(test_values));
|
||||
ADD_ALL_TESTS(test_signed, OSSL_NELEM(signed_test_values));
|
||||
ADD_ALL_TESTS(test_8values, OSSL_NELEM(test_values_8));
|
||||
ADD_ALL_TESTS(test_64values, OSSL_NELEM(test_values_64));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -364,23 +364,22 @@ static int test_unknown_critical_crl(int n)
|
|||
return r;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int status = EXIT_FAILURE;
|
||||
|
||||
if (!TEST_ptr(test_root = X509_from_strings(kCRLTestRoot))
|
||||
|| !TEST_ptr(test_leaf = X509_from_strings(kCRLTestLeaf)))
|
||||
goto err;
|
||||
return 0;
|
||||
|
||||
ADD_TEST(test_no_crl);
|
||||
ADD_TEST(test_basic_crl);
|
||||
ADD_TEST(test_bad_issuer_crl);
|
||||
ADD_TEST(test_known_critical_crl);
|
||||
ADD_ALL_TESTS(test_unknown_critical_crl, OSSL_NELEM(unknown_critical_crls));
|
||||
return 1;
|
||||
}
|
||||
|
||||
status = run_tests(argv[0]);
|
||||
err:
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
X509_free(test_root);
|
||||
X509_free(test_leaf);
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -501,7 +501,7 @@ static int test_ctlog_from_base64(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_CT
|
||||
if ((ct_dir = getenv("CT_DIR")) == NULL)
|
||||
|
@ -519,10 +519,8 @@ int test_main(int argc, char *argv[])
|
|||
ADD_TEST(test_encode_tls_sct);
|
||||
ADD_TEST(test_default_ct_policy_eval_ctx_time_is_now);
|
||||
ADD_TEST(test_ctlog_from_base64);
|
||||
|
||||
return run_tests(argv[0]);
|
||||
#else
|
||||
printf("No CT support\n");
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -107,10 +107,10 @@ static int test_bad_asn1()
|
|||
}
|
||||
|
||||
/*
|
||||
* Usage: d2i_test <type> <file>, e.g.
|
||||
* Usage: d2i_test <name> <type> <file>, e.g.
|
||||
* d2i_test generalname bad_generalname.der
|
||||
*/
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
const char *test_type_name;
|
||||
const char *expected_error_string;
|
||||
|
@ -125,15 +125,13 @@ int test_main(int argc, char *argv[])
|
|||
{"compare", ASN1_COMPARE}
|
||||
};
|
||||
|
||||
if (!TEST_int_eq(argc, 4)) {
|
||||
fprintf(stderr, "Usage: d2i_test item_name expected_error file.der\n");
|
||||
return 1;
|
||||
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))) {
|
||||
TEST_note("Usage: d2i_test item_name expected_error file.der");
|
||||
return 0;
|
||||
}
|
||||
|
||||
test_type_name = argv[1];
|
||||
expected_error_string = argv[2];
|
||||
test_file = argv[3];
|
||||
|
||||
item_type = ASN1_ITEM_lookup(test_type_name);
|
||||
|
||||
if (item_type == NULL) {
|
||||
|
@ -146,7 +144,7 @@ int test_main(int argc, char *argv[])
|
|||
break;
|
||||
TEST_note("\t%s", it->sname);
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(expected_errors); i++) {
|
||||
|
@ -158,10 +156,9 @@ int test_main(int argc, char *argv[])
|
|||
|
||||
if (expected_error == ASN1_UNKNOWN) {
|
||||
TEST_error("Unknown expected error %s\n", expected_error_string);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ADD_TEST(test_bad_asn1);
|
||||
|
||||
return run_tests(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -409,22 +409,17 @@ end:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (argc != 4) {
|
||||
if (!TEST_ptr(basedomain = test_get_argument(0))
|
||||
|| !TEST_ptr(CAfile = test_get_argument(1))
|
||||
|| !TEST_ptr(tlsafile = test_get_argument(2))) {
|
||||
TEST_error("Usage error: danetest basedomain CAfile tlsafile");
|
||||
return 0;
|
||||
}
|
||||
basedomain = argv[1];
|
||||
CAfile = argv[2];
|
||||
tlsafile = argv[3];
|
||||
|
||||
ADD_TEST(run_tlsatest);
|
||||
|
||||
ret = run_tests(argv[0]);
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#include <internal/dane.h>
|
||||
|
|
|
@ -693,7 +693,7 @@ static int test_des_quad_cksum(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_DES
|
||||
ADD_ALL_TESTS(test_des_ecb, NUM_TESTS);
|
||||
|
@ -717,4 +717,5 @@ void register_tests(void)
|
|||
ADD_ALL_TESTS(test_input_align, 4);
|
||||
ADD_ALL_TESTS(test_output_align, 4);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,7 @@
|
|||
#include <openssl/err.h>
|
||||
#include "testutil.h"
|
||||
|
||||
#ifdef OPENSSL_NO_DH
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("No DH support\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#else
|
||||
#ifndef OPENSSL_NO_DH
|
||||
# include <openssl/dh.h>
|
||||
|
||||
static int cb(int p, int n, BN_GENCB *arg);
|
||||
|
@ -507,11 +501,16 @@ static int rfc5114_test(void)
|
|||
TEST_error("Test failed RFC5114 set %d\n", i + 1);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifdef OPENSSL_NO_DH
|
||||
TEST_note("No DH support");
|
||||
#else
|
||||
ADD_TEST(dh_test);
|
||||
ADD_TEST(rfc5114_test);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -476,15 +476,11 @@ err:
|
|||
}
|
||||
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (argc != 1) {
|
||||
TEST_error("Usage: %s", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
app_data_index = RAND_DRBG_get_ex_new_index(0L, NULL, NULL, NULL, NULL);
|
||||
|
||||
ADD_ALL_TESTS(test_kats, OSSL_NELEM(drbg_test));
|
||||
ADD_ALL_TESTS(test_error_checks, OSSL_NELEM(drbg_test));
|
||||
return run_tests(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-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
|
||||
|
@ -137,9 +137,10 @@ static int dsa_cb(int p, int n, BN_GENCB *arg)
|
|||
}
|
||||
#endif /* OPENSSL_NO_DSA */
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
ADD_TEST(dsa_test);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -189,7 +189,8 @@ static int run_mtu_tests(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
ADD_TEST(run_mtu_tests);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -93,22 +93,18 @@ static int test_dtls_unprocessed(int testidx)
|
|||
return testresult;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int testresult = 1;
|
||||
|
||||
if (!TEST_int_eq(argc, 3))
|
||||
return 1;
|
||||
|
||||
cert = argv[1];
|
||||
privkey = argv[2];
|
||||
if (!TEST_ptr(cert = test_get_argument(0))
|
||||
|| !TEST_ptr(privkey = test_get_argument(1)))
|
||||
return 0;
|
||||
|
||||
ADD_ALL_TESTS(test_dtls_unprocessed, NUM_TESTS);
|
||||
return 1;
|
||||
}
|
||||
|
||||
testresult = run_tests(argv[0]);
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
bio_f_tls_dump_filter_free();
|
||||
bio_s_mempacket_test_free();
|
||||
|
||||
return testresult;
|
||||
}
|
||||
|
|
|
@ -348,9 +348,10 @@ static int dtls_listen_test(int i)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
ADD_ALL_TESTS(dtls_listen_test, (int)OSSL_NELEM(testpackets));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2002-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
|
@ -396,7 +396,7 @@ static int test_builtin(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifdef OPENSSL_NO_EC
|
||||
TEST_note("Elliptic curves are disabled.");
|
||||
|
@ -406,4 +406,5 @@ void register_tests(void)
|
|||
ADD_TEST(x9_62_tests);
|
||||
ADD_TEST(test_builtin);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -123,39 +123,28 @@ static int atoi64(const char *in, int64_t *result)
|
|||
* |num| times and prints the resulting X-coordinate. Otherwise runs the test
|
||||
* the default number of times and compares against the expected result.
|
||||
*/
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
const char *argv0 = argv[0];
|
||||
const char *p;
|
||||
|
||||
if (!atoi64(NUM_REPEATS, &num_repeats)) {
|
||||
TEST_error("Cannot parse " NUM_REPEATS);
|
||||
return EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* TODO(openssl-team): code under test/ should be able to reuse the option
|
||||
* parsing framework currently in apps/.
|
||||
*/
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-num") == 0) {
|
||||
if (--argc < 1
|
||||
|| !atoi64(*++argv, &num_repeats)
|
||||
|| num_repeats < 0) {
|
||||
TEST_error("Bad -num argument\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
p = test_get_option_argument("-num");
|
||||
if (p != NULL) {
|
||||
if (!atoi64(p, &num_repeats)
|
||||
|| num_repeats < 0)
|
||||
return 0;
|
||||
print_mode = 1;
|
||||
} else {
|
||||
TEST_error("Unknown option %s\n", *argv);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ADD_TEST(test_curve);
|
||||
#endif
|
||||
return run_tests(argv0);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1430,15 +1430,13 @@ static const char rnd_seed[] =
|
|||
"string to make the random number generator think it has randomness";
|
||||
#endif
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int result = EXIT_SUCCESS;
|
||||
#ifndef OPENSSL_NO_EC
|
||||
|
||||
crv_len = EC_get_builtin_curves(NULL, 0);
|
||||
if (!TEST_ptr(curves = OPENSSL_malloc(sizeof(*curves) * crv_len))
|
||||
|| !TEST_true(EC_get_builtin_curves(curves, crv_len)))
|
||||
return EXIT_FAILURE;
|
||||
return 0;
|
||||
|
||||
RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */
|
||||
|
||||
|
@ -1453,9 +1451,11 @@ int test_main(int argc, char *argv[])
|
|||
# endif
|
||||
ADD_ALL_TESTS(internal_curve_test, crv_len);
|
||||
ADD_ALL_TESTS(internal_curve_test_method, crv_len);
|
||||
|
||||
result = run_tests(argv[0]);
|
||||
OPENSSL_free(curves);
|
||||
#endif
|
||||
return result;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
OPENSSL_free(curves);
|
||||
}
|
||||
|
|
|
@ -12,13 +12,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef OPENSSL_NO_ENGINE
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("No ENGINE support\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#else
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
# include <openssl/buffer.h>
|
||||
# include <openssl/crypto.h>
|
||||
# include <openssl/engine.h>
|
||||
|
@ -180,9 +174,14 @@ static int test_engines(void)
|
|||
ENGINE_free(block[loop]);
|
||||
return to_return;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
{
|
||||
ADD_TEST(test_engines);
|
||||
}
|
||||
#endif
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifdef OPENSSL_NO_ENGINE
|
||||
TEST_note("No ENGINE support");
|
||||
#else
|
||||
ADD_TEST(test_engines);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -16,6 +16,7 @@
|
|||
#include <openssl/rsa.h>
|
||||
#include <openssl/x509.h>
|
||||
#include "testutil.h"
|
||||
#include "e_os.h"
|
||||
|
||||
/*
|
||||
* kExampleRSAKeyDER is an RSA private key in ASN.1, DER format. Of course, you
|
||||
|
@ -346,13 +347,13 @@ static int test_EVP_PKCS82PKEY(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_EVP_DigestSignInit);
|
||||
ADD_TEST(test_EVP_DigestVerifyInit);
|
||||
ADD_ALL_TESTS(test_d2i_AutoPrivateKey,
|
||||
sizeof(keydata) / sizeof(keydata[0]));
|
||||
ADD_ALL_TESTS(test_d2i_AutoPrivateKey, OSSL_NELEM(keydata));
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ADD_TEST(test_EVP_PKCS82PKEY);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -2510,16 +2510,15 @@ top:
|
|||
return 1;
|
||||
}
|
||||
|
||||
static char * const *testfiles;
|
||||
|
||||
static int run_file_tests(int i)
|
||||
{
|
||||
EVP_TEST *t;
|
||||
const char *testfile = test_get_argument(i);
|
||||
int c;
|
||||
|
||||
if (!TEST_ptr(t = OPENSSL_zalloc(sizeof(*t))))
|
||||
return 0;
|
||||
if (!test_start_file(&t->s, testfiles[i])) {
|
||||
if (!test_start_file(&t->s, testfile)) {
|
||||
OPENSSL_free(t);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2544,15 +2543,15 @@ static int run_file_tests(int i)
|
|||
return c == 0;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (argc < 2) {
|
||||
TEST_error("Usage: %s file...", argv[0]);
|
||||
size_t n = test_get_argument_count();
|
||||
|
||||
if (n == 0) {
|
||||
TEST_error("Usage: %s file...", test_get_program_name());
|
||||
return 0;
|
||||
}
|
||||
testfiles = &argv[1];
|
||||
|
||||
ADD_ALL_TESTS(run_file_tests, argc - 1);
|
||||
|
||||
return run_tests(argv[0]);
|
||||
ADD_ALL_TESTS(run_file_tests, n);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -258,7 +258,8 @@ static int test_exdata(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_exdata);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -198,8 +198,9 @@ static int test_mod_exp(int round)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_mod_exp_zero);
|
||||
ADD_ALL_TESTS(test_mod_exp, 200);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -55,10 +55,11 @@ static int test_gmtime(int offset)
|
|||
check_time(-offset * 1000L);
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (sizeof(time_t) < 8)
|
||||
TEST_info("Skipping; time_t is less than 64-bits");
|
||||
else
|
||||
ADD_ALL_TESTS_NOSUBTEST(test_gmtime, 1000000);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -236,12 +236,13 @@ static char *pt(unsigned char *md, unsigned int len)
|
|||
}
|
||||
# endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_ALL_TESTS(test_hmac_md5, 4);
|
||||
ADD_TEST(test_hmac_single_shot);
|
||||
ADD_TEST(test_hmac_bad);
|
||||
ADD_TEST(test_hmac_run);
|
||||
ADD_TEST(test_hmac_copy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,11 +108,12 @@ static int test_idea_cfb64(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
ADD_TEST(test_idea_ecb);
|
||||
ADD_TEST(test_idea_cbc);
|
||||
ADD_TEST(test_idea_cfb64);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2006-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
|
||||
|
@ -433,7 +433,7 @@ static int test_bi_ige_garble3(void)
|
|||
return TEST_size_t_le(matches, sizeof checktext / 100);
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
RAND_bytes(rkey, sizeof rkey);
|
||||
RAND_bytes(rkey2, sizeof rkey2);
|
||||
|
@ -450,4 +450,5 @@ void register_tests(void)
|
|||
ADD_TEST(test_bi_ige_garble3);
|
||||
ADD_ALL_TESTS(test_ige_vectors, OSSL_NELEM(ige_test_vectors));
|
||||
ADD_ALL_TESTS(test_bi_ige_vectors, OSSL_NELEM(bi_ige_test_vectors));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -220,8 +220,9 @@ end:
|
|||
return testresult;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_int_lhash);
|
||||
ADD_TEST(test_stress);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -58,9 +58,10 @@ static int test_md2(int n)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
ADD_ALL_TESTS(test_md2, OSSL_NELEM(test));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -64,7 +64,8 @@ static int test_mdc2(int idx)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
ADD_ALL_TESTS(test_mdc2, OSSL_NELEM(tests));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -69,9 +69,10 @@ static int test_mdc2(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_MDC2
|
||||
ADD_TEST(test_mdc2);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -949,33 +949,22 @@ static void benchmark_gcm128(const unsigned char *K, size_t Klen,
|
|||
#endif
|
||||
}
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
int result = 0;
|
||||
int iter_argv;
|
||||
int benchmark = 0;
|
||||
|
||||
for (iter_argv = 1; iter_argv < argc; iter_argv++) {
|
||||
if (strcmp(argv[iter_argv], "-b") == 0)
|
||||
benchmark = 1;
|
||||
else if (strcmp(argv[iter_argv], "-h") == 0)
|
||||
goto help;
|
||||
if (test_has_option("-h")) {
|
||||
printf("-h\tThis help\n");
|
||||
printf("-b\tBenchmark gcm128 in addition to the tests\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ADD_ALL_TESTS(test_cts128, OSSL_NELEM(cts128_vectors));
|
||||
ADD_ALL_TESTS(test_cts128_nist, OSSL_NELEM(cts128_vectors));
|
||||
ADD_ALL_TESTS(test_gcm128, OSSL_NELEM(gcm128_vectors));
|
||||
|
||||
result = run_tests(argv[0]);
|
||||
|
||||
if (benchmark)
|
||||
benchmark_gcm128(K1, sizeof(K1), IV1, sizeof(IV1));
|
||||
|
||||
return result;
|
||||
|
||||
help:
|
||||
printf("-h\tThis help\n");
|
||||
printf("-b\tBenchmark gcm128 in addition to the tests\n");
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
if (test_has_option("-b"))
|
||||
benchmark_gcm128(K1, sizeof(K1), IV1, sizeof(IV1));
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -460,7 +460,7 @@ static int test_PACKET_as_length_prefixed_2()
|
|||
return 1;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -490,4 +490,5 @@ void register_tests(void)
|
|||
ADD_TEST(test_PACKET_get_length_prefixed_3);
|
||||
ADD_TEST(test_PACKET_as_length_prefixed_1);
|
||||
ADD_TEST(test_PACKET_as_length_prefixed_2);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -43,7 +43,8 @@ static int test_pbelu(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_pbelu);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -69,8 +69,9 @@ static int test_invalid(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_b64);
|
||||
ADD_TEST(test_invalid);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,8 @@ static int test_asn1_meths()
|
|||
return good;
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
ADD_TEST(test_asn1_meths);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -1609,31 +1609,20 @@ static int test_poly1305(int idx)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
int result = 0;
|
||||
int iter_argv;
|
||||
int benchmark = 0;
|
||||
|
||||
for (iter_argv = 1; iter_argv < argc; iter_argv++) {
|
||||
if (strcmp(argv[iter_argv], "-b") == 0)
|
||||
benchmark = 1;
|
||||
else if (strcmp(argv[iter_argv], "-h") == 0)
|
||||
goto help;
|
||||
if (test_has_option("-h")) {
|
||||
printf("-h\tThis help\n");
|
||||
printf("-b\tBenchmark in addition to the tests\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ADD_ALL_TESTS(test_poly1305, OSSL_NELEM(tests));
|
||||
|
||||
result = run_tests(argv[0]);
|
||||
|
||||
if (benchmark)
|
||||
benchmark_poly1305();
|
||||
|
||||
return result;
|
||||
|
||||
help:
|
||||
printf("-h\tThis help\n");
|
||||
printf("-b\tBenchmark in addition to the tests\n");
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
if (test_has_option("-b"))
|
||||
benchmark_poly1305();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-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
|
||||
|
@ -103,7 +103,8 @@ static int fips_random_tests(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(fips_random_tests);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -59,9 +59,10 @@ static int test_rc2(const int n)
|
|||
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
ADD_ALL_TESTS(test_rc2, OSSL_NELEM(RC2key));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ static int test_rc_bulk(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
ADD_ALL_TESTS(test_rc4_encrypt, OSSL_NELEM(data_len));
|
||||
|
@ -124,4 +124,5 @@ void register_tests(void)
|
|||
ADD_ALL_TESTS(test_rc4_multi_call, data_len[3]);
|
||||
ADD_TEST(test_rc_bulk);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -224,10 +224,11 @@ static int test_rc5_cbc(int n)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
ADD_ALL_TESTS(test_rc5_ecb, OSSL_NELEM(RC5key));
|
||||
ADD_ALL_TESTS(test_rc5_cbc, RC5_CBC_NUM);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -184,22 +184,17 @@ static int test_record_overflow(int idx)
|
|||
return testresult;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int testresult = 1;
|
||||
|
||||
if (argc != 3) {
|
||||
TEST_error("Invalid argument count");
|
||||
return 1;
|
||||
}
|
||||
cert = argv[1];
|
||||
privkey = argv[2];
|
||||
if (!TEST_ptr(cert = test_get_argument(0))
|
||||
|| !TEST_ptr(privkey = test_get_argument(1)))
|
||||
return 0;
|
||||
|
||||
ADD_ALL_TESTS(test_record_overflow, TOTAL_RECORD_OVERFLOW_TESTS);
|
||||
|
||||
testresult = run_tests(argv[0]);
|
||||
|
||||
bio_s_mempacket_test_free();
|
||||
|
||||
return testresult;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
bio_s_mempacket_test_free();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "testutil.h"
|
||||
|
||||
#ifdef OPENSSL_NO_RSA
|
||||
void register_tests(void)
|
||||
void setup_tests(void)
|
||||
{
|
||||
/* No tests */
|
||||
}
|
||||
|
@ -328,9 +328,10 @@ err:
|
|||
return ret;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_ALL_TESTS(test_rsa_pkcs1, 3);
|
||||
ADD_ALL_TESTS(test_rsa_oaep, 3);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -75,12 +75,13 @@ static int test_sanity_unsigned_convertion(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_sanity_null_zero);
|
||||
ADD_TEST(test_sanity_enum_size);
|
||||
ADD_TEST(test_sanity_twos_complement);
|
||||
ADD_TEST(test_sanity_sign);
|
||||
ADD_TEST(test_sanity_unsigned_convertion);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,8 @@ static int test_sec_mem(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_sec_mem);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -175,28 +175,26 @@ end:
|
|||
#endif
|
||||
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (argc != 4) {
|
||||
TEST_error("Unexpected number of arguments");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
const char *p = test_get_argument(0);
|
||||
|
||||
if (strcmp(argv[1], "-crypto_first") == 0) {
|
||||
if (strcmp(p, "-crypto_first") == 0) {
|
||||
test_type = CRYPTO_FIRST;
|
||||
} else if (strcmp(argv[1], "-ssl_first") == 0) {
|
||||
} else if (strcmp(p, "-ssl_first") == 0) {
|
||||
test_type = SSL_FIRST;
|
||||
} else if (strcmp(argv[1], "-just_crypto") == 0) {
|
||||
} else if (strcmp(p, "-just_crypto") == 0) {
|
||||
test_type = JUST_CRYPTO;
|
||||
} else {
|
||||
TEST_error("Unrecognised argument");
|
||||
return EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
path_crypto = argv[2];
|
||||
path_ssl = argv[3];
|
||||
if (!TEST_ptr(path_crypto = test_get_argument(1))
|
||||
|| !TEST_ptr(path_ssl = test_get_argument(2)))
|
||||
return 0;
|
||||
|
||||
#if defined(DSO_DLFCN) || defined(DSO_WIN32)
|
||||
ADD_TEST(test_lib);
|
||||
#endif
|
||||
return run_tests(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -319,11 +319,13 @@ static int test_siphash_basic(void)
|
|||
&& TEST_true(SipHash_Final(&siphash, output, 16));
|
||||
}
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
int result = 0;
|
||||
int iter_argv;
|
||||
int benchmark = 0;
|
||||
if (test_has_option("-h")) {
|
||||
BIO_printf(bio_out, "-h\tThis help\n");
|
||||
BIO_printf(bio_out, "-b\tBenchmark in addition to the tests\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
b_stderr = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
b_stdout = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
@ -332,28 +334,15 @@ int test_main(int argc, char **argv)
|
|||
b_stdout = BIO_push(BIO_new(BIO_f_linebuffer()), b_stdout);
|
||||
#endif
|
||||
|
||||
for (iter_argv = 1; iter_argv < argc; iter_argv++) {
|
||||
if (strcmp(argv[iter_argv], "-b") == 0)
|
||||
benchmark = 1;
|
||||
else if (strcmp(argv[iter_argv], "-h") == 0)
|
||||
goto help;
|
||||
}
|
||||
|
||||
ADD_TEST(test_siphash_basic);
|
||||
ADD_ALL_TESTS(test_siphash, OSSL_NELEM(tests));
|
||||
if (benchmark)
|
||||
if (test_has_option("-b"))
|
||||
ADD_TEST(benchmark_siphash);
|
||||
return 1;
|
||||
}
|
||||
|
||||
result = run_tests(argv[0]);
|
||||
goto out;
|
||||
|
||||
help:
|
||||
BIO_printf(b_stdout, "-h\tThis help\n");
|
||||
BIO_printf(b_stdout, "-b\tBenchmark in addition to the tests\n");
|
||||
|
||||
out:
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
BIO_free(b_stdout);
|
||||
BIO_free(b_stderr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2011-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
|
||||
|
@ -264,7 +264,7 @@ static int run_srp_tests(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifdef OPENSSL_NO_SRP
|
||||
printf("No SRP support\n");
|
||||
|
@ -272,4 +272,5 @@ void register_tests(void)
|
|||
ADD_TEST(run_srp_tests);
|
||||
ADD_TEST(run_srp_kat);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,8 @@ static int test_ssl_cert_table()
|
|||
return 1;
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
ADD_TEST(test_ssl_cert_table);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -428,23 +428,22 @@ err:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
int result = EXIT_FAILURE;
|
||||
long num_tests;
|
||||
|
||||
if (!TEST_int_eq(argc, 2)
|
||||
|| !TEST_ptr(conf = NCONF_new(NULL))
|
||||
if (!TEST_ptr(conf = NCONF_new(NULL))
|
||||
/* argv[1] should point to the test conf file */
|
||||
|| !TEST_int_gt(NCONF_load(conf, argv[1], NULL), 0)
|
||||
|| !TEST_int_gt(NCONF_load(conf, test_get_argument(0), NULL), 0)
|
||||
|| !TEST_int_ne(NCONF_get_number_e(conf, NULL, "num_tests",
|
||||
&num_tests), 0))
|
||||
goto err;
|
||||
return 0;
|
||||
|
||||
ADD_ALL_TESTS(test_handshake, (int)(num_tests));
|
||||
result = run_tests(argv[0]);
|
||||
|
||||
err:
|
||||
NCONF_free(conf);
|
||||
return result;
|
||||
ADD_ALL_TESTS(test_handshake, (int)num_tests);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
NCONF_free(conf);
|
||||
}
|
||||
|
|
|
@ -215,25 +215,23 @@ static int test_bad_configuration(int idx)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (argc != 2) {
|
||||
TEST_info("Missing file argument");
|
||||
goto end;
|
||||
if (!TEST_ptr(conf = NCONF_new(NULL)))
|
||||
return 0;
|
||||
/* argument should point to test/ssl_test_ctx_test.conf */
|
||||
if (!TEST_int_gt(NCONF_load(conf, test_get_argument(0), NULL), 0)) {
|
||||
TEST_note("Missing file argument");
|
||||
return 0;
|
||||
}
|
||||
if (!TEST_ptr(conf = NCONF_new(NULL))
|
||||
/* argv[1] should point to test/ssl_test_ctx_test.conf */
|
||||
|| !TEST_int_gt(NCONF_load(conf, argv[1], NULL), 0))
|
||||
goto end;
|
||||
|
||||
ADD_TEST(test_empty_configuration);
|
||||
ADD_TEST(test_good_configuration);
|
||||
ADD_ALL_TESTS(test_bad_configuration, OSSL_NELEM(bad_configurations));
|
||||
result = run_tests(argv[0]);
|
||||
|
||||
end:
|
||||
NCONF_free(conf);
|
||||
return result;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
NCONF_free(conf);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -2703,17 +2703,11 @@ static int test_ssl_clear(int idx)
|
|||
return testresult;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int testresult = 1;
|
||||
|
||||
if (argc != 3) {
|
||||
TEST_error("Wrong argument count");
|
||||
if (!TEST_ptr(cert = test_get_argument(0))
|
||||
|| !TEST_ptr(privkey = test_get_argument(1)))
|
||||
return 0;
|
||||
}
|
||||
|
||||
cert = argv[1];
|
||||
privkey = argv[2];
|
||||
|
||||
ADD_TEST(test_large_message_tls);
|
||||
ADD_TEST(test_large_message_tls_read_ahead);
|
||||
|
@ -2759,10 +2753,10 @@ int test_main(int argc, char *argv[])
|
|||
ADD_ALL_TESTS(test_serverinfo, 8);
|
||||
ADD_ALL_TESTS(test_export_key_mat, 4);
|
||||
ADD_ALL_TESTS(test_ssl_clear, 2);
|
||||
|
||||
testresult = run_tests(argv[0]);
|
||||
|
||||
bio_s_mempacket_test_free();
|
||||
|
||||
return testresult;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
bio_s_mempacket_test_free();
|
||||
}
|
||||
|
|
|
@ -248,24 +248,24 @@ static int test_ssl_corrupt(int testidx)
|
|||
return testresult;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int ret = EXIT_FAILURE, n;
|
||||
int n;
|
||||
|
||||
if (argc != 3) {
|
||||
TEST_error("Usage error: require cert and private key files");
|
||||
return ret;
|
||||
if (!TEST_ptr(cert = test_get_argument(0))
|
||||
|| !TEST_ptr(privkey = test_get_argument(1))) {
|
||||
TEST_note("Usage error: require cert and private key files");
|
||||
return 0;
|
||||
}
|
||||
cert = argv[1];
|
||||
privkey = argv[2];
|
||||
|
||||
n = setup_cipher_list();
|
||||
if (n > 0) {
|
||||
if (n > 0)
|
||||
ADD_ALL_TESTS(test_ssl_corrupt, n);
|
||||
ret = run_tests(argv[0]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
bio_f_tls_corrupt_filter_free();
|
||||
OPENSSL_free(cipher_list);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -362,10 +362,11 @@ end:
|
|||
return testresult;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_int_stack);
|
||||
ADD_TEST(test_uchar_stack);
|
||||
ADD_TEST(test_SS_stack);
|
||||
ADD_TEST(test_SU_stack);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -509,7 +509,7 @@ static int test_bn_output(int n)
|
|||
}
|
||||
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_int);
|
||||
ADD_TEST(test_uint);
|
||||
|
@ -530,4 +530,5 @@ void register_tests(void)
|
|||
ADD_TEST(test_single_eval);
|
||||
ADD_TEST(test_output);
|
||||
ADD_ALL_TESTS(test_bn_output, OSSL_NELEM(bn_output_tests));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -17,34 +17,31 @@
|
|||
#include <openssl/bn.h>
|
||||
|
||||
/*-
|
||||
* Simple unit tests should implement register_tests().
|
||||
* Simple unit tests should implement setup_tests().
|
||||
* This function should return zero if the registration process fails.
|
||||
* To register tests, call ADD_TEST or ADD_ALL_TESTS:
|
||||
*
|
||||
* void register_tests(void)
|
||||
* int setup_tests(void)
|
||||
* {
|
||||
* ADD_TEST(test_foo);
|
||||
* ADD_ALL_TESTS(test_bar, num_test_bar);
|
||||
* return 1;
|
||||
* }
|
||||
*
|
||||
* Tests that need to perform custom setup or read command-line arguments should
|
||||
* implement test_main():
|
||||
* Tests that require clean up after execution should implement:
|
||||
*
|
||||
* int test_main(int argc, char *argv[])
|
||||
* {
|
||||
* int ret;
|
||||
* void cleanup_tests(void);
|
||||
*
|
||||
* // Custom setup ...
|
||||
* The cleanup_tests function will be called even if setup_tests()
|
||||
* returns failure.
|
||||
*
|
||||
* ADD_TEST(test_foo);
|
||||
* ADD_ALL_TESTS(test_bar, num_test_bar);
|
||||
* // Add more tests ...
|
||||
* In some cases, early initialization before the framework is set up
|
||||
* may be needed. In such a case, this should be implemented:
|
||||
*
|
||||
* ret = run_tests(argv[0]);
|
||||
* int global_init(void);
|
||||
*
|
||||
* // Custom teardown ...
|
||||
*
|
||||
* return ret;
|
||||
* }
|
||||
* This function should return zero if there is an unrecoverable error and
|
||||
* non-zero if the intialization was successful.
|
||||
*/
|
||||
|
||||
/* Adds a simple test case. */
|
||||
|
@ -123,31 +120,39 @@
|
|||
# define TEST_CASE_NAME __func__
|
||||
# endif /* __STDC_VERSION__ */
|
||||
|
||||
/*
|
||||
* Tests that need access to command line arguments should use the functions:
|
||||
* test_get_argument(int n) to get the nth argument, the first argument is
|
||||
* argument 0. This function returns NULL on error.
|
||||
* test_get_argument_count() to get the count of the arguments.
|
||||
* test_has_option(const char *) to check if the specified option was passed.
|
||||
* test_get_option_argument(const char *) to get an option which includes an
|
||||
* argument. NULL is returns if the option is not found.
|
||||
* const char *test_get_program_name(void) returns the name of the test program
|
||||
* being executed.
|
||||
*/
|
||||
const char *test_get_program_name(void);
|
||||
char *test_get_argument(size_t n);
|
||||
size_t test_get_argument_count(void);
|
||||
int test_has_option(const char *option);
|
||||
const char *test_get_option_argument(const char *option);
|
||||
|
||||
/*
|
||||
* Internal helpers. Test programs shouldn't use these directly, but should
|
||||
* rather link to one of the helper main() methods.
|
||||
*/
|
||||
|
||||
/* setup_test() should be called as the first thing in a test main(). */
|
||||
void setup_test(void);
|
||||
/*
|
||||
* finish_test() should be called as the last thing in a test main().
|
||||
* The result of run_tests() should be the input to finish_test().
|
||||
*/
|
||||
__owur int finish_test(int ret);
|
||||
|
||||
void add_test(const char *test_case_name, int (*test_fn) ());
|
||||
void add_all_tests(const char *test_case_name, int (*test_fn)(int idx), int num,
|
||||
int subtest);
|
||||
__owur int run_tests(const char *test_prog_name);
|
||||
void set_test_title(const char *title);
|
||||
|
||||
/*
|
||||
* Declarations for user defined functions
|
||||
* Declarations for user defined functions.
|
||||
* The first two return a boolean indicating that the test should not proceed.
|
||||
*/
|
||||
void register_tests(void);
|
||||
int test_main(int argc, char *argv[]);
|
||||
|
||||
int global_init(void);
|
||||
int setup_tests(void);
|
||||
void cleanup_tests(void);
|
||||
|
||||
/*
|
||||
* Test assumption verification helpers.
|
||||
|
|
|
@ -95,13 +95,11 @@ static int gcd(int a, int b)
|
|||
return a;
|
||||
}
|
||||
|
||||
void setup_test()
|
||||
void setup_test_framework()
|
||||
{
|
||||
char *TAP_levels = getenv("HARNESS_OSSL_LEVEL");
|
||||
char *test_seed = getenv("OPENSSL_TEST_RAND_ORDER");
|
||||
|
||||
test_open_streams();
|
||||
|
||||
level = TAP_levels != NULL ? 4 * atoi(TAP_levels) : 0;
|
||||
|
||||
if (test_seed != NULL) {
|
||||
|
@ -121,7 +119,7 @@ void setup_test()
|
|||
#endif
|
||||
}
|
||||
|
||||
int finish_test(int ret)
|
||||
int pulldown_test_framework(int ret)
|
||||
{
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
if (should_report_leaks()
|
||||
|
@ -129,8 +127,6 @@ int finish_test(int ret)
|
|||
return EXIT_FAILURE;
|
||||
#endif
|
||||
|
||||
test_close_streams();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -150,10 +146,28 @@ void set_test_title(const char *title)
|
|||
test_title = title == NULL ? NULL : strdup(title);
|
||||
}
|
||||
|
||||
PRINTF_FORMAT(2, 3) static void test_verdict(int pass, const char *extra, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
test_flush_stdout();
|
||||
test_flush_stderr();
|
||||
|
||||
test_printf_stdout("%*s%s", level, "", pass ? "ok" : "not ok");
|
||||
if (extra != NULL) {
|
||||
test_printf_stdout(" ");
|
||||
va_start(ap, extra);
|
||||
test_vprintf_stdout(extra, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
test_printf_stdout("\n");
|
||||
test_flush_stdout();
|
||||
}
|
||||
|
||||
int run_tests(const char *test_prog_name)
|
||||
{
|
||||
int num_failed = 0;
|
||||
char *verdict = NULL;
|
||||
int verdict = 1;
|
||||
int ii, i, jj, j, jstep;
|
||||
int permute[OSSL_NELEM(all_tests)];
|
||||
|
||||
|
@ -185,18 +199,12 @@ int run_tests(const char *test_prog_name)
|
|||
set_test_title(all_tests[i].test_case_name);
|
||||
ret = all_tests[i].test_fn();
|
||||
|
||||
test_flush_stdout();
|
||||
test_flush_stderr();
|
||||
|
||||
verdict = "ok";
|
||||
verdict = 1;
|
||||
if (!ret) {
|
||||
verdict = "not ok";
|
||||
verdict = 0;
|
||||
++num_failed;
|
||||
}
|
||||
test_printf_stdout("%*s%s %d - %s\n", level, "", verdict, ii + 1,
|
||||
test_title);
|
||||
test_flush_stdout();
|
||||
test_flush_stderr();
|
||||
test_verdict(verdict, "%d - %s", ii + 1, test_title);
|
||||
finalize(ret);
|
||||
} else {
|
||||
int num_failed_inner = 0;
|
||||
|
@ -225,39 +233,33 @@ int run_tests(const char *test_prog_name)
|
|||
set_test_title(NULL);
|
||||
ret = all_tests[i].param_test_fn(j);
|
||||
|
||||
test_flush_stdout();
|
||||
test_flush_stderr();
|
||||
|
||||
if (!ret)
|
||||
++num_failed_inner;
|
||||
|
||||
finalize(ret);
|
||||
|
||||
if (all_tests[i].subtest) {
|
||||
verdict = "ok";
|
||||
verdict = 1;
|
||||
if (!ret) {
|
||||
verdict = "not ok";
|
||||
verdict = 0;
|
||||
++num_failed_inner;
|
||||
}
|
||||
if (test_title != NULL)
|
||||
test_printf_stdout("%*s%s %d - %s\n", level, "",
|
||||
verdict, jj + 1, test_title);
|
||||
test_verdict(verdict, "%d - %s", jj + 1, test_title);
|
||||
else
|
||||
test_printf_stdout("%*s%s %d - iteration %d\n", level,
|
||||
"", verdict, jj + 1, j + 1);
|
||||
test_flush_stdout();
|
||||
test_verdict(verdict, "%d - iteration %d",
|
||||
jj + 1, j + 1);
|
||||
}
|
||||
}
|
||||
|
||||
level -= 4;
|
||||
verdict = "ok";
|
||||
verdict = 1;
|
||||
if (num_failed_inner) {
|
||||
verdict = "not ok";
|
||||
verdict = 0;
|
||||
++num_failed;
|
||||
}
|
||||
test_printf_stdout("%*s%s %d - %s\n", level, "", verdict, ii + 1,
|
||||
test_verdict(verdict, "%d - %s", ii + 1,
|
||||
all_tests[i].test_case_name);
|
||||
test_flush_stdout();
|
||||
}
|
||||
}
|
||||
if (num_failed != 0)
|
||||
|
|
15
test/testutil/init.c
Normal file
15
test/testutil/init.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright 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
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "../testutil.h"
|
||||
|
||||
int global_init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
|
@ -8,13 +8,99 @@
|
|||
*/
|
||||
|
||||
#include "../testutil.h"
|
||||
#include "../../e_os.h"
|
||||
#include "output.h"
|
||||
#include "tu_local.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static size_t arg_count;
|
||||
static char **args;
|
||||
static unsigned char arg_used[1000];
|
||||
|
||||
static void check_arg_usage(void)
|
||||
{
|
||||
size_t i, n = arg_count < OSSL_NELEM(arg_used) ? arg_count
|
||||
: OSSL_NELEM(arg_used);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (!arg_used[i+1])
|
||||
test_printf_stderr("Warning ignored command-line argument %d: %s\n",
|
||||
i, args[i+1]);
|
||||
if (i < arg_count)
|
||||
test_printf_stderr("Warning arguments %zu and later unchecked\n", i);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
setup_test();
|
||||
int ret = EXIT_FAILURE;
|
||||
|
||||
ret = test_main(argc, argv);
|
||||
test_open_streams();
|
||||
|
||||
return finish_test(ret);
|
||||
if (!global_init()) {
|
||||
test_printf_stderr("Global init failed - aborting\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
arg_count = argc - 1;
|
||||
args = argv;
|
||||
|
||||
setup_test_framework();
|
||||
|
||||
if (setup_tests())
|
||||
ret = run_tests(argv[0]);
|
||||
cleanup_tests();
|
||||
check_arg_usage();
|
||||
|
||||
ret = pulldown_test_framework(ret);
|
||||
test_close_streams();
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char *test_get_program_name(void)
|
||||
{
|
||||
return args[0];
|
||||
}
|
||||
|
||||
char *test_get_argument(size_t n)
|
||||
{
|
||||
if (n > arg_count)
|
||||
return NULL;
|
||||
if (n + 1 < OSSL_NELEM(arg_used))
|
||||
arg_used[n + 1] = 1;
|
||||
return args[n + 1];
|
||||
}
|
||||
|
||||
size_t test_get_argument_count(void)
|
||||
{
|
||||
return arg_count;
|
||||
}
|
||||
|
||||
int test_has_option(const char *option)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 1; i <= arg_count; i++)
|
||||
if (strcmp(args[i], option) == 0) {
|
||||
arg_used[i] = 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *test_get_option_argument(const char *option)
|
||||
{
|
||||
size_t i, n = strlen(option);
|
||||
|
||||
for (i = 1; i <= arg_count; i++)
|
||||
if (strncmp(args[i], option, n) == 0) {
|
||||
arg_used[i] = 1;
|
||||
if (args[i][n] == '\0' && i + 1 < arg_count) {
|
||||
arg_used[++i] = 1;
|
||||
return args[i];
|
||||
}
|
||||
return args[i] + n;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "e_os.h"
|
||||
#include "../testutil.h"
|
||||
#include "tu_local.h"
|
||||
|
||||
int test_start_file(STANZA *s, const char *testfile)
|
||||
{
|
||||
|
|
14
test/testutil/test_cleanup.c
Normal file
14
test/testutil/test_cleanup.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright 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
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "../testutil.h"
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Copyright 2016-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
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "../testutil.h"
|
||||
#include "output.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1)
|
||||
test_printf_stderr("Warning: ignoring extra command-line arguments.\n");
|
||||
|
||||
register_tests();
|
||||
return run_tests(argv[0]);
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
#include <stdlib.h> /* size_t */
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/bio.h>
|
||||
#include "../testutil.h"
|
||||
|
||||
int subtest_level(void);
|
||||
int openssl_error_cb(const char *str, size_t len, void *u);
|
||||
|
@ -43,3 +44,8 @@ void test_fail_memory_message(const char *prefix, const char *file,
|
|||
const unsigned char *m1, size_t l1,
|
||||
const unsigned char *m2, size_t l2);
|
||||
|
||||
void setup_test_framework(void);
|
||||
__owur int pulldown_test_framework(int ret);
|
||||
|
||||
__owur int run_tests(const char *test_prog_name);
|
||||
void set_test_title(const char *title);
|
||||
|
|
|
@ -184,9 +184,10 @@ static int test_thread_local(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_lock);
|
||||
ADD_TEST(test_once);
|
||||
ADD_TEST(test_thread_local);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,8 @@ static int test_offset(int idx)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
ADD_ALL_TESTS(test_offset, OSSL_NELEM(tests));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -398,7 +398,8 @@ static int test_tls13_encryption(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_tls13_encryption);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -384,7 +384,8 @@ static int test_handshake_secrets(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
ADD_TEST(test_handshake_secrets);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2002-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
|
||||
|
@ -88,8 +88,9 @@ static int test_new_ui()
|
|||
return ok;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_old);
|
||||
ADD_TEST(test_new_ui);
|
||||
return 1;
|
||||
}
|
||||
|
|
14
test/v3ext.c
14
test/v3ext.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -37,17 +37,11 @@ end:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (argc != 2) {
|
||||
TEST_error("Usage error");
|
||||
if (!TEST_ptr(infile = test_get_argument(0)))
|
||||
return 0;
|
||||
}
|
||||
infile = argv[1];
|
||||
|
||||
ADD_TEST(test_pathlen);
|
||||
ret = run_tests(argv[0]);
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2012-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
|
||||
|
@ -353,7 +353,8 @@ static int call_run_cert(int i)
|
|||
return failed == 0;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_ALL_TESTS(call_run_cert, sizeof(name_fns) / sizeof(name_fns[0]));
|
||||
ADD_ALL_TESTS(call_run_cert, OSSL_NELEM(name_fns));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -15,6 +15,10 @@
|
|||
#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)
|
||||
{
|
||||
STACK_OF(X509) *certs;
|
||||
|
@ -83,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;
|
||||
|
@ -136,14 +138,15 @@ static int test_alt_chains_cert_forgery(const char *roots_f,
|
|||
return ret;
|
||||
}
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (argc != 4) {
|
||||
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 EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!TEST_true(test_alt_chains_cert_forgery(argv[1], argv[2], argv[3])))
|
||||
return EXIT_FAILURE;
|
||||
return EXIT_SUCCESS;
|
||||
ADD_TEST(test_alt_chains_cert_forgery);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-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
|
||||
|
@ -360,10 +360,8 @@ static int test_WPACKET_memcpy(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
int testresult = 0;
|
||||
|
||||
if (!TEST_ptr(buf = BUF_MEM_new()))
|
||||
return 0;
|
||||
|
||||
|
@ -373,8 +371,10 @@ int test_main(int argc, char *argv[])
|
|||
ADD_TEST(test_WPACKET_set_flags);
|
||||
ADD_TEST(test_WPACKET_allocate_bytes);
|
||||
ADD_TEST(test_WPACKET_memcpy);
|
||||
testresult = run_tests(argv[0]);
|
||||
|
||||
BUF_MEM_free(buf);
|
||||
return testresult;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
BUF_MEM_free(buf);
|
||||
}
|
||||
|
|
|
@ -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,17 @@ failed:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (!TEST_int_eq(argc, 5)) {
|
||||
TEST_info("usage: x509_check_cert_pkey cert.pem|cert.req"
|
||||
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))) {
|
||||
TEST_note("usage: x509_check_cert_pkey cert.pem|cert.req"
|
||||
" key.pem cert|req <expected>");
|
||||
return 1;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -14,12 +14,13 @@
|
|||
|
||||
#include "testutil.h"
|
||||
|
||||
static int test_509_dup_cert(const char *cert_f)
|
||||
static int test_509_dup_cert(int n)
|
||||
{
|
||||
int ret = 0;
|
||||
X509_STORE_CTX *sctx = NULL;
|
||||
X509_STORE *store = NULL;
|
||||
X509_LOOKUP *lookup = NULL;
|
||||
const char *cert_f = test_get_argument(n);
|
||||
|
||||
if (TEST_ptr(store = X509_STORE_new())
|
||||
&& TEST_ptr(lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file()))
|
||||
|
@ -32,12 +33,15 @@ static int test_509_dup_cert(const char *cert_f)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int test_main(int argc, char **argv)
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (!TEST_int_eq(argc, 2)) {
|
||||
TEST_info("usage: x509_dup_cert_test cert.pem");
|
||||
return 1;
|
||||
size_t n = test_get_argument_count();
|
||||
|
||||
if (!TEST_int_gt(n, 0)) {
|
||||
TEST_note("usage: x509_dup_cert_test cert.pem...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return !test_509_dup_cert(argv[1]);
|
||||
ADD_ALL_TESTS(test_509_dup_cert, n);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,8 @@ static int test_standard_exts()
|
|||
return good;
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
ADD_TEST(test_standard_exts);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -424,10 +424,11 @@ static int test_days(int n)
|
|||
return r;
|
||||
}
|
||||
|
||||
void register_tests()
|
||||
int setup_tests()
|
||||
{
|
||||
ADD_TEST(test_x509_cmp_time_current);
|
||||
ADD_ALL_TESTS(test_x509_cmp_time, OSSL_NELEM(x509_cmp_tests));
|
||||
ADD_ALL_TESTS(test_x509_time, OSSL_NELEM(x509_format_tests));
|
||||
ADD_ALL_TESTS(test_days, OSSL_NELEM(day_of_week_tests));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
#include "e_os.h"
|
||||
#include "testutil.h"
|
||||
|
||||
|
||||
/* List of files, from argv */
|
||||
static char **files;
|
||||
|
||||
static int test_certs(int num)
|
||||
{
|
||||
int c;
|
||||
|
@ -33,7 +29,7 @@ static int test_certs(int num)
|
|||
typedef X509 *(*d2i_X509_t)(X509 **, const unsigned char **, long);
|
||||
typedef int (*i2d_X509_t)(X509 *, unsigned char **);
|
||||
int err = 0;
|
||||
BIO *fp = BIO_new_file(files[num], "r");
|
||||
BIO *fp = BIO_new_file(test_get_argument(num), "r");
|
||||
|
||||
if (!TEST_ptr(fp))
|
||||
return 0;
|
||||
|
@ -156,14 +152,15 @@ static int test_certs(int num)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int test_main(int argc, char *argv[])
|
||||
int setup_tests(void)
|
||||
{
|
||||
if (argc < 2) {
|
||||
TEST_error("usage: %s certfile...", argv[0]);
|
||||
size_t n = test_get_argument_count();
|
||||
|
||||
if (n == 0) {
|
||||
TEST_error("usage: %s certfile...", test_get_program_name());
|
||||
return 0;
|
||||
}
|
||||
|
||||
files = &argv[1];
|
||||
ADD_ALL_TESTS(test_certs, argc - 1);
|
||||
return run_tests(argv[0]);
|
||||
ADD_ALL_TESTS(test_certs, n);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue