summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-08-20 06:07:40 +0000
committerngie <ngie@FreeBSD.org>2017-08-20 06:07:40 +0000
commit2fe01cb4507296b66d1691b4262f55c1e8a96e8f (patch)
treeb37e56e7af0acde9926d9fc7d10b86f70d6719a6
parent78d345dacb519982a2e508349349721a29927496 (diff)
downloadFreeBSD-src-2fe01cb4507296b66d1691b4262f55c1e8a96e8f.zip
FreeBSD-src-2fe01cb4507296b66d1691b4262f55c1e8a96e8f.tar.gz
MFC r305626,r305629,r307863,r322447,r322448,r322449,r322450,r322451:
r305626 (by oshogbo): Move libcasper tests from regression/capsicum/libcasper/ to lib/libcasper/service/${service_name}/tests. r305629 (by jkim): Add new directories added in r305626 to fix "make installworld". r307863 (by emaste): Set SHLIBDIR before .including src.opts.mk in libcapser services bsd.own.mk (included from src.opts.mk) sets SHLIBDIR?=${LIBDIR}, so SHLIBDIR must be set before including either one of them. MFC with: 305626 r322447: Fix result printing - Flushing stdout prevents the buffer from being printed twice, fixing issues with stdout printing out the testplan, etc, twice. - Don't print out raw source/line numbers; hide them behind comments. r322448: Make root-privileges a requirement for the test Some of the testcases try to manipulate sysctls that require root privileges, e.g., "kern.sync_on_panic". Make root-privileges a hard requirement so the tests don't raise false positives due to privilege issues when calling sysctlbyname(3) on writable sysctls. r322449: Use hardcoded IPv4/IPv6 addresses for google-public-dns-a.google.com instead of freefall.freebsd.org to unbreak the DNS tests The address allocations for freefall.freebsd.org have changed in the past 4 years. Use a more stable set of hardcoded addresses for now to make the tests succeed reliably. The hostname should be resolved dynamically instead of hardcoding the addresses in the future. This is just a bandaid. r322450: Integrate the tests moved in r305626 in to the FreeBSD test suite The reachover Kyuafiles were never added, and thus the tests were installed as standalone tests, and not integrated into the full suite. MFC with: r305626, 305629, r307863, r322447, r322448, r322449 r322451: TESTSDIR isn't required; remove it MFC with: r322450
-rw-r--r--etc/mtree/BSD.tests.dist12
-rw-r--r--lib/libcasper/Makefile2
-rw-r--r--lib/libcasper/services/Makefile2
-rw-r--r--lib/libcasper/services/cap_dns/Makefile9
-rw-r--r--lib/libcasper/services/cap_dns/tests/Makefile11
-rw-r--r--lib/libcasper/services/cap_dns/tests/dns_test.c (renamed from tools/regression/capsicum/libcasper/dns.c)33
-rw-r--r--lib/libcasper/services/cap_grp/Makefile9
-rw-r--r--lib/libcasper/services/cap_grp/tests/Makefile11
-rw-r--r--lib/libcasper/services/cap_grp/tests/grp_test.c (renamed from tools/regression/capsicum/libcasper/grp.c)3
-rw-r--r--lib/libcasper/services/cap_pwd/Makefile9
-rw-r--r--lib/libcasper/services/cap_pwd/tests/Makefile11
-rw-r--r--lib/libcasper/services/cap_pwd/tests/pwd_test.c (renamed from tools/regression/capsicum/libcasper/pwd.c)11
-rw-r--r--lib/libcasper/services/cap_sysctl/Makefile9
-rw-r--r--lib/libcasper/services/cap_sysctl/tests/Makefile13
-rw-r--r--lib/libcasper/services/cap_sysctl/tests/sysctl_test.c (renamed from tools/regression/capsicum/libcasper/sysctl.c)11
-rw-r--r--lib/libcasper/services/tests/Makefile6
-rw-r--r--lib/libcasper/tests/Makefile6
-rw-r--r--tools/regression/capsicum/libcasper/Makefile32
18 files changed, 138 insertions, 62 deletions
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
index c3247bd..1440352 100644
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -316,6 +316,18 @@
..
libcam
..
+ libcasper
+ services
+ cap_dns
+ ..
+ cap_grp
+ ..
+ cap_pwd
+ ..
+ cap_sysctl
+ ..
+ ..
+ ..
libcrypt
..
libdevdctl
diff --git a/lib/libcasper/Makefile b/lib/libcasper/Makefile
index 97cf1df..3101f33 100644
--- a/lib/libcasper/Makefile
+++ b/lib/libcasper/Makefile
@@ -3,6 +3,8 @@
SUBDIR= libcasper
SUBDIR+= services
+SUBDIR.${MK_TESTS}+= tests
+
SUBDIR_PARALLEL=
.include <bsd.subdir.mk>
diff --git a/lib/libcasper/services/Makefile b/lib/libcasper/services/Makefile
index c80e589..3eeac69 100644
--- a/lib/libcasper/services/Makefile
+++ b/lib/libcasper/services/Makefile
@@ -6,6 +6,8 @@ SUBDIR+= cap_pwd
SUBDIR+= cap_random
SUBDIR+= cap_sysctl
+SUBDIR.${MK_TESTS}+= tests
+
SUBDIR_PARALLEL=
.include <bsd.subdir.mk>
diff --git a/lib/libcasper/services/cap_dns/Makefile b/lib/libcasper/services/cap_dns/Makefile
index 2582fe8..4a36da1 100644
--- a/lib/libcasper/services/cap_dns/Makefile
+++ b/lib/libcasper/services/cap_dns/Makefile
@@ -1,10 +1,13 @@
# $FreeBSD$
+SHLIBDIR?= /lib/casper
+
+.include <src.opts.mk>
+
PACKAGE=libcasper
LIB= cap_dns
SHLIB_MAJOR= 0
-SHLIBDIR?= /lib/casper
INCSDIR?= ${INCLUDEDIR}/casper
SRCS= cap_dns.c
@@ -15,4 +18,8 @@ LIBADD= nv
CFLAGS+=-I${.CURDIR}
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.lib.mk>
diff --git a/lib/libcasper/services/cap_dns/tests/Makefile b/lib/libcasper/services/cap_dns/tests/Makefile
new file mode 100644
index 0000000..38af711
--- /dev/null
+++ b/lib/libcasper/services/cap_dns/tests/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+TAP_TESTS_C= dns_test
+
+LIBADD+= casper
+LIBADD+= cap_dns
+LIBADD+= nv
+
+WARNS?= 3
+
+.include <bsd.test.mk>
diff --git a/tools/regression/capsicum/libcasper/dns.c b/lib/libcasper/services/cap_dns/tests/dns_test.c
index 51839c1..0629869 100644
--- a/tools/regression/capsicum/libcasper/dns.c
+++ b/lib/libcasper/services/cap_dns/tests/dns_test.c
@@ -52,18 +52,20 @@ static int ntest = 1;
#define CHECK(expr) do { \
if ((expr)) \
- printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
else \
- printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
+ fflush(stdout); \
ntest++; \
} while (0)
#define CHECKX(expr) do { \
if ((expr)) { \
- printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
} else { \
- printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
exit(1); \
} \
+ fflush(stdout); \
ntest++; \
} while (0)
@@ -295,32 +297,26 @@ runtest(cap_channel_t *capdns)
freeaddrinfo(aic);
}
- /*
- * 8.8.178.135 is IPv4 address of freefall.freebsd.org
- * as of 27 October 2013.
- */
- inet_pton(AF_INET, "8.8.178.135", &ip4);
+ /* XXX: hardcoded addresses for "google-public-dns-a.google.com". */
+#define GOOGLE_DNS_IPV4 "8.8.8.8"
+#define GOOGLE_DNS_IPV6 "2001:4860:4860::8888"
+
+ inet_pton(AF_INET, GOOGLE_DNS_IPV4, &ip4);
hps = gethostbyaddr(&ip4, sizeof(ip4), AF_INET);
if (hps == NULL)
- fprintf(stderr, "Unable to resolve %s.\n", "8.8.178.135");
+ fprintf(stderr, "Unable to resolve %s.\n", GOOGLE_DNS_IPV4);
hpc = cap_gethostbyaddr(capdns, &ip4, sizeof(ip4), AF_INET);
if (hostent_compare(hps, hpc))
result |= GETHOSTBYADDR_AF_INET;
- /*
- * 2001:1900:2254:206c::16:87 is IPv6 address of freefall.freebsd.org
- * as of 27 October 2013.
- */
- inet_pton(AF_INET6, "2001:1900:2254:206c::16:87", &ip6);
+ inet_pton(AF_INET6, GOOGLE_DNS_IPV6, &ip6);
hps = gethostbyaddr(&ip6, sizeof(ip6), AF_INET6);
if (hps == NULL) {
- fprintf(stderr, "Unable to resolve %s.\n",
- "2001:1900:2254:206c::16:87");
+ fprintf(stderr, "Unable to resolve %s.\n", GOOGLE_DNS_IPV6);
}
hpc = cap_gethostbyaddr(capdns, &ip6, sizeof(ip6), AF_INET6);
if (hostent_compare(hps, hpc))
result |= GETHOSTBYADDR_AF_INET6;
-
return (result);
}
@@ -332,6 +328,7 @@ main(void)
int families[2];
printf("1..91\n");
+ fflush(stdout);
capcas = cap_init();
CHECKX(capcas != NULL);
diff --git a/lib/libcasper/services/cap_grp/Makefile b/lib/libcasper/services/cap_grp/Makefile
index 195b08d..c2cc4b1 100644
--- a/lib/libcasper/services/cap_grp/Makefile
+++ b/lib/libcasper/services/cap_grp/Makefile
@@ -1,10 +1,13 @@
# $FreeBSD$
+SHLIBDIR?= /lib/casper
+
+.include <src.opts.mk>
+
PACKAGE=libcasper
LIB= cap_grp
SHLIB_MAJOR= 0
-SHLIBDIR?= /lib/casper
INCSDIR?= ${INCLUDEDIR}/casper
SRCS= cap_grp.c
@@ -15,4 +18,8 @@ LIBADD= nv
CFLAGS+=-I${.CURDIR}
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.lib.mk>
diff --git a/lib/libcasper/services/cap_grp/tests/Makefile b/lib/libcasper/services/cap_grp/tests/Makefile
new file mode 100644
index 0000000..6561885
--- /dev/null
+++ b/lib/libcasper/services/cap_grp/tests/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+TAP_TESTS_C= grp_test
+
+LIBADD+= casper
+LIBADD+= cap_grp
+LIBADD+= nv
+
+WARNS?= 3
+
+.include <bsd.test.mk>
diff --git a/tools/regression/capsicum/libcasper/grp.c b/lib/libcasper/services/cap_grp/tests/grp_test.c
index 7b8ada5..cdda7c6 100644
--- a/tools/regression/capsicum/libcasper/grp.c
+++ b/lib/libcasper/services/cap_grp/tests/grp_test.c
@@ -52,6 +52,7 @@ static int ntest = 1;
printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
else \
printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ fflush(stdout); \
ntest++; \
} while (0)
#define CHECKX(expr) do { \
@@ -61,6 +62,7 @@ static int ntest = 1;
printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
exit(1); \
} \
+ fflush(stdout); \
ntest++; \
} while (0)
@@ -1524,6 +1526,7 @@ main(void)
cap_channel_t *capcas, *capgrp;
printf("1..199\n");
+ fflush(stdout);
capcas = cap_init();
CHECKX(capcas != NULL);
diff --git a/lib/libcasper/services/cap_pwd/Makefile b/lib/libcasper/services/cap_pwd/Makefile
index 3e604bd..ab4be4b 100644
--- a/lib/libcasper/services/cap_pwd/Makefile
+++ b/lib/libcasper/services/cap_pwd/Makefile
@@ -1,10 +1,13 @@
# $FreeBSD$
+SHLIBDIR?= /lib/casper
+
+.include <src.opts.mk>
+
PACKAGE=libcasper
LIB= cap_pwd
SHLIB_MAJOR= 0
-SHLIBDIR?= /lib/casper
INCSDIR?= ${INCLUDEDIR}/casper
SRCS= cap_pwd.c
@@ -15,4 +18,8 @@ LIBADD= nv
CFLAGS+=-I${.CURDIR}
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.lib.mk>
diff --git a/lib/libcasper/services/cap_pwd/tests/Makefile b/lib/libcasper/services/cap_pwd/tests/Makefile
new file mode 100644
index 0000000..8c88753
--- /dev/null
+++ b/lib/libcasper/services/cap_pwd/tests/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+TAP_TESTS_C= pwd_test
+
+LIBADD+= casper
+LIBADD+= cap_pwd
+LIBADD+= nv
+
+WARNS?= 3
+
+.include <bsd.test.mk>
diff --git a/tools/regression/capsicum/libcasper/pwd.c b/lib/libcasper/services/cap_pwd/tests/pwd_test.c
index b102700..e5764db 100644
--- a/tools/regression/capsicum/libcasper/pwd.c
+++ b/lib/libcasper/services/cap_pwd/tests/pwd_test.c
@@ -49,18 +49,20 @@ static int ntest = 1;
#define CHECK(expr) do { \
if ((expr)) \
- printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
else \
- printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__);\
+ printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
+ fflush(stdout); \
ntest++; \
} while (0)
#define CHECKX(expr) do { \
if ((expr)) { \
- printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
} else { \
- printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__);\
+ printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
exit(1); \
} \
+ fflush(stdout); \
ntest++; \
} while (0)
@@ -1510,6 +1512,7 @@ main(void)
cap_channel_t *capcas, *cappwd;
printf("1..188\n");
+ fflush(stdout);
capcas = cap_init();
CHECKX(capcas != NULL);
diff --git a/lib/libcasper/services/cap_sysctl/Makefile b/lib/libcasper/services/cap_sysctl/Makefile
index 7501f37..446ec52 100644
--- a/lib/libcasper/services/cap_sysctl/Makefile
+++ b/lib/libcasper/services/cap_sysctl/Makefile
@@ -1,10 +1,13 @@
# $FreeBSD$
+SHLIBDIR?= /lib/casper
+
+.include <src.opts.mk>
+
PACKAGE=libcasper
LIB= cap_sysctl
SHLIB_MAJOR= 0
-SHLIBDIR?= /lib/casper
INCSDIR?= ${INCLUDEDIR}/casper
SRCS= cap_sysctl.c
@@ -15,4 +18,8 @@ LIBADD= nv
CFLAGS+=-I${.CURDIR}
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.lib.mk>
diff --git a/lib/libcasper/services/cap_sysctl/tests/Makefile b/lib/libcasper/services/cap_sysctl/tests/Makefile
new file mode 100644
index 0000000..cd0f3bb
--- /dev/null
+++ b/lib/libcasper/services/cap_sysctl/tests/Makefile
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+TAP_TESTS_C= sysctl_test
+
+LIBADD+= casper
+LIBADD+= cap_sysctl
+LIBADD+= nv
+
+WARNS?= 3
+
+TEST_METADATA.sysctl_test+= required_user="root"
+
+.include <bsd.test.mk>
diff --git a/tools/regression/capsicum/libcasper/sysctl.c b/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c
index f326820..0377964 100644
--- a/tools/regression/capsicum/libcasper/sysctl.c
+++ b/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c
@@ -61,18 +61,20 @@ static int ntest = 1;
#define CHECK(expr) do { \
if ((expr)) \
- printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
else \
- printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
+ fflush(stdout); \
ntest++; \
} while (0)
#define CHECKX(expr) do { \
if ((expr)) { \
- printf("ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
} else { \
- printf("not ok %d %s:%u\n", ntest, __FILE__, __LINE__); \
+ printf("not ok %d # %s:%u\n", ntest, __FILE__, __LINE__); \
exit(1); \
} \
+ fflush(stdout); \
ntest++; \
} while (0)
@@ -1472,6 +1474,7 @@ main(void)
size_t scsize;
printf("1..256\n");
+ fflush(stdout);
scsize = sizeof(scvalue0);
CHECKX(sysctlbyname(SYSCTL0_NAME, &scvalue0, &scsize, NULL, 0) == 0);
diff --git a/lib/libcasper/services/tests/Makefile b/lib/libcasper/services/tests/Makefile
new file mode 100644
index 0000000..3b3078f
--- /dev/null
+++ b/lib/libcasper/services/tests/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+.PATH: ${SRCTOP}/tests
+KYUAFILE= yes
+
+.include <bsd.test.mk>
diff --git a/lib/libcasper/tests/Makefile b/lib/libcasper/tests/Makefile
new file mode 100644
index 0000000..3b3078f
--- /dev/null
+++ b/lib/libcasper/tests/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+.PATH: ${SRCTOP}/tests
+KYUAFILE= yes
+
+.include <bsd.test.mk>
diff --git a/tools/regression/capsicum/libcasper/Makefile b/tools/regression/capsicum/libcasper/Makefile
deleted file mode 100644
index b024c3b..0000000
--- a/tools/regression/capsicum/libcasper/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-# $FreeBSD$
-
-SERVICES= dns
-SERVICES+= grp
-SERVICES+= pwd
-SERVICES+= sysctl
-
-CFLAGS= -O2 -pipe -std=gnu99 -fstack-protector
-CFLAGS+= -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter
-CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type
-CFLAGS+= -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter
-CFLAGS+= -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
-CFLAGS+= -Wold-style-definition -Wno-pointer-sign
-
-CFLAGS+= -ggdb
-
-SERVTEST= ${SERVICES:=.t}
-
-all: ${SERVTEST}
-
-.for SERVICE in ${SERVICES}
-
-${SERVICE}.t: ${SERVICE}.c
- ${CC} ${CFLAGS} ${@:.t=.c} -o $@ -lnv -lcasper -lcap_${@:.t=}
-
-.endfor
-
-test: all
- @prove -r ${.CURDIR}
-
-clean:
- rm -f ${SERVTEST}
OpenPOWER on IntegriCloud