[4.1] 2a582e5 Allow to change varnishtest's buffer size
Federico G. Schwindt
fgsch at lodoss.net
Mon Sep 28 13:31:07 CEST 2015
commit 2a582e59fc69a22fc17c5c23036b252cde55607b
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Mon Sep 21 12:56:58 2015 +0100
Allow to change varnishtest's buffer size
From Carlos Abalde (carlos-dot-abalde-at-gmail-dot-com) with comments
from Dridi and phk.
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index cfdea02..60b6fcb 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -46,6 +46,7 @@
#include "vev.h"
#include "vfil.h"
+#include "vnum.h"
#include "vqueue.h"
#include "vrnd.h"
#include "vsa.h"
@@ -80,6 +81,7 @@ struct vtc_job {
int iflg = 0;
unsigned vtc_maxdur = 60;
+unsigned vtc_bufsiz = 512 * 1024;
static VTAILQ_HEAD(, vtc_tst) tst_head = VTAILQ_HEAD_INITIALIZER(tst_head);
static struct vev_base *vb;
@@ -124,6 +126,7 @@ usage(void)
{
fprintf(stderr, "usage: varnishtest [options] file ...\n");
#define FMT " %-28s # %s\n"
+ fprintf(stderr, FMT, "-b size", "Set internal buffer size (default: 512K)");
fprintf(stderr, FMT, "-D name=val", "Define macro");
fprintf(stderr, FMT, "-i", "Find varnishd in build tree");
fprintf(stderr, FMT, "-j jobs", "Run this many tests in parallel");
@@ -234,7 +237,7 @@ start_test(void)
ALLOC_OBJ(jp, JOB_MAGIC);
AN(jp);
- jp->bufsiz = 512*1024; /* XXX */
+ jp->bufsiz = vtc_bufsiz;
jp->buf = mmap(NULL, jp->bufsiz, PROT_READ|PROT_WRITE,
MAP_ANON | MAP_SHARED, -1, 0);
@@ -432,6 +435,7 @@ main(int argc, char * const *argv)
int ntest = 1; /* Run tests this many times */
struct vtc_tst *tp;
char *p;
+ uintmax_t bufsiz;
/* Default names of programs */
#define VTC_PROG(l) extmacro_def(#l, #l);
@@ -453,8 +457,21 @@ main(int argc, char * const *argv)
setbuf(stdout, NULL);
setbuf(stderr, NULL);
- while ((ch = getopt(argc, argv, "D:ij:klLn:qt:vW")) != -1) {
+ while ((ch = getopt(argc, argv, "b:D:ij:klLn:qt:vW")) != -1) {
switch (ch) {
+ case 'b':
+ if (VNUM_2bytes(optarg, &bufsiz, 0)) {
+ fprintf(stderr, "Cannot parse b opt '%s'\n",
+ optarg);
+ exit(2);
+ }
+ if (bufsiz > UINT_MAX) {
+ fprintf(stderr, "Invalid b opt '%s'\n",
+ optarg);
+ exit(2);
+ }
+ vtc_bufsiz = (unsigned)bufsiz;
+ break;
case 'D':
if (!parse_D_opt(optarg)) {
fprintf(stderr, "Cannot parse D opt '%s'\n",
diff --git a/doc/sphinx/reference/varnishtest.rst b/doc/sphinx/reference/varnishtest.rst
index 5aa1928..00828ff 100644
--- a/doc/sphinx/reference/varnishtest.rst
+++ b/doc/sphinx/reference/varnishtest.rst
@@ -15,7 +15,7 @@ Test program for Varnish
SYNOPSIS
========
-varnishtest [-iklLqv] [-n iter] [-D name=val] [-j jobs] [-t duration] file [file ...]
+varnishtest [-iklLqv] [-n iter] [-b size] [-D name=val] [-j jobs] [-t duration] file [file ...]
DESCRIPTION
===========
@@ -30,6 +30,8 @@ simulate a transaction to provoke a specific behavior.
The following options are available:
+-b size Set internal buffer size (default: 512K)
+
-D name=val Define macro for use in scripts
-i Find varnishd in build tree
More information about the varnish-commit
mailing list