diff options
| author | jsing <> | 2014-12-28 16:24:48 +0000 |
|---|---|---|
| committer | jsing <> | 2014-12-28 16:24:48 +0000 |
| commit | fc3f7c64d2079b7a0eee82331194b54f30799874 (patch) | |
| tree | 191085ee221a5e862669ba6466fcc070983a247c | |
| parent | 4eb0a7a0a04348c425df5fc594de04a50beb7f6a (diff) | |
| download | openbsd-fc3f7c64d2079b7a0eee82331194b54f30799874.tar.gz openbsd-fc3f7c64d2079b7a0eee82331194b54f30799874.tar.bz2 openbsd-fc3f7c64d2079b7a0eee82331194b54f30799874.zip | |
Add regress tests for multiple argument callback functions.
Diffstat (limited to '')
| -rw-r--r-- | src/regress/usr.bin/openssl/options/optionstest.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/regress/usr.bin/openssl/options/optionstest.c b/src/regress/usr.bin/openssl/options/optionstest.c index ee756b7880..771e436fe5 100644 --- a/src/regress/usr.bin/openssl/options/optionstest.c +++ b/src/regress/usr.bin/openssl/options/optionstest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: optionstest.c,v 1.5 2014/12/28 16:11:54 jsing Exp $ */ | 1 | /* $OpenBSD: optionstest.c,v 1.6 2014/12/28 16:24:48 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -29,6 +29,7 @@ BIO *bio_err; | |||
| 29 | CONF *config; | 29 | CONF *config; |
| 30 | 30 | ||
| 31 | static int argfunc(char *arg); | 31 | static int argfunc(char *arg); |
| 32 | static int multiarg(int argc, char **argv, int *argsused); | ||
| 32 | 33 | ||
| 33 | static struct { | 34 | static struct { |
| 34 | char *arg; | 35 | char *arg; |
| @@ -53,6 +54,11 @@ static struct option test_options[] = { | |||
| 53 | .type = OPTION_FLAG, | 54 | .type = OPTION_FLAG, |
| 54 | .opt.flag = &test_config.flag, | 55 | .opt.flag = &test_config.flag, |
| 55 | }, | 56 | }, |
| 57 | { | ||
| 58 | .name = "multiarg", | ||
| 59 | .type = OPTION_ARGV_FUNC, | ||
| 60 | .opt.argvfunc = multiarg, | ||
| 61 | }, | ||
| 56 | { NULL }, | 62 | { NULL }, |
| 57 | }; | 63 | }; |
| 58 | 64 | ||
| @@ -67,6 +73,7 @@ char *args8[] = { "opts", "-arg", "arg", "-flag", "file1", "file2", "file3" }; | |||
| 67 | char *args9[] = { "opts", "-arg", "arg", "-flag", "file1", "-file2", "file3" }; | 73 | char *args9[] = { "opts", "-arg", "arg", "-flag", "file1", "-file2", "file3" }; |
| 68 | char *args10[] = { "opts", "-arg", "arg", "-flag", "-", "file1", "file2" }; | 74 | char *args10[] = { "opts", "-arg", "arg", "-flag", "-", "file1", "file2" }; |
| 69 | char *args11[] = { "opts", "-arg", "arg", "-flag", "-", "-file1", "-file2" }; | 75 | char *args11[] = { "opts", "-arg", "arg", "-flag", "-", "-file1", "-file2" }; |
| 76 | char *args12[] = { "opts", "-multiarg", "arg1", "arg2", "-flag", "unnamed" }; | ||
| 70 | 77 | ||
| 71 | struct options_test { | 78 | struct options_test { |
| 72 | int argc; | 79 | int argc; |
| @@ -215,6 +222,26 @@ struct options_test options_tests[] = { | |||
| 215 | .wantarg = "arg", | 222 | .wantarg = "arg", |
| 216 | .wantflag = 1, | 223 | .wantflag = 1, |
| 217 | }, | 224 | }, |
| 225 | { | ||
| 226 | /* Test 15 - Multiple argument callback. */ | ||
| 227 | .argc = 6, | ||
| 228 | .argv = args12, | ||
| 229 | .unnamed = "unnamed", | ||
| 230 | .type = OPTIONS_TEST_UNNAMED, | ||
| 231 | .want = 0, | ||
| 232 | .wantarg = NULL, | ||
| 233 | .wantflag = 1, | ||
| 234 | }, | ||
| 235 | { | ||
| 236 | /* Test 16 - Multiple argument callback. */ | ||
| 237 | .argc = 6, | ||
| 238 | .argv = args12, | ||
| 239 | .used = 5, | ||
| 240 | .type = OPTIONS_TEST_ARGSUSED, | ||
| 241 | .want = 0, | ||
| 242 | .wantarg = NULL, | ||
| 243 | .wantflag = 1, | ||
| 244 | }, | ||
| 218 | }; | 245 | }; |
| 219 | 246 | ||
| 220 | #define N_OPTIONS_TESTS \ | 247 | #define N_OPTIONS_TESTS \ |
| @@ -228,6 +255,16 @@ argfunc(char *arg) | |||
| 228 | } | 255 | } |
| 229 | 256 | ||
| 230 | static int | 257 | static int |
| 258 | multiarg(int argc, char **argv, int *argsused) | ||
| 259 | { | ||
| 260 | if (argc < 3) | ||
| 261 | return (1); | ||
| 262 | |||
| 263 | *argsused = 3; | ||
| 264 | return (0); | ||
| 265 | } | ||
| 266 | |||
| 267 | static int | ||
| 231 | do_options_test(int test_no, struct options_test *ot) | 268 | do_options_test(int test_no, struct options_test *ot) |
| 232 | { | 269 | { |
| 233 | int *argsused = NULL; | 270 | int *argsused = NULL; |
