diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2018-08-16 12:36:01 +1000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-02-11 15:31:51 +0100 |
commit | a43ce58f5569a160272c492c680f2e42d38ec769 (patch) | |
tree | acfaac32bee9b8e5dd832fbb49f95709c3b9741e /test/bftest.c | |
parent | 9d5560331d86c6463e965321f774e4eed582ce0b (diff) |
Updated test command line parsing to support commmon commands
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6975)
Diffstat (limited to 'test/bftest.c')
-rw-r--r-- | test/bftest.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/test/bftest.c b/test/bftest.c index 2f9b29387b..5b489251c0 100644 --- a/test/bftest.c +++ b/test/bftest.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -434,28 +434,53 @@ static int test_bf_ofb64(void) } #endif +typedef enum OPTION_choice { + OPT_ERR = -1, + OPT_EOF = 0, + OPT_PRINT, + OPT_TEST_ENUM +} OPTION_CHOICE; + +const OPTIONS *test_get_options(void) +{ + static const OPTIONS test_options[] = { + OPT_TEST_OPTIONS_DEFAULT_USAGE, + { "print", OPT_PRINT, '-', "Output test tables instead of running tests"}, + { NULL } + }; + return test_options; +} + int setup_tests(void) { #ifndef OPENSSL_NO_BF + OPTION_CHOICE o; # ifdef CHARSET_EBCDIC int n; - ebcdic2ascii(cbc_data, cbc_data, strlen(cbc_data)); for (n = 0; n < 2; n++) { ebcdic2ascii(bf_key[n], bf_key[n], strlen(bf_key[n])); } # 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); + while ((o = opt_next()) != OPT_EOF) { + switch(o) { + case OPT_PRINT: + print_test_data(); + return 1; + case OPT_TEST_CASES: + break; + default: + return 0; + } } + + 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 1; } |