git: e34b159d4c64 - main - Remove {ATF,PLAIN}_REQUIRE_KERNEL_MODULE macros
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 10 Nov 2026 21:32:22 UTC
The branch main has been updated by ngie:
URL: https://cgit.FreeBSD.org/src/commit/?id=e34b159d4c64575aa45763968b6ad01dfd7c2337
commit e34b159d4c64575aa45763968b6ad01dfd7c2337
Author: Enji Cooper <ngie@FreeBSD.org>
AuthorDate: 2026-11-10 21:31:45 +0000
Commit: Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-11-10 21:31:54 +0000
Remove {ATF,PLAIN}_REQUIRE_KERNEL_MODULE macros
These macros predated the `require.kmod` (ATF) and `required_kmods`
(kyua) test metadata and are no longer needed.
Add a hint to freebsd_test_suite/macros.h about the `*FEATURE*` macros
going away soon. See [this kyua issue][kyua-issue] for more details.
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D61082
[kyua-issue]: https://github.com/freebsd/kyua/issues/346
---
contrib/netbsd-tests/kernel/t_mqueue.c | 4 ----
tests/freebsd_test_suite/macros.h | 26 +++++++++++++-------------
tests/sys/kern/Makefile | 1 +
tests/sys/net/routing/rtsock_config.h | 18 +++++++++++++++---
4 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/contrib/netbsd-tests/kernel/t_mqueue.c b/contrib/netbsd-tests/kernel/t_mqueue.c
index 7edbbc9cc924..cde188efb67e 100644
--- a/contrib/netbsd-tests/kernel/t_mqueue.c
+++ b/contrib/netbsd-tests/kernel/t_mqueue.c
@@ -116,10 +116,6 @@ ATF_TC_BODY(mqueue, tc)
char template[32];
char mq_name[64];
-#ifdef __FreeBSD__
- ATF_REQUIRE_KERNEL_MODULE("mqueuefs");
-#endif
-
strlcpy(template, "./t_mqueue.XXXXXX", sizeof(template));
tmpdir = mkdtemp(template);
ATF_REQUIRE_MSG(tmpdir != NULL, "mkdtemp failed: %d", errno);
diff --git a/tests/freebsd_test_suite/macros.h b/tests/freebsd_test_suite/macros.h
index d09d7fe1bf05..975672f5be20 100644
--- a/tests/freebsd_test_suite/macros.h
+++ b/tests/freebsd_test_suite/macros.h
@@ -24,6 +24,11 @@
* SUCH DAMAGE.
*/
+/*
+ * TODO(ngie): replace these macros with first-class metadata properties via
+ * `atf` and `kyua`, much like `require.kmods`.
+ */
+
#ifndef _FREEBSD_TEST_MACROS_H_
#define _FREEBSD_TEST_MACROS_H_
@@ -44,12 +49,10 @@
} \
} while(0)
-#define ATF_REQUIRE_KERNEL_MODULE(_mod_name) do { \
- if (modfind(_mod_name) == -1) { \
- atf_tc_skip("module %s could not be resolved: %s", \
- _mod_name, strerror(errno)); \
- } \
-} while(0)
+/*
+ * ATF_REQUIRE_KERNEL_MODULE was replaced by `require.kmods` (ATF property),
+ * et al.
+ */
#define ATF_REQUIRE_SYSCTL_BOOL(_mib_name, _required_value) do { \
bool value; \
@@ -83,12 +86,9 @@
} \
} while(0)
-#define PLAIN_REQUIRE_KERNEL_MODULE(_mod_name, _exit_code) do { \
- if (modfind(_mod_name) == -1) { \
- printf("module %s could not be resolved: %s\n", \
- _mod_name, strerror(errno)); \
- _exit(_exit_code); \
- } \
-} while(0)
+/*
+ * PLAIN_REQUIRE_KERNEL_MODULE was replaced by the `required_kmods` metadata
+ * property in Kyuafile.
+ */
#endif
diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile
index a59168094c58..d34316a4b10e 100644
--- a/tests/sys/kern/Makefile
+++ b/tests/sys/kern/Makefile
@@ -137,6 +137,7 @@ NETBSD_ATF_TESTS_C+= sysv_test
CFLAGS.mqueue_test+= -I${SRCTOP}/tests
LIBADD.mqueue_test+= rt
LIBADD.tty_pts+= util
+TEST_METADATA.mqueue_test+= required_kmods="mqueuefs"
ATF_TESTS_C+= libkern_crc32
SRCS.libkern_crc32+= libkern_crc32.c
diff --git a/tests/sys/net/routing/rtsock_config.h b/tests/sys/net/routing/rtsock_config.h
index 345fc13f167c..4b0925d7153b 100644
--- a/tests/sys/net/routing/rtsock_config.h
+++ b/tests/sys/net/routing/rtsock_config.h
@@ -127,9 +127,21 @@ config_setup(const atf_tc_t *tc, struct rtsock_config_options *co)
ATF_CHECK_ERRNO(0, true);
if (co->num_interfaces > 0) {
- /* Try loading if_epair and if that fails skip the test. */
- kldload("if_epair");
- ATF_REQUIRE_KERNEL_MODULE("if_epair");
+ /**
+ * Attempt to blindly load `if_epair`. If that fails (and
+ * `if_epair` isn't already loaded), fail the test via
+ * `atf_require_kmod(..)`.
+ *
+ * - TODO(igoro,ngie): `kyua prepare` support will clean this
+ * up a bit, but it requires plumbing on the kyua side, the
+ * CI side, and a few other areas.
+ *
+ * - TODO(ngie): replace this with `require.kmods` atf-c-api(3)
+ * property to restore prior behavior of skipping test
+ * instead of failing if `if_epair` is not loaded.
+ */
+ (void)kldload("if_epair");
+ atf_require_kmod("if_epair");
/* Clear errno for the following tests. */
errno = 0;