]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: Test depmod's -m flag
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 9 Sep 2024 06:03:01 +0000 (01:03 -0500)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 10 Sep 2024 18:25:46 +0000 (13:25 -0500)
Link: https://github.com/kmod-project/kmod/pull/100
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
scripts/setup-rootfs.sh
testsuite/rootfs-pristine/test-depmod/another-moddir/foobar/4.4.4/correct-modules.dep [new file with mode: 0644]
testsuite/test-depmod.c

index c44cd68497634270b24363efc9baa7d35125444c..92c5d2dd8e69a77d663440330c11a94bc7900ce2 100755 (executable)
@@ -8,6 +8,7 @@ MODULE_PLAYGROUND=$3
 CONFIG_H=$4
 SYSCONFDIR=$5
 MODULE_DIRECTORY=$6
+ANOTHER_MODULE_DIRECTORY=/foobar
 
 # create rootfs from rootfs-pristine
 
@@ -103,6 +104,7 @@ map=(
     ["test-depmod/modules-outdir$MODULE_DIRECTORY/4.4.4/kernel/drivers/block/cciss.ko"]="mod-fake-cciss.ko"
     ["test-depmod/modules-outdir$MODULE_DIRECTORY/4.4.4/kernel/drivers/scsi/hpsa.ko"]="mod-fake-hpsa.ko"
     ["test-depmod/modules-outdir$MODULE_DIRECTORY/4.4.4/kernel/drivers/scsi/scsi_mod.ko"]="mod-fake-scsi-mod.ko"
+    ["test-depmod/another-moddir$ANOTHER_MODULE_DIRECTORY/4.4.4/kernel/"]="mod-simple.ko"
     # TODO: add cross-compiled modules to the test
     ["test-modinfo/mod-simple.ko"]="mod-simple.ko"
     ["test-modinfo/mod-simple-sha1.ko"]="mod-simple.ko"
diff --git a/testsuite/rootfs-pristine/test-depmod/another-moddir/foobar/4.4.4/correct-modules.dep b/testsuite/rootfs-pristine/test-depmod/another-moddir/foobar/4.4.4/correct-modules.dep
new file mode 100644 (file)
index 0000000..5476653
--- /dev/null
@@ -0,0 +1 @@
+kernel/mod-simple.ko:
index 478dda04f8459b1e7170d9eb29dd8b9167ea5296..36729673aaf2c10e26ab52550558ded252e9af67 100644 (file)
@@ -103,6 +103,37 @@ DEFINE_TEST(depmod_search_order_simple,
                },
        });
 
+
+#define ANOTHER_MODDIR "/foobar"
+#define MODULES_ANOTHER_MODDIR_ROOTFS TESTSUITE_ROOTFS "test-depmod/another-moddir"
+#define MODULES_ANOTHER_MODDIR_LIB_MODULES MODULES_ANOTHER_MODDIR_ROOTFS ANOTHER_MODDIR "/" MODULES_UNAME
+static noreturn int depmod_another_moddir(const struct test *t)
+{
+       const char *progname = TOOLS_DIR "/depmod";
+       const char *const args[] = {
+               progname,
+               "-m",
+               ANOTHER_MODDIR,
+               NULL,
+       };
+
+       test_spawn_prog(progname, args);
+       exit(EXIT_FAILURE);
+}
+DEFINE_TEST(depmod_another_moddir,
+       .description = "check depmod -m flag",
+       .config = {
+               [TC_UNAME_R] = MODULES_UNAME,
+               [TC_ROOTFS] = MODULES_ANOTHER_MODDIR_ROOTFS,
+       },
+       .output = {
+               .files = (const struct keyval[]) {
+                       { MODULES_ANOTHER_MODDIR_LIB_MODULES "/correct-modules.dep",
+                         MODULES_ANOTHER_MODDIR_LIB_MODULES "/modules.dep" },
+                       { },
+               },
+       });
+
 #define SEARCH_ORDER_SAME_PREFIX_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-same-prefix"
 #define SEARCH_ORDER_SAME_PREFIX_LIB_MODULES SEARCH_ORDER_SAME_PREFIX_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME
 static noreturn int depmod_search_order_same_prefix(const struct test *t)