Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Aug 2017 06:07:40 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r322715 - in stable/11: etc/mtree lib/libcasper lib/libcasper/services lib/libcasper/services/cap_dns lib/libcasper/services/cap_dns/tests lib/libcasper/services/cap_grp lib/libcasper/s...
Message-ID:  <201708200607.v7K67eZN042764@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sun Aug 20 06:07:40 2017
New Revision: 322715
URL: https://svnweb.freebsd.org/changeset/base/322715

Log:
  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

Added:
  stable/11/lib/libcasper/services/cap_dns/tests/
     - copied from r305626, head/lib/libcasper/services/cap_dns/tests/
  stable/11/lib/libcasper/services/cap_grp/tests/
     - copied from r305626, head/lib/libcasper/services/cap_grp/tests/
  stable/11/lib/libcasper/services/cap_pwd/tests/
     - copied from r305626, head/lib/libcasper/services/cap_pwd/tests/
  stable/11/lib/libcasper/services/cap_sysctl/tests/
     - copied from r305626, head/lib/libcasper/services/cap_sysctl/tests/
  stable/11/lib/libcasper/services/tests/
     - copied from r322450, head/lib/libcasper/services/tests/
  stable/11/lib/libcasper/tests/
     - copied from r322450, head/lib/libcasper/tests/
Deleted:
  stable/11/tools/regression/capsicum/libcasper/
Modified:
  stable/11/etc/mtree/BSD.tests.dist
  stable/11/lib/libcasper/Makefile
  stable/11/lib/libcasper/services/Makefile
  stable/11/lib/libcasper/services/cap_dns/Makefile
  stable/11/lib/libcasper/services/cap_dns/tests/dns_test.c
  stable/11/lib/libcasper/services/cap_grp/Makefile
  stable/11/lib/libcasper/services/cap_grp/tests/grp_test.c
  stable/11/lib/libcasper/services/cap_pwd/Makefile
  stable/11/lib/libcasper/services/cap_pwd/tests/pwd_test.c
  stable/11/lib/libcasper/services/cap_sysctl/Makefile
  stable/11/lib/libcasper/services/cap_sysctl/tests/Makefile
  stable/11/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c
  stable/11/lib/libcasper/services/tests/Makefile
  stable/11/lib/libcasper/tests/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/etc/mtree/BSD.tests.dist
==============================================================================
--- stable/11/etc/mtree/BSD.tests.dist	Sun Aug 20 01:42:01 2017	(r322714)
+++ stable/11/etc/mtree/BSD.tests.dist	Sun Aug 20 06:07:40 2017	(r322715)
@@ -316,6 +316,18 @@
         ..
         libcam
         ..
+        libcasper
+            services
+                cap_dns
+                ..
+                cap_grp
+                ..
+                cap_pwd
+                ..
+                cap_sysctl
+                ..
+            ..
+        ..
         libcrypt
         ..
         libdevdctl

Modified: stable/11/lib/libcasper/Makefile
==============================================================================
--- stable/11/lib/libcasper/Makefile	Sun Aug 20 01:42:01 2017	(r322714)
+++ stable/11/lib/libcasper/Makefile	Sun Aug 20 06:07:40 2017	(r322715)
@@ -3,6 +3,8 @@
 SUBDIR=		libcasper
 SUBDIR+=	services
 
+SUBDIR.${MK_TESTS}+=	tests
+
 SUBDIR_PARALLEL=
 
 .include <bsd.subdir.mk>

Modified: stable/11/lib/libcasper/services/Makefile
==============================================================================
--- stable/11/lib/libcasper/services/Makefile	Sun Aug 20 01:42:01 2017	(r322714)
+++ stable/11/lib/libcasper/services/Makefile	Sun Aug 20 06:07:40 2017	(r322715)
@@ -6,6 +6,8 @@ SUBDIR+=	cap_pwd
 SUBDIR+=	cap_random
 SUBDIR+=	cap_sysctl
 
+SUBDIR.${MK_TESTS}+=	tests
+
 SUBDIR_PARALLEL=
 
 .include <bsd.subdir.mk>

Modified: stable/11/lib/libcasper/services/cap_dns/Makefile
==============================================================================
--- stable/11/lib/libcasper/services/cap_dns/Makefile	Sun Aug 20 01:42:01 2017	(r322714)
+++ stable/11/lib/libcasper/services/cap_dns/Makefile	Sun Aug 20 06:07:40 2017	(r322715)
@@ -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
@@ -14,5 +17,9 @@ INCS=	cap_dns.h
 LIBADD=	nv
 
 CFLAGS+=-I${.CURDIR}
+
+.if ${MK_TESTS} != "no"
+SUBDIR+=	tests
+.endif
 
 .include <bsd.lib.mk>

Modified: stable/11/lib/libcasper/services/cap_dns/tests/dns_test.c
==============================================================================
--- head/lib/libcasper/services/cap_dns/tests/dns_test.c	Thu Sep  8 20:01:26 2016	(r305626)
+++ stable/11/lib/libcasper/services/cap_dns/tests/dns_test.c	Sun Aug 20 06:07:40 2017	(r322715)
@@ -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);

Modified: stable/11/lib/libcasper/services/cap_grp/Makefile
==============================================================================
--- stable/11/lib/libcasper/services/cap_grp/Makefile	Sun Aug 20 01:42:01 2017	(r322714)
+++ stable/11/lib/libcasper/services/cap_grp/Makefile	Sun Aug 20 06:07:40 2017	(r322715)
@@ -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
@@ -14,5 +17,9 @@ INCS=	cap_grp.h
 LIBADD=	nv
 
 CFLAGS+=-I${.CURDIR}
+
+.if ${MK_TESTS} != "no"
+SUBDIR+=	tests
+.endif
 
 .include <bsd.lib.mk>

Modified: stable/11/lib/libcasper/services/cap_grp/tests/grp_test.c
==============================================================================
--- head/lib/libcasper/services/cap_grp/tests/grp_test.c	Thu Sep  8 20:01:26 2016	(r305626)
+++ stable/11/lib/libcasper/services/cap_grp/tests/grp_test.c	Sun Aug 20 06:07:40 2017	(r322715)
@@ -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);

Modified: stable/11/lib/libcasper/services/cap_pwd/Makefile
==============================================================================
--- stable/11/lib/libcasper/services/cap_pwd/Makefile	Sun Aug 20 01:42:01 2017	(r322714)
+++ stable/11/lib/libcasper/services/cap_pwd/Makefile	Sun Aug 20 06:07:40 2017	(r322715)
@@ -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
@@ -14,5 +17,9 @@ INCS=	cap_pwd.h
 LIBADD=	nv
 
 CFLAGS+=-I${.CURDIR}
+
+.if ${MK_TESTS} != "no"
+SUBDIR+=	tests
+.endif
 
 .include <bsd.lib.mk>

Modified: stable/11/lib/libcasper/services/cap_pwd/tests/pwd_test.c
==============================================================================
--- head/lib/libcasper/services/cap_pwd/tests/pwd_test.c	Thu Sep  8 20:01:26 2016	(r305626)
+++ stable/11/lib/libcasper/services/cap_pwd/tests/pwd_test.c	Sun Aug 20 06:07:40 2017	(r322715)
@@ -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);

Modified: stable/11/lib/libcasper/services/cap_sysctl/Makefile
==============================================================================
--- stable/11/lib/libcasper/services/cap_sysctl/Makefile	Sun Aug 20 01:42:01 2017	(r322714)
+++ stable/11/lib/libcasper/services/cap_sysctl/Makefile	Sun Aug 20 06:07:40 2017	(r322715)
@@ -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
@@ -14,5 +17,9 @@ INCS=	cap_sysctl.h
 LIBADD=	nv
 
 CFLAGS+=-I${.CURDIR}
+
+.if ${MK_TESTS} != "no"
+SUBDIR+=	tests
+.endif
 
 .include <bsd.lib.mk>

Modified: stable/11/lib/libcasper/services/cap_sysctl/tests/Makefile
==============================================================================
--- head/lib/libcasper/services/cap_sysctl/tests/Makefile	Thu Sep  8 20:01:26 2016	(r305626)
+++ stable/11/lib/libcasper/services/cap_sysctl/tests/Makefile	Sun Aug 20 06:07:40 2017	(r322715)
@@ -8,4 +8,6 @@ LIBADD+=	nv
 
 WARNS?=		3
 
+TEST_METADATA.sysctl_test+=	required_user="root"
+
 .include <bsd.test.mk>

Modified: stable/11/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c
==============================================================================
--- head/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c	Thu Sep  8 20:01:26 2016	(r305626)
+++ stable/11/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c	Sun Aug 20 06:07:40 2017	(r322715)
@@ -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);

Modified: stable/11/lib/libcasper/services/tests/Makefile
==============================================================================
--- head/lib/libcasper/services/tests/Makefile	Sun Aug 13 01:04:44 2017	(r322450)
+++ stable/11/lib/libcasper/services/tests/Makefile	Sun Aug 20 06:07:40 2017	(r322715)
@@ -1,7 +1,5 @@
 # $FreeBSD$
 
-TESTSDIR=	${TESTSBASE}/lib/libcasper/services
-
 .PATH:		${SRCTOP}/tests
 KYUAFILE=	yes
 

Modified: stable/11/lib/libcasper/tests/Makefile
==============================================================================
--- head/lib/libcasper/tests/Makefile	Sun Aug 13 01:04:44 2017	(r322450)
+++ stable/11/lib/libcasper/tests/Makefile	Sun Aug 20 06:07:40 2017	(r322715)
@@ -1,7 +1,5 @@
 # $FreeBSD$
 
-TESTSDIR=	${TESTSBASE}/lib/libcasper
-
 .PATH:		${SRCTOP}/tests
 KYUAFILE=	yes
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708200607.v7K67eZN042764>