Move the pf address printing test into its own subdirectory. This
authorbluhm <bluhm@openbsd.org>
Wed, 24 Aug 2016 22:31:41 +0000 (22:31 +0000)
committerbluhm <bluhm@openbsd.org>
Wed, 24 Aug 2016 22:31:41 +0000 (22:31 +0000)
makes it consistent with the regress tree structure.

regress/sys/net/Makefile
regress/sys/net/pf_print/Makefile [new file with mode: 0644]
regress/sys/net/pf_print/pf_print_test.c [new file with mode: 0644]
regress/sys/net/pf_print_test.c [deleted file]

index 01ac658..3d82195 100644 (file)
@@ -1,21 +1,5 @@
-#      $OpenBSD: Makefile,v 1.7 2015/10/26 08:04:10 vgross Exp $
+#      $OpenBSD: Makefile,v 1.8 2016/08/24 22:31:41 bluhm Exp $
 
-SUBDIR +=      pf_divert pf_forward pf_fragment rdomains
+SUBDIR +=      pf_divert pf_forward pf_fragment pf_print rdomains
 
-.MAIN: regress
-
-PROG=          pf_print_test
-CLEANFILES=    pf_print_host.c
-CFLAGS=                -Wall
-CPPFLAGS=      -I.
-
-pf_print_host.c: ../../../sys/net/pf.c Makefile
-       sed -n '/^pf_print_host/{x;p;x;};/^pf_print_host/,/^}/p;h' \
-           ${.CURDIR}/../../../sys/net/pf.c >$@.tmp
-       mv $@.tmp $@
-
-beforedepend: pf_print_host.c
-
-pf_print_test.o: pf_print_test.c pf_print_host.c
-
-.include <bsd.regress.mk>
+.include <bsd.subdir.mk>
diff --git a/regress/sys/net/pf_print/Makefile b/regress/sys/net/pf_print/Makefile
new file mode 100644 (file)
index 0000000..2ffe825
--- /dev/null
@@ -0,0 +1,17 @@
+#      $OpenBSD: Makefile,v 1.1 2016/08/24 22:31:41 bluhm Exp $
+
+PROG=          pf_print_test
+CLEANFILES=    pf_print_host.c
+CFLAGS=                -Wall
+CPPFLAGS=      -I.
+
+pf_print_host.c: ../../../../sys/net/pf.c Makefile
+       sed -n '/^pf_print_host/{x;p;x;};/^pf_print_host/,/^}/p;h' \
+           ${.CURDIR}/../../../../sys/net/pf.c >$@.tmp
+       mv $@.tmp $@
+
+beforedepend: pf_print_host.c
+
+pf_print_test.o: pf_print_test.c pf_print_host.c
+
+.include <bsd.regress.mk>
diff --git a/regress/sys/net/pf_print/pf_print_test.c b/regress/sys/net/pf_print/pf_print_test.c
new file mode 100644 (file)
index 0000000..8353907
--- /dev/null
@@ -0,0 +1,133 @@
+/*     $OpenBSD: pf_print_test.c,v 1.1 2016/08/24 22:31:41 bluhm Exp $ */
+
+/*
+ * Copyright (c) 2008, 2013 Alexander Bluhm <bluhm@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+
+#include <net/if.h>
+#include <net/route.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <net/pfvar.h>
+
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define        INET    1
+#define        INET6   1
+
+void                   pf_print_host(struct pf_addr *, u_int16_t, u_int8_t);
+#define        addlog          printf
+
+char *ipv6_addrs[] = {
+       "::",
+       "::1",
+       "1::",
+       "1::1",
+       "0:1::1:0",
+       "::1:2:0",
+       "0:1::",
+       "::1:0:0:0",
+       "1:2:3:4:5:6:7:8",
+       "0:2:3:4:5:6:7:8",
+       "1:2:3:4:5:6:7:0",
+       "1:0:3:0:5:0:7:8",
+       "::3:4:5:6:7:8",
+       "1:2:3:4:5:6::",
+       "0:2:3::6:7:8",
+       "1:2:0:4:5::8",
+       "1::4:5:0:0:8",
+       "1::5:0:0:8",
+       "1:0:0:4::8",
+       "::4:5:6:0:0",
+       "0:0:3:4:5::",
+       "::4:5:0:0:0",
+       "1234:5678:90ab:cdef:1234:5678:90ab:cdef",
+       NULL
+};
+
+int
+main(int argc, char *argv[])
+{
+       char str[100];
+       struct pf_addr addr;
+       FILE *fpipe;
+       char **in, *out;
+       size_t len;
+       pid_t pid;
+       int fds[2];
+       int status, ret = 0;
+
+       for (in = ipv6_addrs; *in; in++) {
+               if (!inet_pton(AF_INET6, *in, &addr.v6))
+                       errx(2, "inet_pton %s", *in);
+               if (!inet_ntop(AF_INET6, &addr.v6, str, sizeof(str)))
+                       errx(2, "inet_ntop %s", *in);
+               if (strcmp(*in, str) != 0) {
+                       warnx("not equal\nin:\t%s\nstr:\t%s", *in, str);
+                       ret = 2;
+               }
+               if (pipe(fds) == -1)
+                       err(2, "pipe");
+               if ((pid = fork()) == -1)
+                       err(2, "fork");
+               if (pid == 0) {
+                       close(fds[0]);
+                       if (dup2(fds[1], 1) == -1)
+                               err(2, "dup2");
+                       close(fds[1]);
+                       pf_print_host(&addr, 0, AF_INET6);
+                       fflush(stdout);
+                       _exit(0);
+               }
+               close(fds[1]);
+               if ((fpipe = fdopen(fds[0], "r")) == NULL)
+                       err(2, "fdopen");
+               if ((out = fgetln(fpipe, &len)) == NULL)
+                       err(2, "fgetln");
+               if (out[len - 1] == '\n')
+                       out[len - 1] = '\0';
+               else {
+                       char *tmp;
+                       /* EOF without EOL, copy and add the NUL */
+                       if ((tmp = malloc(len + 1)) == NULL)
+                               err(2, "malloc");
+                       memcpy(tmp, out, len);
+                       tmp[len] = '\0';
+                       out = tmp;
+               }
+               if (fclose(fpipe) == EOF)
+                       err(2, "fclose");
+               if (wait(&status) <= 0)
+                       err(2, "wait");
+               if (status != 0)
+                       errx(2, "child exit status: %d", status);
+               if (strcmp(*in, out) != 0) {
+                       warnx("not equal\nin:\t%s\nout:\t%s", *in, out);
+                       ret = 1;
+               }
+       }
+       return (ret);
+}
+
+#include "pf_print_host.c"
diff --git a/regress/sys/net/pf_print_test.c b/regress/sys/net/pf_print_test.c
deleted file mode 100644 (file)
index 212d72f..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*     $OpenBSD: pf_print_test.c,v 1.5 2015/02/09 12:01:41 deraadt Exp $ */
-
-/*
- * Copyright (c) 2008, 2013 Alexander Bluhm <bluhm@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-
-#include <net/if.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <net/pfvar.h>
-
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define        INET    1
-#define        INET6   1
-
-void                   pf_print_host(struct pf_addr *, u_int16_t, u_int8_t);
-#define        addlog          printf
-
-char *ipv6_addrs[] = {
-       "::",
-       "::1",
-       "1::",
-       "1::1",
-       "0:1::1:0",
-       "::1:2:0",
-       "0:1::",
-       "::1:0:0:0",
-       "1:2:3:4:5:6:7:8",
-       "0:2:3:4:5:6:7:8",
-       "1:2:3:4:5:6:7:0",
-       "1:0:3:0:5:0:7:8",
-       "::3:4:5:6:7:8",
-       "1:2:3:4:5:6::",
-       "0:2:3::6:7:8",
-       "1:2:0:4:5::8",
-       "1::4:5:0:0:8",
-       "1::5:0:0:8",
-       "1:0:0:4::8",
-       "::4:5:6:0:0",
-       "0:0:3:4:5::",
-       "::4:5:0:0:0",
-       "1234:5678:90ab:cdef:1234:5678:90ab:cdef",
-       NULL
-};
-
-int
-main(int argc, char *argv[])
-{
-       char str[100];
-       struct pf_addr addr;
-       FILE *fpipe;
-       char **in, *out;
-       size_t len;
-       pid_t pid;
-       int fds[2];
-       int status, ret = 0;
-
-       for (in = ipv6_addrs; *in; in++) {
-               if (!inet_pton(AF_INET6, *in, &addr.v6))
-                       errx(2, "inet_pton %s", *in);
-               if (!inet_ntop(AF_INET6, &addr.v6, str, sizeof(str)))
-                       errx(2, "inet_ntop %s", *in);
-               if (strcmp(*in, str) != 0) {
-                       warnx("not equal\nin:\t%s\nstr:\t%s", *in, str);
-                       ret = 2;
-               }
-               if (pipe(fds) == -1)
-                       err(2, "pipe");
-               if ((pid = fork()) == -1)
-                       err(2, "fork");
-               if (pid == 0) {
-                       close(fds[0]);
-                       if (dup2(fds[1], 1) == -1)
-                               err(2, "dup2");
-                       close(fds[1]);
-                       pf_print_host(&addr, 0, AF_INET6);
-                       fflush(stdout);
-                       _exit(0);
-               }
-               close(fds[1]);
-               if ((fpipe = fdopen(fds[0], "r")) == NULL)
-                       err(2, "fdopen");
-               if ((out = fgetln(fpipe, &len)) == NULL)
-                       err(2, "fgetln");
-               if (out[len - 1] == '\n')
-                       out[len - 1] = '\0';
-               else {
-                       char *tmp;
-                       /* EOF without EOL, copy and add the NUL */
-                       if ((tmp = malloc(len + 1)) == NULL)
-                               err(2, "malloc");
-                       memcpy(tmp, out, len);
-                       tmp[len] = '\0';
-                       out = tmp;
-               }
-               if (fclose(fpipe) == EOF)
-                       err(2, "fclose");
-               if (wait(&status) <= 0)
-                       err(2, "wait");
-               if (status != 0)
-                       errx(2, "child exit status: %d", status);
-               if (strcmp(*in, out) != 0) {
-                       warnx("not equal\nin:\t%s\nout:\t%s", *in, out);
-                       ret = 1;
-               }
-       }
-       return (ret);
-}
-
-#include "pf_print_host.c"