From: phk Date: Mon, 8 Sep 2008 17:34:16 +0000 (+0000) Subject: Add -bodylen which creates a synthetic body of the specified length. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3c6883f0d276bfc40a51d238731d4ecec38d81c;p=varnish 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 git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3173 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishtest/vtc_http.c b/varnish-cache/bin/varnishtest/vtc_http.c index b8677f2f..23450a65 100644 --- a/varnish-cache/bin/varnishtest/vtc_http.c +++ b/varnish-cache/bin/varnishtest/vtc_http.c @@ -65,6 +65,41 @@ struct http { /* XXX: we may want to vary this */ 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 @@ cmd_http_txresp(CMD_ARGS) 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 @@ cmd_http_txreq(CMD_ARGS) AZ(body); body = av[1]; av++; + } else if (!strcmp(*av, "-bodylen")) { + AZ(body); + body = synth_body(av[1]); + av++; } else break; }