git: 3c5c55beee5e - main - tests/sys/kern: Skip capsicum procdesc tests when capability mode is unavailable

Olivier Cochard <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a73a2d1.426b2.1a45be92__8725.64918115444$1785963238$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/src/commit/?id=3c5c55beee5ef80d8a9526480682cee86cbac584

commit 3c5c55beee5ef80d8a9526480682cee86cbac584
Author:     Olivier Cochard <[email protected]>
AuthorDate: 2026-08-05 20:46:10 +0000
Commit:     Olivier Cochard <[email protected]>
CommitDate: 2026-08-05 20:51:02 +0000

    tests/sys/kern: Skip capsicum procdesc tests when capability mode is unavailable
    
    pdwait's capsicum/enotcap and procdesc's pdopenpid_capmode enter capability mode.
    Require security_capability_mode (and security_capabilities for enotcap) so the
    cases skip cleanly on kernels built without CAPABILITIES instead of failing.
    
    Approved by:    asomers, gallatin
    Sponsored by:   Netflix
    Differential Revision:  https://reviews.freebsd.org/D58545
---
 tests/sys/kern/Makefile   | 2 ++
 tests/sys/kern/pdwait.c   | 7 +++++++
 tests/sys/kern/procdesc.c | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile
index f025172c8388..96f1f70a5b08 100644
--- a/tests/sys/kern/Makefile
+++ b/tests/sys/kern/Makefile
@@ -154,6 +154,8 @@ CFLAGS.subr_unit.c+=	-Wno-missing-prototypes
 SRCS.subr_unit_test+=	subr_unit.c
 
 CFLAGS.exterr_test+=	-I${SRCTOP}/tests
+CFLAGS.pdwait+=		-I${SRCTOP}/tests
+CFLAGS.procdesc+=	-I${SRCTOP}/tests
 
 WARNS?=	3
 
diff --git a/tests/sys/kern/pdwait.c b/tests/sys/kern/pdwait.c
index 92c8c1b2b3ca..8489dd4ef894 100644
--- a/tests/sys/kern/pdwait.c
+++ b/tests/sys/kern/pdwait.c
@@ -38,6 +38,8 @@
 #include <signal.h>
 #include <string.h>
 
+#include "freebsd_test_suite/macros.h"
+
 static void*
 unmapped(void) {
 	void *unmapped;
@@ -85,6 +87,8 @@ ATF_TC_BODY(capsicum, tc)
 	pid_t pid;
 	int status, r;
 
+	ATF_REQUIRE_FEATURE("security_capability_mode");
+
 	pid = pdfork(&fdp, 0);
 	if (pid == 0)
 		_exit(42);
@@ -195,6 +199,9 @@ ATF_TC_BODY(enotcap, tc)
 	pid_t pid;
 	int status;
 
+	ATF_REQUIRE_FEATURE("security_capability_mode");
+	ATF_REQUIRE_FEATURE("security_capabilities");
+
 	/*cap_rights_init(&rights, CAP_RIGHTS_ALL);*/
 	CAP_ALL(&rights);
 	cap_rights_clear(&rights, CAP_PDWAIT);
diff --git a/tests/sys/kern/procdesc.c b/tests/sys/kern/procdesc.c
index b78e903adb7c..ef5746d544aa 100644
--- a/tests/sys/kern/procdesc.c
+++ b/tests/sys/kern/procdesc.c
@@ -49,6 +49,8 @@
 #include <atf-c.h>
 #include <kvm.h>
 
+#include "freebsd_test_suite/macros.h"
+
 /* Tests for procdesc(4) that aren't specific to any one syscall */
 
 /*
@@ -348,6 +350,8 @@ ATF_TC_BODY(pdopenpid_capmode, tc)
 {
 	pid_t child, parent;
 
+	ATF_REQUIRE_FEATURE("security_capability_mode");
+
 	parent = getpid();
 	child = fork();
 	ATF_REQUIRE_MSG(child >= 0, "fork: %s", strerror(errno));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.