r4751 - trunk/varnish-cache/bin/varnishtest

phk at varnish-cache.org phk at varnish-cache.org
Fri Apr 30 10:15:37 CEST 2010


Author: phk
Date: 2010-04-30 10:15:37 +0200 (Fri, 30 Apr 2010)
New Revision: 4751

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc.c
   trunk/varnish-cache/bin/varnishtest/vtc.h
   trunk/varnish-cache/bin/varnishtest/vtc_client.c
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
   trunk/varnish-cache/bin/varnishtest/vtc_log.c
   trunk/varnish-cache/bin/varnishtest/vtc_sema.c
   trunk/varnish-cache/bin/varnishtest/vtc_server.c
Log:
A round of various cleanups



Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c	2010-04-30 08:15:13 UTC (rev 4750)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c	2010-04-30 08:15:37 UTC (rev 4751)
@@ -36,6 +36,7 @@
 #include <ctype.h>
 #include <fcntl.h>
 #include <math.h>
+#include <limits.h>
 #include <pthread.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -54,12 +55,11 @@
 #define		MAX_FILESIZE		(1024 * 1024)
 #define		MAX_TOKENS		200
 
-static const char	*vtc_file;
 static char		*vtc_desc;
 int			vtc_error;	/* Error encountered */
 int			vtc_stop;	/* Stops current test without error */
 pthread_t		vtc_thread;
-char			*vtc_tmpdir;
+char			vtc_tmpdir[PATH_MAX];
 static struct vtclog	*vltop;
 static pthread_mutex_t	vtc_mtx;
 static pthread_cond_t	vtc_cond;
@@ -529,7 +529,6 @@
 
 	t0 = TIM_mono();
 	vtc_stop = 0;
-	vtc_file = fn;
 	vtc_desc = NULL;
 	vtc_log(vltop, 1, "TEST %s starting", fn);
 	pe.buf = read_file(fn);
@@ -539,18 +538,19 @@
 	pe.fn = fn;
 
 	t = TIM_real() + dur;
-	ts.tv_sec = floor(t);
-	ts.tv_nsec = (t - ts.tv_sec) * 1e9;
+	ts.tv_sec = (long)floor(t);
+	ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9);
 
 	AZ(pthread_mutex_lock(&vtc_mtx));
 	AZ(pthread_create(&pt, NULL, exec_file_thread, &pe));
 	i = pthread_cond_timedwait(&vtc_cond, &vtc_mtx, &ts);
-	vtc_thread = NULL;
+	memset(&vtc_thread, 0, sizeof vtc_thread);
 
 	if (i == 0) {
 		AZ(pthread_mutex_unlock(&vtc_mtx));
 		AZ(pthread_join(pt, &v));
 	} else {
+		AZ(pthread_mutex_unlock(&vtc_mtx));
 		if (i != ETIMEDOUT)
 			vtc_log(vltop, 1, "Weird condwait return: %d %s",
 			    i, strerror(i));
@@ -580,7 +580,6 @@
 	else if (vtc_verbosity == 0)
 		printf("#    top  TEST %s passed (%.3fs)\n", fn, t0);
 
-	vtc_file = NULL;
 	free(vtc_desc);
 	return (t0);
 }
@@ -612,7 +611,6 @@
 	double tmax, t0, t00;
 	unsigned dur = 30;
 	const char *nmax;
-	char tmpdir[BUFSIZ];
 	char cmd[BUFSIZ];
 
 	setbuf(stdout, NULL);
@@ -647,9 +645,7 @@
 	init_macro();
 	init_sema();
 
-	bprintf(tmpdir, "/tmp/vtc.%d.%08x", getpid(), (unsigned)random());
-	vtc_tmpdir = tmpdir;
-	AN(vtc_tmpdir);
+	bprintf(vtc_tmpdir, "/tmp/vtc.%d.%08x", getpid(), (unsigned)random());
 	AZ(mkdir(vtc_tmpdir, 0700));
 	macro_def(vltop, NULL, "tmpdir", vtc_tmpdir);
 
@@ -679,7 +675,6 @@
 	if (vtc_error == 0 || vtc_verbosity == 0) {
 		bprintf(cmd, "rm -rf %s", vtc_tmpdir);
 		AZ(system(cmd));
-		free(vtc_tmpdir);
 	}
 
 	if (vtc_error)

Modified: trunk/varnish-cache/bin/varnishtest/vtc.h
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.h	2010-04-30 08:15:13 UTC (rev 4750)
+++ trunk/varnish-cache/bin/varnishtest/vtc.h	2010-04-30 08:15:37 UTC (rev 4751)
@@ -58,7 +58,7 @@
 extern int vtc_error;		/* Error, bail out */
 extern int vtc_stop;		/* Abandon current test, no error */
 extern pthread_t	vtc_thread;
-extern char *vtc_tmpdir;
+extern char vtc_tmpdir[PATH_MAX];
 
 void init_sema(void);
 

Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_client.c	2010-04-30 08:15:13 UTC (rev 4750)
+++ trunk/varnish-cache/bin/varnishtest/vtc_client.c	2010-04-30 08:15:37 UTC (rev 4751)
@@ -31,6 +31,7 @@
 #include "svnid.h"
 SVNID("$Id$")
 
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>

Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2010-04-30 08:15:13 UTC (rev 4750)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2010-04-30 08:15:37 UTC (rev 4751)
@@ -31,6 +31,7 @@
 #include "svnid.h"
 SVNID("$Id$")
 
+#include <limits.h>
 #include <poll.h>
 #include <stdio.h>
 #include <poll.h>

Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_log.c	2010-04-30 08:15:13 UTC (rev 4750)
+++ trunk/varnish-cache/bin/varnishtest/vtc_log.c	2010-04-30 08:15:37 UTC (rev 4751)
@@ -31,6 +31,7 @@
 #include "svnid.h"
 SVNID("$Id$")
 
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>

Modified: trunk/varnish-cache/bin/varnishtest/vtc_sema.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_sema.c	2010-04-30 08:15:13 UTC (rev 4750)
+++ trunk/varnish-cache/bin/varnishtest/vtc_sema.c	2010-04-30 08:15:37 UTC (rev 4751)
@@ -31,6 +31,7 @@
 #include "svnid.h"
 SVNID("$Id$")
 
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>

Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_server.c	2010-04-30 08:15:13 UTC (rev 4750)
+++ trunk/varnish-cache/bin/varnishtest/vtc_server.c	2010-04-30 08:15:37 UTC (rev 4751)
@@ -31,6 +31,7 @@
 #include "svnid.h"
 SVNID("$Id$")
 
+#include <limits.h>
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>




More information about the varnish-commit mailing list