git: 307e725acce2 - main - Revert "Remove {ATF,PLAIN}_REQUIRE_KERNEL_MODULE macros"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 10 Nov 2026 22:13:55 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=307e725acce22043d5961b0ad392ea0283e1d056
commit 307e725acce22043d5961b0ad392ea0283e1d056
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-11-10 22:12:50 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-10 22:12:50 +0000
Revert "Remove {ATF,PLAIN}_REQUIRE_KERNEL_MODULE macros"
The change breaks the build of tests/sys/net/routing/test_rtsock_l3.c.
This reverts commit e34b159d4c64575aa45763968b6ad01dfd7c2337.
---
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, 20 insertions(+), 29 deletions(-)
diff --git a/contrib/netbsd-tests/kernel/t_mqueue.c b/contrib/netbsd-tests/kernel/t_mqueue.c
index cde188efb67e..7edbbc9cc924 100644
--- a/contrib/netbsd-tests/kernel/t_mqueue.c
+++ b/contrib/netbsd-tests/kernel/t_mqueue.c
@@ -116,6 +116,10 @@ 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 975672f5be20..d09d7fe1bf05 100644
--- a/tests/freebsd_test_suite/macros.h
+++ b/tests/freebsd_test_suite/macros.h
@@ -24,11 +24,6 @@
* 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_
@@ -49,10 +44,12 @@
} \
} while(0)
-/*
- * ATF_REQUIRE_KERNEL_MODULE was replaced by `require.kmods` (ATF property),
- * et al.
- */
+#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)
#define ATF_REQUIRE_SYSCTL_BOOL(_mib_name, _required_value) do { \
bool value; \
@@ -86,9 +83,12 @@
} \
} while(0)
-/*
- * PLAIN_REQUIRE_KERNEL_MODULE was replaced by the `required_kmods` metadata
- * property in Kyuafile.
- */
+#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)
#endif
diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile
index d34316a4b10e..a59168094c58 100644
--- a/tests/sys/kern/Makefile
+++ b/tests/sys/kern/Makefile
@@ -137,7 +137,6 @@ 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 4b0925d7153b..345fc13f167c 100644
--- a/tests/sys/net/routing/rtsock_config.h
+++ b/tests/sys/net/routing/rtsock_config.h
@@ -127,21 +127,9 @@ config_setup(const atf_tc_t *tc, struct rtsock_config_options *co)
ATF_CHECK_ERRNO(0, true);
if (co->num_interfaces > 0) {
- /**
- * 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");
+ /* Try loading if_epair and if that fails skip the test. */
+ kldload("if_epair");
+ ATF_REQUIRE_KERNEL_MODULE("if_epair");
/* Clear errno for the following tests. */
errno = 0;