tests: Add ATF_REQUIRE_SYSCTL_BOOL

Modify a capability mode test to use it for kern.trap_enotcap, to avoid
false positives.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Mark Johnston 2023-04-25 09:54:23 -04:00
parent fc727ad63d
commit 8a271827e7
2 changed files with 16 additions and 3 deletions

View File

@ -53,6 +53,18 @@
} \
} while(0)
#define ATF_REQUIRE_SYSCTL_BOOL(_mib_name, _required_value) do { \
bool value; \
size_t size = sizeof(value); \
if (sysctlbyname(_mib_name, &value, &size, NULL, 0) == -1) { \
atf_tc_skip("sysctl for %s failed: %s", _mib_name, \
strerror(errno)); \
} \
if (value != (_required_value)) \
atf_tc_skip("requires %s=%d, =%d", (_mib_name), \
(_required_value), value); \
} while (0)
#define ATF_REQUIRE_SYSCTL_INT(_mib_name, _required_value) do { \
int value; \
size_t size = sizeof(value); \
@ -60,8 +72,9 @@
atf_tc_skip("sysctl for %s failed: %s", _mib_name, \
strerror(errno)); \
} \
if (value != _required_value) \
atf_tc_skip("requires %s=%d", _mib_name, _required_value); \
if (value != (_required_value)) \
atf_tc_skip("requires %s=%d, =%d", (_mib_name), \
(_required_value), value); \
} while(0)
#define PLAIN_REQUIRE_FEATURE(_feature_name, _exit_code) do { \

View File

@ -80,7 +80,7 @@ check_capsicum(void)
{
ATF_REQUIRE_FEATURE("security_capabilities");
ATF_REQUIRE_FEATURE("security_capability_mode");
ATF_REQUIRE_SYSCTL_INT("kern.trap_enotcap", 0);
ATF_REQUIRE_SYSCTL_BOOL("kern.trap_enotcap", false);
}
/*