r2712 - trunk/varnish-cache/bin/varnishtest
phk at projects.linpro.no
phk at projects.linpro.no
Tue Jun 17 09:10:15 CEST 2008
Author: phk
Date: 2008-06-17 09:10:14 +0200 (Tue, 17 Jun 2008)
New Revision: 2712
Modified:
trunk/varnish-cache/bin/varnishtest/vtc.c
trunk/varnish-cache/bin/varnishtest/vtc.h
Log:
Add a delay command, it takes second.fraction and uses usleep()
below 100s and sleep() over.
Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-17 07:04:03 UTC (rev 2711)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-17 07:10:14 UTC (rev 2712)
@@ -249,10 +249,32 @@
/**********************************************************************
- * Execute a file
+ * Dump command arguments
*/
void
+cmd_delay(char **av, void *priv)
+{
+ double f;
+
+ (void)priv;
+ if (av == NULL)
+ return;
+ AN(av[1]);
+ AZ(av[2]);
+ f = strtod(av[1], NULL);
+ if (f > 100.) {
+ sleep((int)f);
+ } else {
+ usleep((int)(f * 1e6));
+ }
+}
+
+/**********************************************************************
+ * Dump command arguments
+ */
+
+void
cmd_dump(char **av, void *priv)
{
@@ -263,11 +285,16 @@
printf("\t<%s>\n", *av++);
}
+/**********************************************************************
+ * Execute a file
+ */
+
static struct cmds cmds[] = {
{ "server", cmd_server },
{ "client", cmd_client },
{ "stats", cmd_stats },
{ "varnish", cmd_varnish },
+ { "delay", cmd_delay },
{ "test", cmd_test },
{ NULL, NULL }
};
@@ -294,6 +321,7 @@
int ch;
setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
while ((ch = getopt(argc, argv, "")) != -1) {
switch (ch) {
case '?':
Modified: trunk/varnish-cache/bin/varnishtest/vtc.h
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-17 07:04:03 UTC (rev 2711)
+++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-17 07:10:14 UTC (rev 2712)
@@ -36,6 +36,8 @@
void parse_string(char *buf, const struct cmds *cmd, void *priv);
void cmd_dump(char **av, void *priv);
+void cmd_delay(char **av, void *priv);
+
void cmd_server(char **av, void *priv);
void cmd_client(char **av, void *priv);
void cmd_vcl(char **av, void *priv);
More information about the varnish-commit
mailing list