[master] 12cbc69 Change varnishtest to use new api
Martin Blix Grydeland
martin at varnish-cache.org
Wed May 15 14:46:13 CEST 2013
commit 12cbc690d9b30c8056fbc0bdec4bd9bdac69399b
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Thu Feb 28 13:01:18 2013 +0100
Change varnishtest to use new api
Clear the thread specific log pointer on log close
Reenable building of varnishtest
diff --git a/bin/Makefile.am b/bin/Makefile.am
index 4adc0bb..2c1b6a6 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -3,7 +3,7 @@
# Disabling building of the tools while api is in flux
#SUBDIRS = varnishadm varnishd varnishlog varnishncsa varnishreplay varnishtest
-SUBDIRS = varnishd
+SUBDIRS = varnishd varnishtest
if HAVE_CURSES
#SUBDIRS += varnishhist varnishstat varnishtop
diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c
index 1fc3760..e90b305 100644
--- a/bin/varnishtest/vtc_log.c
+++ b/bin/varnishtest/vtc_log.c
@@ -88,6 +88,8 @@ vtc_logclose(struct vtclog *vl)
{
CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC);
+ if (pthread_getspecific(log_key) == vl)
+ AZ(pthread_setspecific(log_key, NULL));
VSB_delete(vl->vsb);
AZ(pthread_mutex_destroy(&vl->mtx));
FREE_OBJ(vl);
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 9857c24..4e6f8d4 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -678,7 +678,7 @@ varnish_vclbackend(struct varnish *v, const char *vcl)
*/
struct stat_priv {
- const char *target;
+ char target[256];
uintmax_t val;
};
@@ -691,18 +691,18 @@ do_stat_cb(void *priv, const struct VSC_point * const pt)
if (pt == NULL)
return(0);
- if (strcmp(pt->class, "")) {
- i = strlen(pt->class);
- if (memcmp(pt->class, p, i))
+ if (strcmp(pt->section->type, "")) {
+ i = strlen(pt->section->type);
+ if (memcmp(pt->section->type, p, i))
return (0);
p += i;
if (*p != '.')
return (0);
p++;
}
- if (strcmp(pt->ident, "")) {
- i = strlen(pt->ident);
- if (memcmp(pt->ident, p, i))
+ if (strcmp(pt->section->ident, "")) {
+ i = strlen(pt->section->ident);
+ if (memcmp(pt->section->ident, p, i))
return (0);
p += i;
if (*p != '.')
@@ -722,32 +722,32 @@ varnish_expect(const struct varnish *v, char * const *av) {
uint64_t ref;
int good;
char *p;
- int i, j;
+ int i;
+ const char *prefix = "";
struct stat_priv sp;
- good = -1;
-
- sp.target = av[0];
+ if (NULL == strchr(av[0], '.'))
+ prefix = "MAIN.";
+ snprintf(sp.target, sizeof sp.target, "%s%s", prefix, av[0]);
+ sp.target[sizeof sp.target - 1] = '\0';
sp.val = 0;
ref = 0;
+ good = 0;
for (i = 0; i < 10; i++, (void)usleep(100000)) {
+ if (VSM_Abandoned(v->vd)) {
+ VSM_Close(v->vd);
+ good = VSM_Open(v->vd);
+ }
+ if (good < 0)
+ continue;
good = VSC_Iter(v->vd, do_stat_cb, &sp);
- if (good < 0) {
- VSM_Close(v->vd);
- j = VSM_Open(v->vd);
- if (j == 0)
- continue;
- do {
- (void)usleep(100000);
- j = VSM_Open(v->vd);
- i++;
- } while(i < 10 && j < 0);
- if (j < 0)
- break;
+ if (!good) {
+ good = -2;
+ continue;
}
- good = 0;
+ good = 0;
ref = strtoumax(av[2], &p, 0);
if (ref == UINTMAX_MAX || *p)
vtc_log(v->vl, 0, "Syntax error in number (%s)", av[2]);
@@ -764,6 +764,9 @@ varnish_expect(const struct varnish *v, char * const *av) {
break;
}
if (good == -1) {
+ vtc_log(v->vl, 0, "VSM error: %s", VSM_Error(v->vd));
+ VSM_ResetError(v->vd);
+ } else if (good == -2) {
vtc_log(v->vl, 0, "stats field %s unknown", av[0]);
} else if (good) {
vtc_log(v->vl, 2, "as expected: %s (%ju) %s %s",
More information about the varnish-commit
mailing list