[4.1] 78ab22c Add a feature check for not-totally-demented-DNS service
Poul-Henning Kamp
phk at FreeBSD.org
Fri Sep 4 15:54:55 CEST 2015
commit 78ab22c13c06a98088600d526d5c26b3376b2b3b
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Aug 25 17:10:19 2015 +0000
Add a feature check for not-totally-demented-DNS service
diff --git a/bin/varnishtest/tests/m00011.vtc b/bin/varnishtest/tests/m00011.vtc
index bd17059..7540c9b 100644
--- a/bin/varnishtest/tests/m00011.vtc
+++ b/bin/varnishtest/tests/m00011.vtc
@@ -1,6 +1,5 @@
varnishtest "Test std.ip"
-
server s1 {
rxreq
txresp -body "1"
diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index 1309df0..f77f617 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -583,6 +583,9 @@ cmd_feature(CMD_ARGS)
continue;
#endif
}
+ if (!strcmp(av[i], "dns") && feature_dns)
+ continue;
+
if (!strcmp(av[i], "topbuild") && iflg)
continue;
diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h
index f2817d8..518494c 100644
--- a/bin/varnishtest/vtc.h
+++ b/bin/varnishtest/vtc.h
@@ -71,6 +71,7 @@ extern pthread_t vtc_thread;
extern int iflg;
extern unsigned vtc_maxdur;
extern int vtc_witness;
+extern int feature_dns;
void init_sema(void);
void init_server(void);
diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c
index df8787c..e1f15d1 100644
--- a/bin/varnishtest/vtc_main.c
+++ b/bin/varnishtest/vtc_main.c
@@ -30,6 +30,7 @@
#include <sys/mman.h>
#include <sys/stat.h>
+#include <sys/socket.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -47,6 +48,9 @@
#include "vfil.h"
#include "vqueue.h"
#include "vrnd.h"
+#include "vsa.h"
+#include "vss.h"
+#include "vtcp.h"
#include "vtim.h"
#define MAX_FILESIZE (1024 * 1024)
@@ -89,6 +93,7 @@ static char *tmppath;
static char *cwd = NULL;
int leave_temp;
int vtc_witness = 0;
+int feature_dns;
/**********************************************************************
* Parse a -D option argument into a name/val pair, and insert
@@ -384,6 +389,41 @@ i_mode(void)
}
/**********************************************************************
+ * Most test-cases use only numeric IP#'s but a few requires non-demented
+ * DNS services. This is a basic sanity check for those.
+ */
+
+static int __match_proto__(vss_resolved_f)
+dns_cb(void *priv, const struct suckaddr *sa)
+{
+ char abuf[VTCP_ADDRBUFSIZE];
+ char pbuf[VTCP_PORTBUFSIZE];
+ int *ret = priv;
+
+ VTCP_name(sa, abuf, sizeof abuf, pbuf, sizeof pbuf);
+ if (strcmp(abuf, "130.225.244.222")) {
+ fprintf(stderr, "DNS-test: Wrong response: %s\n", abuf);
+ *ret = -1;
+ } else if (*ret == 0)
+ *ret = 1;
+ return (0);
+}
+
+static int
+dns_works(void)
+{
+ int ret = 0, error;
+ const char *msg;
+
+ error = VSS_resolver("phk.freebsd.dk", NULL, dns_cb, &ret, &msg);
+ if (error || msg != NULL || ret != 1) {
+ fprintf(stderr, "DNS-test fails\n");
+ return (0);
+ }
+ return (1);
+}
+
+/**********************************************************************
* Main
*/
@@ -480,6 +520,8 @@ main(int argc, char * const *argv)
VTAILQ_INSERT_TAIL(&tst_head, tp, list);
}
+ feature_dns = dns_works();
+
if (iflg)
i_mode();
More information about the varnish-commit
mailing list