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)
diff --git a/test/shlibloadtest.c b/test/shlibloadtest.c
index c57ca8f..131d1f6 100644
--- a/test/shlibloadtest.c
+++ b/test/shlibloadtest.c
@@ -175,28 +175,26 @@
#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;
}