r3173 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Mon Sep 8 19:34:17 CEST 2008


Author: phk
Date: 2008-09-08 19:34:16 +0200 (Mon, 08 Sep 2008)
New Revision: 3173

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
Log:
Add -bodylen which creates a synthetic body of the specified length.

The generated body is the classic drum-printer test pattern:

	!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\n
	"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`\n
	#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a\n
	$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ab\n

The last char is always a \n




Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2008-09-08 16:53:30 UTC (rev 3172)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2008-09-08 17:34:16 UTC (rev 3173)
@@ -66,6 +66,41 @@
 static const char *nl = "\r\n";
 
 /**********************************************************************
+ * Generate a synthetic body
+ */
+
+static const char *
+synth_body(const char *len)
+{
+	int i, j, k, l;
+	char *b;
+	
+	
+	AN(len);
+	i = strtoul(len, NULL, 0);
+	assert(i > 0);
+	b = malloc(i + 1);
+	AN(b);
+	l = k = '!';
+	for (j = 0; j < i; j++) {
+		if ((j % 64) == 63) {
+			b[j] = '\n';
+			k++;
+			if (k == '~')
+				k = '!';
+			l = k;
+		} else {
+			b[j] = l++;
+			if (l == '~')
+				l = '!';
+		}
+	}
+	b[i - 1] = '\n';
+	b[i] = '\0';
+	return (b);
+}
+
+/**********************************************************************
  * Finish and write the vsb to the fd
  */
 
@@ -441,6 +476,10 @@
 			AZ(body);
 			body = av[1];
 			av++;
+		} else if (!strcmp(*av, "-bodylen")) {
+			AZ(body);
+			body = synth_body(av[1]);
+			av++;
 		} else
 			break;
 	}
@@ -530,6 +569,10 @@
 			AZ(body);
 			body = av[1];
 			av++;
+		} else if (!strcmp(*av, "-bodylen")) {
+			AZ(body);
+			body = synth_body(av[1]);
+			av++;
 		} else
 			break;
 	}




More information about the varnish-commit mailing list