Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jan 2021 21:22:12 GMT
From:      Olivier Cochard <olivier@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f1c010d9f9cb - main - tests: Skip cap_fileargs if build without capsicum capabilities
Message-ID:  <202101262122.10QLMCXW097931@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by olivier (ports committer):

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

commit f1c010d9f9cbc28412d491689e7f594e56085bcb
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2021-01-26 21:19:36 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2021-01-26 21:19:36 +0000

    tests: Skip cap_fileargs if build without capsicum capabilities
    
    Approved by:    oshogbo
    Sponsored by:   Netflix
    Differential Revision: https://reviews.freebsd.org/D2834
---
 lib/libcasper/services/cap_fileargs/tests/Makefile |  2 ++
 .../services/cap_fileargs/tests/fileargs_test.c    | 29 ++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/lib/libcasper/services/cap_fileargs/tests/Makefile b/lib/libcasper/services/cap_fileargs/tests/Makefile
index 51674c5f778e..4d63605e794b 100644
--- a/lib/libcasper/services/cap_fileargs/tests/Makefile
+++ b/lib/libcasper/services/cap_fileargs/tests/Makefile
@@ -4,6 +4,8 @@
 
 ATF_TESTS_C=	fileargs_test
 
+CFLAGS+=	-I${SRCTOP}/tests
+
 .if ${MK_CASPER} != "no"
 LIBADD+=	casper
 LIBADD+=	cap_fileargs
diff --git a/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c b/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c
index 9a7f9dfcb9aa..a12afd734998 100644
--- a/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c
+++ b/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c
@@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$");
 #include <libcasper.h>
 #include <casper/cap_fileargs.h>
 
+#include "freebsd_test_suite/macros.h"
+
 #define MAX_FILES		200
 
 static char *files[MAX_FILES];
@@ -46,6 +48,13 @@ static int fds[MAX_FILES];
 
 #define	TEST_FILE	"/etc/passwd"
 
+static void
+check_capsicum(void)
+{
+	ATF_REQUIRE_FEATURE("security_capabilities");
+	ATF_REQUIRE_FEATURE("security_capability_mode");
+}
+
 static void
 prepare_files(size_t num, bool create)
 {
@@ -281,6 +290,8 @@ ATF_TC_BODY(fileargs__open_read, tc)
 	size_t i;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, true);
 
 	cap_rights_init(&rights, CAP_READ | CAP_FCNTL);
@@ -326,6 +337,8 @@ ATF_TC_BODY(fileargs__open_write, tc)
 	size_t i;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, true);
 
 	cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL);
@@ -371,6 +384,8 @@ ATF_TC_BODY(fileargs__open_create, tc)
 	size_t i;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, false);
 
 	cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL | CAP_READ);
@@ -414,6 +429,8 @@ ATF_TC_BODY(fileargs__open_with_casper, tc)
 	size_t i;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, true);
 
 	capcas = cap_init();
@@ -448,6 +465,8 @@ ATF_TC_BODY(fileargs__fopen_read, tc)
 	FILE *pfile;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, true);
 
 	cap_rights_init(&rights, CAP_READ | CAP_FCNTL);
@@ -496,6 +515,8 @@ ATF_TC_BODY(fileargs__fopen_write, tc)
 	FILE *pfile;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, true);
 
 	cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL);
@@ -544,6 +565,8 @@ ATF_TC_BODY(fileargs__fopen_create, tc)
 	FILE *pfile;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, false);
 
 	cap_rights_init(&rights, CAP_READ | CAP_WRITE | CAP_FCNTL);
@@ -585,6 +608,8 @@ ATF_TC_BODY(fileargs__lstat, tc)
 	size_t i;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, true);
 
 	fa = fileargs_init(MAX_FILES, files, 0, 0, NULL, FA_LSTAT);
@@ -646,6 +671,8 @@ ATF_TC_BODY(fileargs__open_lstat, tc)
 	size_t i;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, true);
 
 	cap_rights_init(&rights, CAP_READ | CAP_FCNTL);
@@ -692,6 +719,8 @@ ATF_TC_BODY(fileargs__open_realpath, tc)
 	size_t i;
 	int fd;
 
+	check_capsicum();
+
 	prepare_files(MAX_FILES, true);
 
 	cap_rights_init(&rights, CAP_READ | CAP_FCNTL);



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