From: Fredrik Thulin Date: Wed, 9 Mar 2011 09:27:34 +0000 (+0100) Subject: Use new helper function _parse_args_rc. X-Git-Tag: v1.5.0~2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b5886565ed855ce4c14eb91ee93ada71eea51af;p=yubikey-personalization.old Use new helper function _parse_args_rc. --- diff --git a/tests/test_args_to_config.c b/tests/test_args_to_config.c index 14c30ca..27d3728 100644 --- a/tests/test_args_to_config.c +++ b/tests/test_args_to_config.c @@ -387,110 +387,61 @@ int _test_extended_flags1() int _test_two_slots1() { - YKP_CONFIG *cfg = ykp_create_config(); - YK_STATUS *st = _test_init_st(2, 2, 0); - int rc = 0; - /* Test that it is not possible to choose slot more than once */ char *argv[] = { "unittest", "-1", "-1", NULL }; - int argc = sizeof argv/sizeof argv[0] - 1; - - rc = _test_config(cfg, st, argc, argv); + int rc = _parse_args_rc (argv); assert(rc == 0); - - ykp_free_config(cfg); - free(st); } int _test_two_slots2() { - YKP_CONFIG *cfg = ykp_create_config(); - YK_STATUS *st = _test_init_st(2, 2, 0); - int rc = 0; - /* Test that it is not possible to choose slot more than once */ char *argv[] = { "unittest", "-2", "-1", NULL }; - int argc = sizeof argv/sizeof argv[0] - 1; - - rc = _test_config(cfg, st, argc, argv); + int rc = _parse_args_rc (argv); assert(rc == 0); - - ykp_free_config(cfg); - free(st); } int _test_two_modes_at_once1() { - YKP_CONFIG *cfg = ykp_create_config(); - YK_STATUS *st = _test_init_st(2, 2, 0); - int rc = 0; - /* Test that it is not possible to choose mode (OATH-HOTP/CHAL-RESP) more than once */ char *argv[] = { "unittest", "-ochal-resp", "-ooath-hotp", NULL }; - int argc = sizeof argv/sizeof argv[0] - 1; - - rc = _test_config(cfg, st, argc, argv); + int rc = _parse_args_rc (argv); assert(rc == 0); - - ykp_free_config(cfg); - free(st); } int _test_two_modes_at_once2() { - YKP_CONFIG *cfg = ykp_create_config(); - YK_STATUS *st = _test_init_st(2, 2, 0); - int rc = 0; - /* Test that it is not possible to choose mode (OATH-HOTP/CHAL-RESP) more than once */ char *argv[] = { "unittest", "-ochal-resp", "-ochal-resp", NULL }; - int argc = sizeof argv/sizeof argv[0] - 1; - - rc = _test_config(cfg, st, argc, argv); + int rc = _parse_args_rc (argv); assert(rc == 0); - - ykp_free_config(cfg); - free(st); } int _test_mode_after_other_option() { - YKP_CONFIG *cfg = ykp_create_config(); - YK_STATUS *st = _test_init_st(2, 2, 0); - int rc = 0; - /* Test that it is not possible to set mode after other options */ char *argv[] = { "unittest", "-ohmac-lt64", "-ochal-resp", NULL }; - int argc = sizeof argv/sizeof argv[0] - 1; - - rc = _test_config(cfg, st, argc, argv); + int rc = _parse_args_rc (argv); assert(rc == 0); - - ykp_free_config(cfg); - free(st); } int _test_key_mixed_case1() { - YKP_CONFIG *cfg = ykp_create_config(); - YK_STATUS *st = _test_init_st(2, 2, 0); - int rc = 0; - /* Make sure key with mixed case is rejected (parsing function yubikey_hex_decode * only handles lower case hex) */ @@ -498,13 +449,8 @@ int _test_key_mixed_case1() "unittest", "-1", "-a0000000000000000000000000000000E", NULL }; - int argc = sizeof argv/sizeof argv[0] - 1; - - rc = _test_config(cfg, st, argc, argv); + int rc = _parse_args_rc (argv); assert(rc == 0); - - ykp_free_config(cfg); - free(st); } int _test_uid_for_oath()