diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2014-12-28 16:24:49 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2014-12-28 16:24:49 +0000 |
commit | 4900786ecb370079fc87903fb8b513c4d0757239 (patch) | |
tree | 57bbbcee9c99bb296b6d7b8170185da3ea4cc66c /regress | |
parent | aec002be9e98a9b250be62a66f544c498e942d19 (diff) |
Add regress tests for multiple argument callback functions.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/usr.bin/openssl/options/optionstest.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/regress/usr.bin/openssl/options/optionstest.c b/regress/usr.bin/openssl/options/optionstest.c index ee756b78803..771e436fe54 100644 --- a/regress/usr.bin/openssl/options/optionstest.c +++ b/regress/usr.bin/openssl/options/optionstest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: optionstest.c,v 1.5 2014/12/28 16:11:54 jsing Exp $ */ +/* $OpenBSD: optionstest.c,v 1.6 2014/12/28 16:24:48 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> * @@ -29,6 +29,7 @@ BIO *bio_err; CONF *config; static int argfunc(char *arg); +static int multiarg(int argc, char **argv, int *argsused); static struct { char *arg; @@ -53,6 +54,11 @@ static struct option test_options[] = { .type = OPTION_FLAG, .opt.flag = &test_config.flag, }, + { + .name = "multiarg", + .type = OPTION_ARGV_FUNC, + .opt.argvfunc = multiarg, + }, { NULL }, }; @@ -67,6 +73,7 @@ char *args8[] = { "opts", "-arg", "arg", "-flag", "file1", "file2", "file3" }; char *args9[] = { "opts", "-arg", "arg", "-flag", "file1", "-file2", "file3" }; char *args10[] = { "opts", "-arg", "arg", "-flag", "-", "file1", "file2" }; char *args11[] = { "opts", "-arg", "arg", "-flag", "-", "-file1", "-file2" }; +char *args12[] = { "opts", "-multiarg", "arg1", "arg2", "-flag", "unnamed" }; struct options_test { int argc; @@ -215,6 +222,26 @@ struct options_test options_tests[] = { .wantarg = "arg", .wantflag = 1, }, + { + /* Test 15 - Multiple argument callback. */ + .argc = 6, + .argv = args12, + .unnamed = "unnamed", + .type = OPTIONS_TEST_UNNAMED, + .want = 0, + .wantarg = NULL, + .wantflag = 1, + }, + { + /* Test 16 - Multiple argument callback. */ + .argc = 6, + .argv = args12, + .used = 5, + .type = OPTIONS_TEST_ARGSUSED, + .want = 0, + .wantarg = NULL, + .wantflag = 1, + }, }; #define N_OPTIONS_TESTS \ @@ -228,6 +255,16 @@ argfunc(char *arg) } static int +multiarg(int argc, char **argv, int *argsused) +{ + if (argc < 3) + return (1); + + *argsused = 3; + return (0); +} + +static int do_options_test(int test_no, struct options_test *ot) { int *argsused = NULL; |