From 2f00ec3f9f695c8c106857132c7192198dcd3121 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 25 Mar 2025 12:12:10 -0500 Subject: [PATCH] testsuite: Add modprobe -c test for weakdep Currently failing due to buffer overflow, as reported and fixed in https://github.com/kmod-project/kmod/pull/324. Signed-off-by: Lucas De Marchi Link: https://github.com/kmod-project/kmod/pull/324 (cherry picked from commit 4d8851cbc548c30f63848fa66c7fcf9611b50d6a) --- .../test-weakdep/modprobe-c.txt | 7 ++++++ testsuite/test-weakdep.c | 22 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 testsuite/rootfs-pristine/test-weakdep/modprobe-c.txt diff --git a/testsuite/rootfs-pristine/test-weakdep/modprobe-c.txt b/testsuite/rootfs-pristine/test-weakdep/modprobe-c.txt new file mode 100644 index 00000000..82485a61 --- /dev/null +++ b/testsuite/rootfs-pristine/test-weakdep/modprobe-c.txt @@ -0,0 +1,7 @@ +weakdep mod_loop_b mod-loop-a mod-simple +weakdep mod_weakdep mod-simple + +# End of configuration files. Dumping indexes now: + +alias symbol:printA mod_loop_a +alias symbol:printB mod_loop_b diff --git a/testsuite/test-weakdep.c b/testsuite/test-weakdep.c index fdde0b2b..61938a00 100644 --- a/testsuite/test-weakdep.c +++ b/testsuite/test-weakdep.c @@ -15,6 +15,10 @@ #include "testsuite.h" +#define EXEC_MODPROBE(...) \ + test_spawn_prog(TOOLS_DIR "/modprobe", \ + (const char *[]){ TOOLS_DIR "/modprobe", ##__VA_ARGS__, NULL }) + static const char *const mod_name[] = { "mod-loop-b", "mod-weakdep", @@ -76,7 +80,7 @@ static int test_weakdep(const struct test *t) return EXIT_SUCCESS; } DEFINE_TEST(test_weakdep, - .description = "check if modprobe breaks weakdep", + .description = "check if libkmod breaks weakdep", .config = { [TC_UNAME_R] = "4.4.4", [TC_ROOTFS] = TESTSUITE_ROOTFS "test-weakdep", @@ -86,4 +90,20 @@ DEFINE_TEST(test_weakdep, .out = TESTSUITE_ROOTFS "test-weakdep/correct-weakdep.txt", }); +static noreturn int modprobe_config(const struct test *t) +{ + EXEC_MODPROBE("-c"); + exit(EXIT_FAILURE); +} +DEFINE_TEST(modprobe_config, + .expected_fail = true, + .description = "check modprobe config parsing with weakdep", + .config = { + [TC_UNAME_R] = "4.4.4", + [TC_ROOTFS] = TESTSUITE_ROOTFS "test-weakdep", + }, + .output = { + .out = TESTSUITE_ROOTFS "test-weakdep/modprobe-c.txt", + }); + TESTSUITE_MAIN(); -- 2.47.2