r4365 - in trunk/varnish-cache/bin/varnishtest: . tests

phk at projects.linpro.no phk at projects.linpro.no
Tue Nov 24 20:41:09 CET 2009


Author: phk
Date: 2009-11-24 20:41:09 +0100 (Tue, 24 Nov 2009)
New Revision: 4365

Modified:
   trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00008.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc
   trunk/varnish-cache/bin/varnishtest/vtc.c
Log:
Change the macro expansion syntax to ${foobar}, it's much easier to
parse.



Modified: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -9,7 +9,7 @@
 
 server s1 -start 
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 	txreq 
 	rxresp
 }

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -12,7 +12,7 @@
 
 server s1 -start 
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 	txreq 
 	rxresp
 	expect resp.proto == HTTP/1.1

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -12,7 +12,7 @@
 
 server s1 -start 
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 	txreq -req PUT -proto HTTP/1.0 -url /foo
 	rxresp
 	expect resp.proto == HTTP/1.2

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -21,7 +21,7 @@
 server s1 -start 
 server s2 -start 
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 	txreq -req PUT -proto HTTP/1.0 -url /foo
 	rxresp
 	expect resp.proto == HTTP/1.2
@@ -29,7 +29,7 @@
 	expect resp.msg == Foo
 }
 
-client c2 -connect $s2_sock {
+client c2 -connect ${s2_sock} {
 	txreq 
 	rxresp
 	expect resp.proto == HTTP/1.1

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -12,7 +12,7 @@
 
 server s1 -start 
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 	txreq -req PUT -proto HTTP/1.0 -url /foo
 	rxresp
 	expect resp.proto == HTTP/1.2
@@ -20,7 +20,7 @@
 	expect resp.msg == Foo
 }
 
-client c2 -connect $s1_sock {
+client c2 -connect ${s1_sock} {
 	txreq -req PUT -proto HTTP/1.0 -url /foo
 	rxresp
 	expect resp.proto == HTTP/1.2

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -21,7 +21,7 @@
 server s1 -start 
 server s2 -start 
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 	txreq -req PUT -proto HTTP/1.0 -url /foo
 	rxresp
 	expect resp.proto == HTTP/1.2
@@ -31,7 +31,7 @@
 
 client c1 -run
 
-client c1 -connect $s2_sock {
+client c1 -connect ${s2_sock} {
 	txreq 
 	rxresp
 	expect resp.proto == HTTP/1.1

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -13,7 +13,7 @@
 
 server s1 -start 
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 	txreq -req PUT -proto HTTP/1.0 -url /foo \
 		-body "123456789\n"
 	rxresp

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -13,7 +13,7 @@
 
 server s1 -start 
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 	txreq -url "/1" -req "POST" -body "abcdefghi\n"
 	rxresp
 	txreq -url "/2" -req "POST" -body "ihgfedcba\n"

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00008.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00008.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00008.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -23,21 +23,21 @@
 	txresp
 } -start
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 	delay .2
 	txreq
 	rxresp
 	sema r1 sync 4
 } -start
 
-client c2 -connect $s2_sock {
+client c2 -connect ${s2_sock} {
 	delay .6
 	txreq
 	rxresp
 	sema r1 sync 4
 } -start
 
-client c3 -connect $s3_sock {
+client c3 -connect ${s3_sock} {
 	delay .9
 	txreq
 	rxresp

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00010.vtc	2009-11-24 19:41:09 UTC (rev 4365)
@@ -10,7 +10,7 @@
 
 server s1 -start 
 
-client c1 -connect $s1_sock {
+client c1 -connect ${s1_sock} {
 
 	txreq
 	rxresp

Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c	2009-11-24 19:08:39 UTC (rev 4364)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c	2009-11-24 19:41:09 UTC (rev 4365)
@@ -136,6 +136,38 @@
 	return (retval);
 }
 
+static struct vsb *
+macro_expand(char *name)
+{
+	struct vsb *vsb;
+	char *p, *q;
+
+	vsb = vsb_newauto();
+	AN(vsb);
+	while (*name != '\0') {
+		p = strstr(name, "${");
+		if (p == NULL) {
+			vsb_cat(vsb, name);
+			break;
+		}
+		vsb_bcat(vsb, name, p - name);
+		q = strchr(p, '}');
+		if (q == NULL) {
+			vsb_cat(vsb, name);
+			break;
+		}
+		assert(p[0] == '$');
+		assert(p[1] == '{');
+		assert(q[0] == '}');
+		p += 2;
+		*q = '\0';
+		vsb_cat(vsb, macro_get(p));
+		name = q + 1;
+	}
+	vsb_finish(vsb);
+	return (vsb);
+}
+
 /**********************************************************************
  * Read a file into memory
  */
@@ -174,6 +206,7 @@
 parse_string(char *buf, const struct cmds *cmd, void *priv, struct vtclog *vl)
 {
 	char *token_s[MAX_TOKENS], *token_e[MAX_TOKENS];
+	struct vsb *token_exp[MAX_TOKENS];
 	char *p, *q;
 	int nest_brace;
 	int tn;
@@ -251,16 +284,14 @@
 		assert(tn < MAX_TOKENS);
 		token_s[tn] = NULL;
 		for (tn = 0; token_s[tn] != NULL; tn++) {
+			token_exp[tn] = NULL;
 			AN(token_e[tn]);	/*lint !e771 */
 			*token_e[tn] = '\0';	/*lint !e771 */
-			if (token_s[tn][0] == '$') {
-				q = macro_get(token_s[tn] + 1);
-				if (q == NULL)
-					vtc_log(vl, 0,
-					    "Unknown macro: \"%s\"", token_s[tn]);
-				token_s[tn] = q;
-				token_e[tn] = strchr(token_s[tn], '\0');
-			}
+			if (NULL == strstr(token_s[tn], "${"))
+				continue;
+			token_exp[tn] = macro_expand(token_s[tn]);
+			token_s[tn] = vsb_data(token_exp[tn]);
+			token_e[tn] = strchr(token_s[tn], '\0');
 		}
 
 		for (cp = cmd; cp->name != NULL; cp++)



More information about the varnish-commit mailing list