git: 8a271827e7b5 - main - tests: Add ATF_REQUIRE_SYSCTL_BOOL
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 25 Apr 2023 14:08:26 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=8a271827e7b5d5310e06df1f9f49ba0ef9efd263
commit 8a271827e7b5d5310e06df1f9f49ba0ef9efd263
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-04-25 13:54:23 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-04-25 13:54:23 +0000
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
---
tests/freebsd_test_suite/macros.h | 17 +++++++++++++++--
tests/sys/vfs/lookup_cap_dotdot.c | 2 +-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/tests/freebsd_test_suite/macros.h b/tests/freebsd_test_suite/macros.h
index c5a3a3838ff7..dfce2fb810e1 100644
--- a/tests/freebsd_test_suite/macros.h
+++ b/tests/freebsd_test_suite/macros.h
@@ -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 { \
diff --git a/tests/sys/vfs/lookup_cap_dotdot.c b/tests/sys/vfs/lookup_cap_dotdot.c
index dee1e0b11780..e023a50f8152 100644
--- a/tests/sys/vfs/lookup_cap_dotdot.c
+++ b/tests/sys/vfs/lookup_cap_dotdot.c
@@ -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);
}
/*