]> err.no Git - yubikey-personalization/commitdiff
Use new helper function _parse_args_rc.
authorFredrik Thulin <fredrik@yubico.com>
Wed, 9 Mar 2011 09:27:34 +0000 (10:27 +0100)
committerFredrik Thulin <fredrik@yubico.com>
Wed, 9 Mar 2011 09:27:34 +0000 (10:27 +0100)
tests/test_args_to_config.c

index 14c30ca143bfb384f7043d8ce2b149f4d2fa704e..27d3728da20d2e0b6e39faf5e0293729ece4936f 100644 (file)
@@ -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()