From 8d242823ed2270e2907914fb09004ae30263fb00 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Thu, 30 Jan 2020 15:30:17 +0000 Subject: Fix common test framework options PR#6975 added the ability to our test framework to have common options to all tests. For example providing the option "-test 5" to one of our test programs will just run test number 5. This can be useful when debugging tests. Unforuntately this does not work well for a number of tests. In particular those tests that call test_get_argument() without first skipping over these common test options will not get the expected value. Some tests did this correctly but a large number did not. A helper function is introduced, test_skip_common_options(), to make this easier for those tests which do not have their own specialised test option handling, but yet still need to call test_get_argument(). This function call is then added to all those tests that need it. Reviewed-by: Shane Lontis Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/10975) --- test/testutil/options.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/testutil') diff --git a/test/testutil/options.c b/test/testutil/options.c index 9a32d1f..b5c0739 100644 --- a/test/testutil/options.c +++ b/test/testutil/options.c @@ -15,6 +15,21 @@ static int used[100] = { 0 }; +int test_skip_common_options(void) +{ + OPTION_CHOICE_DEFAULT o; + + while ((o = (OPTION_CHOICE_DEFAULT)opt_next()) != OPT_EOF) { + switch (o) { + case OPT_TEST_CASES: + break; + default: + case OPT_ERR: + return 0; + } + } + return 1; +} size_t test_get_argument_count(void) { -- cgit v1.1