Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vav: fix issues and improve tests #4021

Merged
merged 5 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/varnishtest/tests/b00008.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ varnish v1 -cliexpect 60 "param.show first_byte_timeout"
varnish v1 -cliok "param.set cli_limit 128"

varnish v1 -clierr 201 "param.show"

varnish v1 -cliok "\"help\" \"help\""
24 changes: 15 additions & 9 deletions lib/libvarnish/vav.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ VAV_ParseTxt(const char *b, const char *e, int *argc, int flag)
b++;
continue;
}
if (sep != NULL && *sep == '"' && *b == '"') {
if (sep != NULL && *sep == '"' &&
*b == ',' && (flag & ARGV_COMMA)) {
sep = NULL;
b++;
continue;
}
if (sep != NULL && *sep == '"' && *b == '"' && (b - sep) < 2) {
argv[0] = err_missing_separator;
return (argv);
}
Expand Down Expand Up @@ -401,6 +407,8 @@ static const struct test_case *tests[] = {
TEST_PASS( N, "foo\"bar", "foo\"bar"),
TEST_FAIL(0 , "foo\"bar", invalid_quote),
TEST_FAIL(0 , "foo\"bar", invalid_quote),
TEST_PASS(0 , "\"foo\" \"bar\"", "foo", "bar"),
TEST_PASS( C , "\"foo\",\"bar\"", "foo", "bar"),
TEST_PASS( N, "\"foo\"\"bar\"", "\"foo\"\"bar\""),
TEST_FAIL(0 , "\"foo\"\"bar\"", missing_separator),
NULL
Expand Down Expand Up @@ -441,9 +449,6 @@ test_run(const struct test_case *tc, int *ret)
return (argv);
}

if (tc->argv[0] != NULL)
return (argv);

for (i = 1; i < argc && tc->argv[i] != NULL && argv[i] != NULL; i++) {
if (!strcmp(tc->argv[i], argv[i]))
continue;
Expand All @@ -455,7 +460,7 @@ test_run(const struct test_case *tc, int *ret)
return (argv);
}

if (tc->argv[i] != NULL || argv[i] != NULL) {
if (tc->argv[0] == NULL && (tc->argv[i] != NULL || argv[i] != NULL)) {
walid-git marked this conversation as resolved.
Show resolved Hide resolved
act = i < argc ? "less" : "more";
printf(
"ERROR: Parsing string <%s> with flags %x, "
Expand All @@ -474,16 +479,17 @@ int
main(int argc, char **argv)
{
const struct test_case **tc;
int ret = 0;
int ret = 0, fail = 0;

(void)argc;
(void)argv;

for (tc = tests; ret == 0 && *tc != NULL; tc++) {
for (tc = tests; *tc != NULL; ret = 0, tc++) {
argv = test_run(*tc, &ret);
VAV_Free(argv);
if (ret)
fail = 1;
}

return (0);
return (fail);
}
#endif /* TEST_DRIVER */