Commit ff74d1ec authored by Dridi Boukelmoune's avatar Dridi Boukelmoune Committed by guillaume quintard

Allow shell commands in client/server specs

With this we can move body checks closer to HTTP checks.
parent d424a373
varnishtest "Write a body to a file"
server s1 {
# First, HTTP checks
rxreq
expect req.http.Content-Type == "text/plain"
# Then, payload checks
write_body req.txt
shell {grep -q request req.txt}
txresp -hdr "Content-Type: text/plain" -body response
} -start
......@@ -11,10 +16,12 @@ varnish v1 -vcl+backend {} -start
client c1 {
txreq -req POST -hdr "Content-Type: text/plain" -body request
# First, HTTP checks
rxresp
expect resp.http.Content-Type == "text/plain"
# Then, payload checks
write_body resp.txt
shell {grep -q response resp.txt}
} -run
shell {grep -q request req.txt}
shell {grep -q response resp.txt}
......@@ -441,8 +441,12 @@ cmd_varnishtest(CMD_ARGS)
*
* The vtc will fail if the return code of the shell is not 0.
*/
/* SECTION: client-server.spec.shell shell
*
* Same as for the top-level shell.
*/
static void
void
cmd_shell(CMD_ARGS)
{
(void)priv;
......@@ -471,8 +475,12 @@ cmd_shell(CMD_ARGS)
* err_shell expect the shell command to fail AND stdout to match the string,
* failing the test case otherwise.
*/
/* SECTION: client-server.spec.shell err_shell
*
* Same as for the top-level err_shell.
*/
static void
void
cmd_err_shell(CMD_ARGS)
{
(void)priv;
......
......@@ -66,6 +66,8 @@ CMD(varnish);
CMD(barrier);
CMD(logexpect);
CMD(process);
CMD(err_shell);
CMD(shell);
#undef CMD
extern volatile sig_atomic_t vtc_error; /* Error, bail out */
......
......@@ -1860,6 +1860,8 @@ static const struct cmds http_cmds[] = {
/* general purpose */
CMD(barrier),
CMD(delay),
CMD(err_shell),
CMD(shell),
#undef CMD_HTTP
#undef CMD
{ NULL, NULL }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment