tests: Skip cap_fileargs if build without capsicum capabilities
Approved by: oshogbo Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D2834
This commit is contained in:
parent
a098a831a1
commit
f1c010d9f9
@ -4,6 +4,8 @@
|
||||
|
||||
ATF_TESTS_C= fileargs_test
|
||||
|
||||
CFLAGS+= -I${SRCTOP}/tests
|
||||
|
||||
.if ${MK_CASPER} != "no"
|
||||
LIBADD+= casper
|
||||
LIBADD+= cap_fileargs
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user