[master] c56b6ee Make it possible to test that a shell command fails with a specific wait/exit code.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Mar 11 10:51:46 CET 2015
commit c56b6ee1877dfc7a1556c425473a55e2b2b69556
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Mar 11 09:50:57 2015 +0000
Make it possible to test that a shell command fails with a
specific wait/exit code.
diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index 6abc7bb..4cf7941 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -420,6 +420,30 @@ cmd_shell(CMD_ARGS)
r = system(av[1]);
AZ(WEXITSTATUS(r));
}
+/**********************************************************************
+ * Shell command execution
+ */
+
+static void
+cmd_shell_err(CMD_ARGS)
+{
+ (void)priv;
+ (void)cmd;
+ int r;
+
+ if (av == NULL)
+ return;
+ AN(av[1]);
+ AN(av[2]);
+ AZ(av[3]);
+ vtc_dump(vl, 4, "shell_err", av[2], -1);
+ r = system(av[2]);
+ vtc_log(vl, 4, "shell status: 0x%x", r);
+ if (strtol(av[1], NULL, 0) != r)
+ vtc_log(vl, 0, "Wrong shell status: 0x%x", r);
+ else
+ vtc_log(vl, 4, "Expected shell status: 0x%x", r);
+}
/**********************************************************************
* Dump command arguments
@@ -545,6 +569,7 @@ static const struct cmds cmds[] = {
{ "delay", cmd_delay },
{ "varnishtest",cmd_varnishtest },
{ "shell", cmd_shell },
+ { "shell_err", cmd_shell_err },
{ "sema", cmd_sema },
{ "random", cmd_random },
{ "feature", cmd_feature },
More information about the varnish-commit
mailing list