summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2014-12-28 16:24:48 +0000
committerjsing <>2014-12-28 16:24:48 +0000
commit820ab7628dd07b64b052b91013ab938ac2b90d64 (patch)
tree191085ee221a5e862669ba6466fcc070983a247c
parentc24a164cd821984a3b548688ddfdd0b5c7a06563 (diff)
downloadopenbsd-820ab7628dd07b64b052b91013ab938ac2b90d64.tar.gz
openbsd-820ab7628dd07b64b052b91013ab938ac2b90d64.tar.bz2
openbsd-820ab7628dd07b64b052b91013ab938ac2b90d64.zip
Add regress tests for multiple argument callback functions.
-rw-r--r--src/regress/usr.bin/openssl/options/optionstest.c39
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;
29CONF *config; 29CONF *config;
30 30
31static int argfunc(char *arg); 31static int argfunc(char *arg);
32static int multiarg(int argc, char **argv, int *argsused);
32 33
33static struct { 34static 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" };
67char *args9[] = { "opts", "-arg", "arg", "-flag", "file1", "-file2", "file3" }; 73char *args9[] = { "opts", "-arg", "arg", "-flag", "file1", "-file2", "file3" };
68char *args10[] = { "opts", "-arg", "arg", "-flag", "-", "file1", "file2" }; 74char *args10[] = { "opts", "-arg", "arg", "-flag", "-", "file1", "file2" };
69char *args11[] = { "opts", "-arg", "arg", "-flag", "-", "-file1", "-file2" }; 75char *args11[] = { "opts", "-arg", "arg", "-flag", "-", "-file1", "-file2" };
76char *args12[] = { "opts", "-multiarg", "arg1", "arg2", "-flag", "unnamed" };
70 77
71struct options_test { 78struct 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
230static int 257static int
258multiarg(int argc, char **argv, int *argsused)
259{
260 if (argc < 3)
261 return (1);
262
263 *argsused = 3;
264 return (0);
265}
266
267static int
231do_options_test(int test_no, struct options_test *ot) 268do_options_test(int test_no, struct options_test *ot)
232{ 269{
233 int *argsused = NULL; 270 int *argsused = NULL;