summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/README3
-rw-r--r--test/afalgtest.c30
-rw-r--r--test/asn1_encode_test.c3
-rw-r--r--test/asn1_internal_test.c3
-rw-r--r--test/asynciotest.c23
-rw-r--r--test/bad_dtls_test.c3
-rw-r--r--test/bftest.c23
-rw-r--r--test/bio_enc_test.c5
-rw-r--r--test/bioprinttest.c8
-rw-r--r--test/bntest.c29
-rw-r--r--test/build.info4
-rw-r--r--test/casttest.c5
-rw-r--r--test/chacha_internal_test.c3
-rw-r--r--test/cipher_overhead_test.c5
-rw-r--r--test/cipherbytes_test.c13
-rw-r--r--test/cipherlist_test.c3
-rw-r--r--test/ciphername_test.c3
-rw-r--r--test/clienthellotest.c13
-rw-r--r--test/constant_time_test.c5
-rw-r--r--test/crltest.c13
-rw-r--r--test/ct_test.c6
-rw-r--r--test/d2i_test.c23
-rw-r--r--test/danetest.c17
-rw-r--r--test/destest.c3
-rw-r--r--test/dhtest.c17
-rw-r--r--test/drbgtest.c8
-rw-r--r--test/dsatest.c5
-rw-r--r--test/dtls_mtu_test.c5
-rw-r--r--test/dtlstest.c20
-rw-r--r--test/dtlsv1listentest.c3
-rw-r--r--test/ecdsatest.c5
-rw-r--r--test/ecstresstest.c31
-rw-r--r--test/ectest.c14
-rw-r--r--test/enginetest.c17
-rw-r--r--test/evp_extra_test.c9
-rw-r--r--test/evp_test.c19
-rw-r--r--test/exdatatest.c3
-rw-r--r--test/exptest.c3
-rw-r--r--test/gmdifftest.c3
-rw-r--r--test/hmactest.c3
-rw-r--r--test/ideatest.c3
-rw-r--r--test/igetest.c5
-rw-r--r--test/lhash_test.c3
-rw-r--r--test/md2test.c3
-rw-r--r--test/mdc2_internal_test.c5
-rw-r--r--test/mdc2test.c3
-rw-r--r--test/modes_internal_test.c33
-rw-r--r--test/packettest.c5
-rw-r--r--test/pbelutest.c5
-rw-r--r--test/pemtest.c3
-rw-r--r--test/pkey_meth_test.c3
-rw-r--r--test/poly1305_internal_test.c33
-rw-r--r--test/randtest.c5
-rw-r--r--test/rc2test.c3
-rw-r--r--test/rc4test.c3
-rw-r--r--test/rc5test.c3
-rw-r--r--test/recordlentest.c21
-rw-r--r--test/rsa_test.c5
-rw-r--r--test/sanitytest.c3
-rw-r--r--test/secmemtest.c3
-rw-r--r--test/shlibloadtest.c22
-rw-r--r--test/siphash_internal_test.c33
-rw-r--r--test/srptest.c5
-rw-r--r--test/ssl_cert_table_internal_test.c3
-rw-r--r--test/ssl_test.c19
-rw-r--r--test/ssl_test_ctx_test.c24
-rw-r--r--test/sslapitest.c22
-rw-r--r--test/sslcorrupttest.c24
-rw-r--r--test/stack_test.c3
-rw-r--r--test/test_test.c3
-rw-r--r--test/testutil.h63
-rw-r--r--test/testutil/driver.c64
-rw-r--r--test/testutil/init.c15
-rw-r--r--test/testutil/main.c94
-rw-r--r--test/testutil/stanza.c1
-rw-r--r--test/testutil/test_cleanup.c14
-rw-r--r--test/testutil/test_main.c22
-rw-r--r--test/testutil/tu_local.h6
-rw-r--r--test/threadstest.c3
-rw-r--r--test/time_offset_test.c3
-rw-r--r--test/tls13encryptiontest.c3
-rw-r--r--test/tls13secretstest.c5
-rw-r--r--test/uitest.c5
-rw-r--r--test/v3ext.c14
-rw-r--r--test/v3nametest.c7
-rw-r--r--test/verify_extra_test.c23
-rw-r--r--test/wpackettest.c12
-rw-r--r--test/x509_check_cert_pkey_test.c22
-rw-r--r--test/x509_dup_cert_test.c16
-rw-r--r--test/x509_internal_test.c3
-rw-r--r--test/x509_time_test.c3
-rw-r--r--test/x509aux.c19
92 files changed, 604 insertions, 532 deletions
diff --git a/test/README b/test/README
index bc96ff2aea..d8526806a8 100644
--- a/test/README
+++ b/test/README
@@ -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
diff --git a/test/afalgtest.c b/test/afalgtest.c
index 40ea025405..62dcdb2277 100644
--- a/test/afalgtest.c
+++ b/test/afalgtest.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
@@ -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
diff --git a/test/asn1_encode_test.c b/test/asn1_encode_test.c
index 9b8cdcaf3a..b8ec168943 100644
--- a/test/asn1_encode_test.c
+++ b/test/asn1_encode_test.c
@@ -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;
}
diff --git a/test/asn1_internal_test.c b/test/asn1_internal_test.c
index 38ef6100c1..194a073788 100644
--- a/test/asn1_internal_test.c
+++ b/test/asn1_internal_test.c
@@ -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;
}
diff --git a/test/asynciotest.c b/test/asynciotest.c
index ee450dafd3..aa6076ba01 100644
--- a/test/asynciotest.c
+++ b/test/asynciotest.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 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);
+ return 1;
+}
- testresult = run_tests(argv[0]);
-
- end:
+void cleanup_tests(void)
+{
BIO_meth_free(methods_async);
-
- return testresult;
}
diff --git a/test/bad_dtls_test.c b/test/bad_dtls_test.c
index 9745ff8720..2c10a1cc5b 100644
--- a/test/bad_dtls_test.c
+++ b/test/bad_dtls_test.c
@@ -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;
}
diff --git a/test/bftest.c b/test/bftest.c
index df2c9a7af5..cc509f2dfc 100644
--- a/test/bftest.c
+++ b/test/bftest.c
@@ -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
- 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();
+ 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);
+ }
#endif
- return run_tests(argv[0]);
+ return 1;
}
diff --git a/test/bio_enc_test.c b/test/bio_enc_test.c
index bc49a7992a..8474dc516e 100644
--- a/test/bio_enc_test.c
+++ b/test/bio_enc_test.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
@@ -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;
}
diff --git a/test/bioprinttest.c b/test/bioprinttest.c
index 2c51b7a8b5..d35bffa840 100644
--- a/test/bioprinttest.c
+++ b/test/bioprinttest.c
@@ -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;
}
/*
diff --git a/test/bntest.c b/test/bntest.c
index 59148b0366..a570d0099b 100644
--- a/test/bntest.c
+++ b/test/bntest.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
@@ -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);
}
+ return 1;
+}
- result = run_tests(argv[0]);
-
-end:
+void cleanup_tests(void)
+{
BN_CTX_free(ctx);
- return result;
}
diff --git a/test/build.info b/test/build.info
index 7b8f654a34..2e8775e44f 100644
--- a/test/build.info
+++ b/test/build.info
@@ -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
diff --git a/test/casttest.c b/test/casttest.c
index 24cfbfd455..0fdcb100cc 100644
--- a/test/casttest.c
+++ b/test/casttest.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;
}
diff --git a/test/chacha_internal_test.c b/test/chacha_internal_test.c
index e3d1c4997b..be44012187 100644
--- a/test/chacha_internal_test.c
+++ b/test/chacha_internal_test.c
@@ -179,11 +179,12 @@ static int test_cha_cha_internal(int n)
return 1;
}
-void register_tests(voi