]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: Add modprobe -c test for weakdep
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 25 Mar 2025 17:12:10 +0000 (12:12 -0500)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 25 Mar 2025 19:14:53 +0000 (14:14 -0500)
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 <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/324
(cherry picked from commit 4d8851cbc548c30f63848fa66c7fcf9611b50d6a)

testsuite/rootfs-pristine/test-weakdep/modprobe-c.txt [new file with mode: 0644]
testsuite/test-weakdep.c

diff --git a/testsuite/rootfs-pristine/test-weakdep/modprobe-c.txt b/testsuite/rootfs-pristine/test-weakdep/modprobe-c.txt
new file mode 100644 (file)
index 0000000..82485a6
--- /dev/null
@@ -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
index fdde0b2b89807721bfa43a7a622182beac948101..61938a00228bc1f816d3ec964ed91fb80761fdc3 100644 (file)
 
 #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();