[master] 2b127d43c Polish this to bring it closer to style(9) and how the rest of our test-programs are structured.

Poul-Henning Kamp phk at FreeBSD.org
Mon Feb 24 08:42:05 UTC 2020


commit 2b127d43c7b67fee4c92ac44f240db9008bd63cb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 24 08:40:11 2020 +0000

    Polish this to bring it closer to style(9) and how the
    rest of our test-programs are structured.

diff --git a/lib/libvarnish/Makefile.am b/lib/libvarnish/Makefile.am
index 6545d0b1b..da5821c7e 100644
--- a/lib/libvarnish/Makefile.am
+++ b/lib/libvarnish/Makefile.am
@@ -59,4 +59,5 @@ vjsn_test_CFLAGS = -DVJSN_TEST @SAN_CFLAGS@
 vjsn_test_LDADD = libvarnish.a @SAN_LDFLAGS@
 
 vsb_test_SOURCES = vsb_test.c vsb.c vas.c
+vsb_test_CFLAGS = -DVSB_TEST
 vsb_test_LDADD = libvarnish.a
diff --git a/lib/libvarnish/vsb_test.c b/lib/libvarnish/vsb_test.c
index 5de87118a..c6e4866ff 100644
--- a/lib/libvarnish/vsb_test.c
+++ b/lib/libvarnish/vsb_test.c
@@ -1,3 +1,6 @@
+
+#ifdef VSB_TEST
+
 #include <stdio.h>
 #include <string.h>
 
@@ -11,16 +14,34 @@ struct tc {
 	const char	*out;
 };
 
-struct tc tcs[] = {
-	{ VSB_QUOTE_GLOB, "abcdefghijklmnopqrstvwxyz", "abcdefghijklmnopqrstvwxyz" },
-	{ VSB_QUOTE_GLOB, "ABCDEFGHIJKLMNOPQRSTVWXYZ", "ABCDEFGHIJKLMNOPQRSTVWXYZ" },
-	{ VSB_QUOTE_GLOB, "01234567789", "01234567789"},
-	{ VSB_QUOTE_GLOB, "abcde[f-g]{h,i,j}\\l?*xyz", "abcde\\[f-g\\]\\{h,i,j\\}\\\\l\\?\\*xyz"},
-	{ VSB_QUOTE_GLOB, "0123\t \"\r\v\n'", "0123\\\\t \\\"\\\\r\\\\v\\\\n'"},
-	{0, NULL, NULL}
+static struct tc tcs[] = {
+	{
+	    VSB_QUOTE_GLOB,
+	    "abcdefghijklmnopqrstvwxyz",
+	    "abcdefghijklmnopqrstvwxyz"
+	}, {
+	    VSB_QUOTE_GLOB,
+	    "ABCDEFGHIJKLMNOPQRSTVWXYZ",
+	    "ABCDEFGHIJKLMNOPQRSTVWXYZ"
+	}, {
+	    VSB_QUOTE_GLOB,
+	    "01234567789",
+	    "01234567789"
+	}, {
+	    VSB_QUOTE_GLOB,
+	    "abcde[f-g]{h,i,j}\\l?*xyz",
+	    "abcde\\[f-g\\]\\{h,i,j\\}\\\\l\\?\\*xyz"
+	}, {
+	    VSB_QUOTE_GLOB,
+	    "0123\t \"\r\v\n'",
+	    "0123\\\\t \\\"\\\\r\\\\v\\\\n'"
+	}, {
+	    0, NULL, NULL
+	}
 };
 
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
 	int err = 0;
 	struct tc *tc;
@@ -33,7 +54,7 @@ int main(int argc, char *argv[])
 
 	for (tc = tcs; tc->in; tc++) {
 		VSB_quote(vsb, tc->in, -1, tc->how);
-		VSB_finish(vsb);
+		assert(VSB_finish(vsb) == 0);
 
 		printf("%s -> %s", tc->in, VSB_data(vsb));
 		if (strcmp(VSB_data(vsb), tc->out)) {
@@ -47,3 +68,5 @@ int main(int argc, char *argv[])
 	printf("error is %i\n", err);
 	return (err);
 }
+
+#endif /* VSB_TEST */


More information about the varnish-commit mailing list