summaryrefslogtreecommitdiff
path: root/test/test
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2018-10-22 15:15:27 +0200
committerFerruh Yigit <ferruh.yigit@intel.com>2018-10-26 22:14:06 +0200
commitcc0579f2339a1100152fc1bdbed1b579e9618cb7 (patch)
tree26ae1b891017621e19c5bab3eb172fcb495b0322 /test/test
parent6bd7fbd03c6282689415ea3ff99622a631109984 (diff)
downloaddpdk-cc0579f2339a1100152fc1bdbed1b579e9618cb7.zip
dpdk-cc0579f2339a1100152fc1bdbed1b579e9618cb7.tar.gz
dpdk-cc0579f2339a1100152fc1bdbed1b579e9618cb7.tar.xz
kvargs: support list value
If a value contains a comma, rte_kvargs_tokenize() will split here. In order to support list syntax [a,b] as value, an extra parsing of the square brackets is added. Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Diffstat (limited to 'test/test')
-rw-r--r--test/test/test_kvargs.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test/test_kvargs.c b/test/test/test_kvargs.c
index e673862..a42056f 100644
--- a/test/test/test_kvargs.c
+++ b/test/test/test_kvargs.c
@@ -137,6 +137,26 @@ static int test_valid_kvargs(void)
}
rte_kvargs_free(kvlist);
+ /* third test using list as value */
+ args = "foo=[0,1],check=value2";
+ valid_keys = valid_keys_list;
+ kvlist = rte_kvargs_parse(args, valid_keys);
+ if (kvlist == NULL) {
+ printf("rte_kvargs_parse() error");
+ goto fail;
+ }
+ if (strcmp(kvlist->pairs[0].value, "[0,1]") != 0) {
+ printf("wrong value %s", kvlist->pairs[0].value);
+ goto fail;
+ }
+ count = kvlist->count;
+ if (count != 2) {
+ printf("invalid count value %d\n", count);
+ rte_kvargs_free(kvlist);
+ goto fail;
+ }
+ rte_kvargs_free(kvlist);
+
return 0;
fail:
@@ -162,6 +182,7 @@ static int test_invalid_kvargs(void)
"foo=1,,foo=2", /* empty key/value */
"foo=1,foo", /* no value */
"foo=1,=2", /* no key */
+ "foo=[1,2", /* no closing bracket in value */
",=", /* also test with a smiley */
NULL };
const char **args;