r3920 - in trunk/varnish-cache/bin/varnishtest: . tests
phk at projects.linpro.no
phk at projects.linpro.no
Thu Mar 12 13:14:46 CET 2009
Author: phk
Date: 2009-03-12 13:14:45 +0100 (Thu, 12 Mar 2009)
New Revision: 3920
Modified:
trunk/varnish-cache/bin/varnishtest/tests/p0000.vtc
trunk/varnish-cache/bin/varnishtest/tests/p0001.vtc
trunk/varnish-cache/bin/varnishtest/vtc.c
trunk/varnish-cache/bin/varnishtest/vtc.h
trunk/varnish-cache/bin/varnishtest/vtc_log.c
trunk/varnish-cache/bin/varnishtest/vtc_server.c
trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
Log:
Try to improve the way we come crashing down when a test fails.
Modified: trunk/varnish-cache/bin/varnishtest/tests/p0000.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p0000.vtc 2009-03-12 10:28:57 UTC (rev 3919)
+++ trunk/varnish-cache/bin/varnishtest/tests/p0000.vtc 2009-03-12 12:14:45 UTC (rev 3920)
@@ -10,6 +10,7 @@
shell "rm -f /tmp/__v1/_.per"
varnish v1 \
+ -arg "-pdiag_bitmap=0x20000" \
-arg "-spersistent,/tmp/__v1/_.per,10m" -vcl+backend { } -start
client c1 {
Modified: trunk/varnish-cache/bin/varnishtest/tests/p0001.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p0001.vtc 2009-03-12 10:28:57 UTC (rev 3919)
+++ trunk/varnish-cache/bin/varnishtest/tests/p0001.vtc 2009-03-12 12:14:45 UTC (rev 3920)
@@ -10,6 +10,7 @@
} -start
varnish v1 \
+ -arg "-pdiag_bitmap=0x20000" \
-arg "-spersistent,/tmp/__v1/_.per,10m" -vcl+backend { } -start
client c1 {
Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c 2009-03-12 10:28:57 UTC (rev 3919)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c 2009-03-12 12:14:45 UTC (rev 3920)
@@ -34,6 +34,7 @@
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
+#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
@@ -50,6 +51,7 @@
char *vtc_desc;
int vtc_error; /* Error encountered */
int vtc_stop; /* Stops current test without error */
+pthread_t vtc_thread;;
/**********************************************************************
* Read a file into memory
@@ -417,6 +419,8 @@
usage();
init_sema();
+
+ vtc_thread = pthread_self();
for (i = 0; i < ntest; i++) {
for (ch = 0; ch < argc; ch++) {
exec_file(argv[ch], vl);
Modified: trunk/varnish-cache/bin/varnishtest/vtc.h
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.h 2009-03-12 10:28:57 UTC (rev 3919)
+++ trunk/varnish-cache/bin/varnishtest/vtc.h 2009-03-12 12:14:45 UTC (rev 3920)
@@ -57,6 +57,7 @@
extern int vtc_verbosity;
extern int vtc_error; /* Error, bail out */
extern int vtc_stop; /* Abandon current test, no error */
+extern pthread_t vtc_thread;;
void init_sema(void);
Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_log.c 2009-03-12 10:28:57 UTC (rev 3919)
+++ trunk/varnish-cache/bin/varnishtest/vtc_log.c 2009-03-12 12:14:45 UTC (rev 3920)
@@ -109,7 +109,8 @@
printf("---- TEST FILE: %s\n", vtc_file);
printf("---- TEST DESCRIPTION: %s\n", vtc_desc);
vtc_error = 1;
- pthread_exit(NULL);
+ if (pthread_self() != vtc_thread)
+ pthread_exit(NULL);
}
}
@@ -160,6 +161,7 @@
vsb_clear(vl->vsb);
if (lvl == 0) {
vtc_error = 1;
- pthread_exit(NULL);
+ if (pthread_self() != vtc_thread)
+ pthread_exit(NULL);
}
}
Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2009-03-12 10:28:57 UTC (rev 3919)
+++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2009-03-12 12:14:45 UTC (rev 3920)
@@ -233,8 +233,10 @@
/* Reset and free */
VTAILQ_FOREACH_SAFE(s, &servers, list, s2) {
VTAILQ_REMOVE(&servers, s, list);
- if (s->sock >= 0)
+ if (s->sock >= 0) {
+ pthread_cancel(s->tp);
server_wait(s);
+ }
server_delete(s);
}
return;
Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2009-03-12 10:28:57 UTC (rev 3919)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2009-03-12 12:14:45 UTC (rev 3920)
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <string.h>
#include <signal.h>
+#include <poll.h>
#include <pthread.h>
#include <inttypes.h>
@@ -181,10 +182,20 @@
{
struct varnish *v;
char buf[BUFSIZ];
+ struct pollfd fds[1];
int i;
CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC);
+ TCP_nonblocking(v->fds[0]);
while (1) {
+ memset(fds, 0, sizeof fds);
+ fds->fd = v->fds[0];
+ fds->events = POLLIN;
+ i = poll(fds, 1, 1000);
+ if (i == 0)
+ continue;
+ if (fds->revents & (POLLERR|POLLHUP))
+ break;
i = read(v->fds[0], buf, sizeof buf - 1);
if (i <= 0)
break;
@@ -249,8 +260,10 @@
break;
}
if (v->cli_fd < 0) {
+ AZ(close(v->fds[1]));
(void)kill(v->pid, SIGKILL);
vtc_log(v->vl, 0, "FAIL no CLI connection");
+ return;
}
vtc_log(v->vl, 3, "CLI connection fd = %d", v->cli_fd);
assert(v->cli_fd >= 0);
@@ -273,6 +286,8 @@
if (v->cli_fd < 0)
varnish_launch(v);
+ if (vtc_error)
+ return;
vtc_log(v->vl, 2, "Start");
u = varnish_ask_cli(v, "start", NULL);
assert(u == CLIS_OK);
@@ -291,6 +306,8 @@
if (v->cli_fd < 0)
varnish_launch(v);
+ if (vtc_error)
+ return;
vtc_log(v->vl, 2, "Stop");
(void)varnish_ask_cli(v, "stop", NULL);
while (1) {
@@ -343,6 +360,8 @@
if (v->cli_fd < 0)
varnish_launch(v);
+ if (vtc_error)
+ return;
u = varnish_ask_cli(v, cli, NULL);
vtc_log(v->vl, 2, "CLI %03u <%s>", u, cli);
if (exp != 0 && exp != u)
@@ -361,6 +380,8 @@
if (v->cli_fd < 0)
varnish_launch(v);
+ if (vtc_error)
+ return;
vsb = vsb_newauto();
AN(vsb);
@@ -401,6 +422,8 @@
if (v->cli_fd < 0)
varnish_launch(v);
+ if (vtc_error)
+ return;
vsb = vsb_newauto();
AN(vsb);
More information about the varnish-commit
mailing list