Date: Mon, 1 Apr 2019 14:21:32 +0000 (UTC) From: Olivier Cochard <olivier@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345765 - head/tests/sys/audit Message-ID: <201904011421.x31ELWaR044154@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: olivier (ports committer) Date: Mon Apr 1 14:21:32 2019 New Revision: 345765 URL: https://svnweb.freebsd.org/changeset/base/345765 Log: Fix and simplify code by using ATF_REQUIRE_FEATURE macro PR: 236857 Reviewed by: asomers, ngie Approved by: emaste MFC after: 1 month Sponsored by: Netflix Modified: head/tests/sys/audit/Makefile head/tests/sys/audit/process-control.c Modified: head/tests/sys/audit/Makefile ============================================================================== --- head/tests/sys/audit/Makefile Mon Apr 1 14:19:09 2019 (r345764) +++ head/tests/sys/audit/Makefile Mon Apr 1 14:21:32 2019 (r345765) @@ -55,4 +55,6 @@ WARNS?= 6 LDFLAGS+= -lbsm -lutil +CFLAGS.process-control.c+= -I${SRCTOP}/tests + .include <bsd.test.mk> Modified: head/tests/sys/audit/process-control.c ============================================================================== --- head/tests/sys/audit/process-control.c Mon Apr 1 14:19:09 2019 (r345764) +++ head/tests/sys/audit/process-control.c Mon Apr 1 14:21:32 2019 (r345765) @@ -48,6 +48,8 @@ #include "utils.h" +#include "freebsd_test_suite/macros.h" + static pid_t pid; static int filedesc, status; static struct pollfd fds[1]; @@ -1512,15 +1514,8 @@ ATF_TC_HEAD(cap_enter_success, tc) ATF_TC_BODY(cap_enter_success, tc) { - int capinfo; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + ATF_REQUIRE_FEATURE("security_capability_mode"); - /* Without CAPABILITY_MODE enabled, cap_enter() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); - FILE *pipefd = setup(fds, auclass); ATF_REQUIRE((pid = fork()) != -1); if (pid) { @@ -1550,14 +1545,9 @@ ATF_TC_HEAD(cap_getmode_success, tc) ATF_TC_BODY(cap_getmode_success, tc) { - int capinfo, modep; - size_t len = sizeof(capinfo); - const char *capname = "kern.features.security_capability_mode"; - ATF_REQUIRE_EQ(0, sysctlbyname(capname, &capinfo, &len, NULL, 0)); + int modep; - /* Without CAPABILITY_MODE enabled, cap_getmode() returns ENOSYS */ - if (!capinfo) - atf_tc_skip("Capsicum is not enabled in the system"); + ATF_REQUIRE_FEATURE("security_capability_mode"); pid = getpid(); snprintf(pcregex, sizeof(pcregex), "cap_getmode.*%d.*success", pid);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904011421.x31ELWaR044154>