summaryrefslogtreecommitdiff
path: root/test/d2i_test.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2017-07-18 11:48:27 +1000
committerPauli <paul.dale@oracle.com>2017-07-27 07:53:08 +1000
commitad887416f1e59c3294a7d8f83a0ca77120523b4a (patch)
tree99971c4acaaa7a43efa38a0d52e230c0e68a1c6c /test/d2i_test.c
parentd445302418b41b76c15e103954b1311d98077480 (diff)
downloadopenssl-new-ad887416f1e59c3294a7d8f83a0ca77120523b4a.tar.gz
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)
Diffstat (limited to 'test/d2i_test.c')
-rw-r--r--test/d2i_test.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/test/d2i_test.c b/test/d2i_test.c
index 58fbe4af2f..0901b5d9fb 100644
--- a/test/d2i_test.c
+++ b/test/d2i_test.c
@@ -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;
}