[master] 027296d87 Add vtc feature abstract_uds

Nils Goroll nils.goroll at uplex.de
Mon Nov 21 17:11:05 UTC 2022


commit 027296d877664bb7b79469b255091d2f09aa4282
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Nov 21 17:27:50 2022 +0100

    Add vtc feature abstract_uds

diff --git a/bin/varnishtest/tests/c00121.vtc b/bin/varnishtest/tests/c00121.vtc
index 95b6aa14c..3155e957e 100644
--- a/bin/varnishtest/tests/c00121.vtc
+++ b/bin/varnishtest/tests/c00121.vtc
@@ -1,7 +1,6 @@
 varnishtest "Abstract UDS backend: change path, drop poll"
 
-# XXX better test to check for abstract sockets
-feature cmd {socat abstract-listen:test file:/dev/null & date | socat fd:0  abstract-client:test}
+feature abstract_uds
 
 server s1 -listen "@vtc.s1.sock" {
 	non_fatal
diff --git a/bin/varnishtest/vtc_misc.c b/bin/varnishtest/vtc_misc.c
index 8c90cf438..10875ecd9 100644
--- a/bin/varnishtest/vtc_misc.c
+++ b/bin/varnishtest/vtc_misc.c
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/un.h>
 #include <unistd.h>
 
 #ifdef HAVE_SYS_PERSONALITY_H
@@ -52,6 +53,7 @@
 #include "vtcp.h"
 #include "vss.h"
 #include "vtim.h"
+#include "vus.h"
 
 /* SECTION: vtest vtest
  *
@@ -411,6 +413,28 @@ addr_no_randomize_works(void)
 	return (r >= 0);
 }
 
+/**********************************************************************/
+
+static int
+uds_socket(void *priv, const struct sockaddr_un *uds)
+{
+
+	(void) priv;
+	return (socket(uds->sun_family, SOCK_STREAM, 0));
+}
+static int
+abstract_uds_works(void)
+{
+	const char *err;
+	int fd;
+
+	fd = VUS_resolver("@vtc.feature.abstract_uds", uds_socket, NULL, &err);
+	if (fd < 0)
+		return (0);
+	close(fd);
+	return (1);
+}
+
 /* SECTION: feature feature
  *
  * Test that the required feature(s) for a test are available, and skip
@@ -456,6 +480,8 @@ addr_no_randomize_works(void)
  *        Varnish was built with a sanitizer.
  * workspace_emulator
  *        Varnish was built with its workspace emulator.
+ * abstract_uds
+ *        Creation of an abstract unix domain socket succeeded
  *
  * A feature name can be prefixed with an exclamation mark (!) to skip a
  * test if the feature is present.
@@ -566,6 +592,7 @@ cmd_feature(CMD_ARGS)
 		FEATURE("ubsan", ubsan);
 		FEATURE("sanitizer", sanitizer);
 		FEATURE("workspace_emulator", workspace_emulator);
+		FEATURE("abstract_uds", abstract_uds_works());
 
 		if (!strcmp(feat, "cmd")) {
 			good = 1;


More information about the varnish-commit mailing list