]> err.no Git - varnish/commitdiff
Add a delay command, it takes second.fraction and uses usleep()
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 17 Jun 2008 07:10:14 +0000 (07:10 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 17 Jun 2008 07:10:14 +0000 (07:10 +0000)
below 100s and sleep() over.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2712 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishtest/vtc.c
varnish-cache/bin/varnishtest/vtc.h

index 113ca179e9bbddaf0b97863ceb5957bb795c5935..249f9752b2afef1f50efe760d3480315f050c276 100644 (file)
@@ -249,7 +249,29 @@ cmd_test(char **av, void *priv)
 
 
 /**********************************************************************
- * 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
@@ -263,11 +285,16 @@ cmd_dump(char **av, void *priv)
                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 @@ main(int argc, char **argv)
        int ch;
 
        setbuf(stdout, NULL);
+       setbuf(stderr, NULL);
        while ((ch = getopt(argc, argv, "")) != -1) {
                switch (ch) {
                case '?':
index 23d383161c9529423fcc097987705ed39999ab8c..b227b7df1d9d5ae0aee8c3e61b0408807a6ca402 100644 (file)
@@ -36,6 +36,8 @@ struct cmds {
 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);