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

phk at projects.linpro.no phk at projects.linpro.no
Thu Jun 26 11:45:31 CEST 2008


Author: phk
Date: 2008-06-26 11:45:29 +0200 (Thu, 26 Jun 2008)
New Revision: 2818

Modified:
   trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc
   trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc
   trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc
   trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc
   trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
Log:
Make -body automatically create a Content-Length header in txresp and txreq.

For lowerlevel syntax based tests, we can revert to send and chunked.


Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc	2008-06-26 09:22:46 UTC (rev 2817)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc	2008-06-26 09:45:29 UTC (rev 2818)
@@ -8,7 +8,6 @@
 	expect req.proto == HTTP/1.0
 	expect req.url == "/foo"
 	txresp -proto HTTP/1.2 -status 201 -msg Foo \
-		-hdr "Content-Length: 10" \
 		-body "987654321\n"
 }
 
@@ -16,7 +15,6 @@
 
 client c1 -connect 127.0.0.1:9080 {
 	txreq -req PUT -proto HTTP/1.0 -url /foo \
-		-hdr "Content-Length: 10" \
 		-body "123456789\n"
 	rxresp
 	expect resp.proto == HTTP/1.2

Modified: trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc	2008-06-26 09:22:46 UTC (rev 2817)
+++ trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc	2008-06-26 09:45:29 UTC (rev 2818)
@@ -5,20 +5,18 @@
 server s1 -listen 127.0.0.1:9080 {
 	rxreq
 	expect req.url == "/1"
-	txresp -hdr "Content-Length: 10" -body "123456789\n"
+	txresp -body "123456789\n"
 	rxreq
 	expect req.url == "/2"
-	txresp -hdr "Content-Length: 10" -body "987654321\n"
+	txresp -body "987654321\n"
 }
 
 server s1 -start 
 
 client c1 -connect 127.0.0.1:9080 {
-	txreq -url "/1" -req "POST" \
-	    -hdr "Content-Length: 10" -body "abcdefghi\n"
+	txreq -url "/1" -req "POST" -body "abcdefghi\n"
 	rxresp
-	txreq -url "/2" -req "POST" \
-	    -hdr "Content-Length: 10" -body "ihgfedcba\n"
+	txreq -url "/2" -req "POST" -body "ihgfedcba\n"
 	rxresp
 }
 

Modified: trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc	2008-06-26 09:22:46 UTC (rev 2817)
+++ trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc	2008-06-26 09:45:29 UTC (rev 2818)
@@ -7,15 +7,15 @@
 server s1 {
 	rxreq
 	expect req.http.foobar == "1"
-	txresp -hdr "Vary: Foobar" -hdr "Snafu: 1" -hdr "Content-Length: 5" -body "1111\n"
+	txresp -hdr "Vary: Foobar" -hdr "Snafu: 1" -body "1111\n"
 	rxreq
 	expect req.http.foobar == "2"
-	txresp -hdr "Vary: Foobar" -hdr "Snafu: 2" -hdr "Content-Length: 5" -body "2222\n"
+	txresp -hdr "Vary: Foobar" -hdr "Snafu: 2" -body "2222\n"
 	rxreq
 	expect req.http.foobar == "3"
-	txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -hdr "Content-Length: 5" -body "3333\n"
+	txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -body "3333\n"
 	rxreq
-	txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -hdr "Content-Length: 5" -body "4444\n"
+	txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -body "4444\n"
 } -start
 
 client c1 {

Modified: trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc	2008-06-26 09:22:46 UTC (rev 2817)
+++ trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc	2008-06-26 09:45:29 UTC (rev 2818)
@@ -5,10 +5,10 @@
 server s1 {
 	rxreq
 	expect req.url == "/"
-	txresp -hdr "Content-Length: 5" -body "1111\n"
+	txresp -body "1111\n"
 	rxreq
 	expect req.url == "foo"
-	txresp -hdr "Content-Length: 5" -body "2222\n"
+	txresp -body "2222\n"
 } -start
 
 varnish v1 -vcl+backend {

Modified: trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc	2008-06-26 09:22:46 UTC (rev 2817)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc	2008-06-26 09:45:29 UTC (rev 2818)
@@ -6,7 +6,6 @@
 	rxreq 
 	txresp \
 	    -hdr "Date: Thu, 19 Jun 2008 21:14:49 GMT" \
-	    -hdr "Content-Length: 7" \
 	    -hdr "Expires: Thu, 19 Jun 2008 21:14:49 GMT" \
 	    -hdr "Last-Modified: Sun, 27 Nov 2005 05:41:47 GMT" \
 	    -hdr "Cache-Control: max-age =0" \

Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2008-06-26 09:22:46 UTC (rev 2817)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2008-06-26 09:45:29 UTC (rev 2818)
@@ -359,7 +359,6 @@
 	const char *status = "200";
 	const char *msg = "Ok";
 	const char *body = NULL;
-	int dohdr = 0;
 
 	(void)cmd;
 	CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
@@ -371,46 +370,42 @@
 
 	for(; *av != NULL; av++) {
 		if (!strcmp(*av, "-proto")) {
-			AZ(dohdr);
 			proto = av[1];
 			av++;
-			continue;
-		}
-		if (!strcmp(*av, "-status")) {
-			AZ(dohdr);
+		} else if (!strcmp(*av, "-status")) {
 			status = av[1];
 			av++;
-			continue;
-		}
-		if (!strcmp(*av, "-msg")) {
-			AZ(dohdr);
+		} else if (!strcmp(*av, "-msg")) {
 			msg = av[1];
 			av++;
 			continue;
-		}
-		if (!strcmp(*av, "-body")) {
-			body = av[1];
-			av++;
-			continue;
-		}
+		} else
+			break;
+	}
+
+	vsb_printf(hp->vsb, "%s %s %s%s", proto, status, msg, nl);
+
+	for(; *av != NULL; av++) {
 		if (!strcmp(*av, "-hdr")) {
-			if (dohdr == 0) {
-				vsb_printf(hp->vsb, "%s %s %s%s", 
-				    proto, status, msg, nl);
-				dohdr = 1;
-			}
 			vsb_printf(hp->vsb, "%s%s", av[1], nl);
 			av++;
-			continue;
-		}
-		fprintf(stderr, "Unknown http txreq spec: %s\n", *av);
-		exit (1);
+		} else 
+			break;
 	}
-	if (dohdr == 0) {
-		vsb_printf(hp->vsb, "%s %s %s%s", 
-		    proto, status, msg, nl);
-		dohdr = 1;
+	for(; *av != NULL; av++) {
+		if (!strcmp(*av, "-body")) {
+			AZ(body);
+			body = av[1];
+			av++;
+		} else
+			break;
 	}
+	if (*av != NULL) {
+		fprintf(stderr, "Unknown http txresp spec: %s\n", *av);
+		exit (1);
+	}
+	if (body != NULL) 
+		vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl);
 	vsb_cat(hp->vsb, nl);
 	if (body != NULL) {
 		vsb_cat(hp->vsb, body);
@@ -456,7 +451,6 @@
 	const char *url = "/";
 	const char *proto = "HTTP/1.1";
 	const char *body = NULL;
-	int dohdr = 0;
 
 	(void)cmd;
 	CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
@@ -468,46 +462,39 @@
 
 	for(; *av != NULL; av++) {
 		if (!strcmp(*av, "-url")) {
-			AZ(dohdr);
 			url = av[1];
 			av++;
-			continue;
-		}
-		if (!strcmp(*av, "-proto")) {
-			AZ(dohdr);
+		} else if (!strcmp(*av, "-proto")) {
 			proto = av[1];
 			av++;
-			continue;
-		}
-		if (!strcmp(*av, "-req")) {
-			AZ(dohdr);
+		} else if (!strcmp(*av, "-req")) {
 			req = av[1];
 			av++;
-			continue;
-		}
+		} else
+			break;
+	}
+	vsb_printf(hp->vsb, "%s %s %s%s", req, url, proto, nl);
+	for(; *av != NULL; av++) {
 		if (!strcmp(*av, "-hdr")) {
-			if (dohdr == 0) {
-				vsb_printf(hp->vsb, "%s %s %s%s", 
-				    req, url, proto, nl);
-				dohdr = 1;
-			}
 			vsb_printf(hp->vsb, "%s%s", av[1], nl);
 			av++;
-			continue;
-		}
+		} else
+			break;
+	}
+	for(; *av != NULL; av++) {
 		if (!strcmp(*av, "-body")) {
+			AZ(body);
 			body = av[1];
 			av++;
-			continue;
-		}
+		} else
+			break;
+	}
+	if (*av != NULL) {
 		fprintf(stderr, "Unknown http txreq spec: %s\n", *av);
 		exit (1);
 	}
-	if (dohdr == 0) {
-		vsb_printf(hp->vsb, "%s %s %s%s", 
-		    req, url, proto, nl);
-		dohdr = 1;
-	}
+	if (body != NULL) 
+		vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl);
 	vsb_cat(hp->vsb, nl);
 	if (body != NULL) {
 		vsb_cat(hp->vsb, body);




More information about the varnish-commit mailing list