From: Lucas De Marchi Date: Mon, 9 Sep 2024 06:03:01 +0000 (-0500) Subject: testsuite: Test depmod's -m flag X-Git-Tag: v34~376 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aa7130edaf90d4f91ecdbb495765177e096abf7d;p=thirdparty%2Fkmod.git testsuite: Test depmod's -m flag Link: https://github.com/kmod-project/kmod/pull/100 Signed-off-by: Lucas De Marchi --- diff --git a/scripts/setup-rootfs.sh b/scripts/setup-rootfs.sh index c44cd684..92c5d2dd 100755 --- a/scripts/setup-rootfs.sh +++ b/scripts/setup-rootfs.sh @@ -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 index 00000000..54766537 --- /dev/null +++ b/testsuite/rootfs-pristine/test-depmod/another-moddir/foobar/4.4.4/correct-modules.dep @@ -0,0 +1 @@ +kernel/mod-simple.ko: diff --git a/testsuite/test-depmod.c b/testsuite/test-depmod.c index 478dda04..36729673 100644 --- a/testsuite/test-depmod.c +++ b/testsuite/test-depmod.c @@ -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)