Skip to content

Commit

Permalink
testsuite: add unit test for module overriding
Browse files Browse the repository at this point in the history
This test is like the "replace" test, but it uses depmods's
built-in priority logic by copying the replacement modules
into the "updates" subdirectory. "depmod -I -a" is expected
to detect this change.

Signed-off-by: Martin Wilck <[email protected]>
  • Loading branch information
mwilck committed Nov 18, 2024
1 parent 4ab8a53 commit 7902117
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 1 deletion.
25 changes: 25 additions & 0 deletions scripts/setup-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,31 @@ map=(
["test-depmod/big-01-replace/lib/modules/5.3.18/kernel/drivers/md/dm-mod.ko"]="ex-dm-mod.ko"
["test-depmod/big-01-replace/lib/modules/5.3.18/kernel/fs/configfs/configfs.ko"]="ex-configfs.ko"
["test-depmod/big-01-replace/lib/modules/5.3.18/symvers"]="symvers"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/block/t10-pi.ko"]="ex-t10-pi.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/cdrom/cdrom.ko"]="ex-cdrom.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/scsi_mod.ko"]="ex-scsi_mod.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/scsi_transport_fc.ko"]="ex-scsi_transport_fc.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/scsi_transport_sas.ko"]="ex-scsi_transport_sas.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/sd_mod.ko"]="ex-sd_mod.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/sr_mod.ko"]="ex-sr_mod.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/ses.ko"]="ex-ses.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/device_handler/scsi_dh_alua.ko"]="ex-scsi_dh_alua.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/raid_class.ko"]="ex-raid_class.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/mpt3sas.ko"]="ex-mpt3sas.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/qla2xxx/qla2xxx.ko"]="ex-qla2xxx.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/scsi/qla2xxx/tcm_qla2xxx.ko"]="ex-tcm_qla2xxx.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/updates/qla2xxx.ko"]="other/ex-qla2xxx.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/updates/tcm_qla2xxx.ko"]="other/ex-tcm_qla2xxx.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/nvme/host/nvme-fc.ko"]="ex-nvme-fc.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/nvme/host/nvme-fabrics.ko"]="ex-nvme-fabrics.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/nvme/host/nvme-core.ko"]="ex-nvme-core.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/target/target_core_mod.ko"]="ex-target_core_mod.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/misc/enclosure.ko"]="ex-enclosure.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/md/dm-multipath.ko"]="ex-dm-multipath.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/md/dm-service-time.ko"]="ex-dm-multipath.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/drivers/md/dm-mod.ko"]="ex-dm-mod.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/kernel/fs/configfs/configfs.ko"]="ex-configfs.ko"
["test-depmod/big-01-override/lib/modules/5.3.18/symvers"]="symvers"
)

gzip_array=(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
kernel/drivers/md/dm-multipath.ko: kernel/drivers/md/dm-mod.ko kernel/drivers/scsi/scsi_mod.ko
updates/qla2xxx.ko: kernel/drivers/nvme/host/nvme-fc.ko kernel/drivers/scsi/scsi_transport_fc.ko kernel/drivers/nvme/host/nvme-fabrics.ko kernel/drivers/scsi/scsi_mod.ko kernel/drivers/nvme/host/nvme-core.ko kernel/block/t10-pi.ko
kernel/drivers/nvme/host/nvme-fc.ko: kernel/drivers/nvme/host/nvme-fabrics.ko kernel/drivers/nvme/host/nvme-core.ko kernel/block/t10-pi.ko
kernel/drivers/nvme/host/nvme-fabrics.ko: kernel/drivers/nvme/host/nvme-core.ko kernel/block/t10-pi.ko
kernel/drivers/scsi/scsi_mod.ko:
kernel/drivers/scsi/ses.ko: kernel/drivers/misc/enclosure.ko kernel/drivers/scsi/scsi_transport_sas.ko kernel/drivers/scsi/scsi_mod.ko
kernel/drivers/scsi/scsi_transport_sas.ko: kernel/drivers/scsi/scsi_mod.ko
kernel/drivers/scsi/mpt3sas.ko: kernel/drivers/scsi/raid_class.ko kernel/drivers/scsi/scsi_transport_sas.ko kernel/drivers/scsi/scsi_mod.ko
kernel/drivers/md/dm-mod.ko:
kernel/drivers/nvme/host/nvme-core.ko: kernel/block/t10-pi.ko
updates/tcm_qla2xxx.ko: updates/qla2xxx.ko kernel/drivers/target/target_core_mod.ko kernel/fs/configfs/configfs.ko kernel/drivers/nvme/host/nvme-fc.ko kernel/drivers/scsi/scsi_transport_fc.ko kernel/drivers/nvme/host/nvme-fabrics.ko kernel/drivers/scsi/scsi_mod.ko kernel/drivers/nvme/host/nvme-core.ko kernel/block/t10-pi.ko
kernel/drivers/misc/enclosure.ko:
kernel/drivers/scsi/raid_class.ko: kernel/drivers/scsi/scsi_mod.ko
kernel/drivers/md/dm-service-time.ko: kernel/drivers/md/dm-mod.ko kernel/drivers/scsi/scsi_mod.ko
kernel/drivers/target/target_core_mod.ko: kernel/fs/configfs/configfs.ko
kernel/drivers/scsi/sr_mod.ko: kernel/drivers/cdrom/cdrom.ko kernel/drivers/scsi/scsi_mod.ko
kernel/drivers/scsi/sd_mod.ko: kernel/drivers/scsi/scsi_mod.ko kernel/block/t10-pi.ko
kernel/drivers/scsi/device_handler/scsi_dh_alua.ko: kernel/drivers/scsi/scsi_mod.ko
kernel/drivers/cdrom/cdrom.ko:
kernel/block/t10-pi.ko:
kernel/drivers/scsi/scsi_transport_fc.ko: kernel/drivers/scsi/scsi_mod.ko
kernel/fs/configfs/configfs.ko:
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Aliases for symbols, used by symbol_request().
alias symbol:scsi_target_block_mangled scsi_mod
alias symbol:scsi_remove_host_mangled scsi_mod
alias symbol:t10_pi_type1_crc_mangled t10_pi
alias symbol:scsi_is_sas_rphy_mangled scsi_transport_sas
alias symbol:scsi_dh_attach_mangled scsi_mod
alias symbol:nvme_fc_set_remoteport_devloss_mangled nvme_fc
alias symbol:target_backend_unregister_mangled target_core_mod
alias symbol:scsi_host_get_mangled scsi_mod
alias symbol:__scsi_iterate_devices_mangled scsi_mod
alias symbol:target_execute_cmd_mangled target_core_mod
alias symbol:sas_enable_tlr_mangled scsi_transport_sas
alias symbol:fc_attach_transport_mangled scsi_transport_fc
alias symbol:register_cdrom_mangled cdrom
alias symbol:fc_vport_create_mangled scsi_transport_fc
alias symbol:scsi_print_sense_hdr_mangled scsi_mod
alias symbol:scsi_dma_map_mangled scsi_mod
alias symbol:scsi_is_sdev_device_mangled scsi_mod
alias symbol:nvme_complete_rq_mangled nvme_core
alias symbol:dm_unregister_path_selector_mangled dm_service_time
alias symbol:raid_class_attach_mangled raid_class
alias symbol:enclosure_remove_device_mangled enclosure
alias symbol:scsi_mode_sense_mangled scsi_mod
alias symbol:qlt_stop_phase2_mangled qla2xxx
alias symbol:dm_table_run_md_queue_async_mangled dm_mod
alias symbol:nvmf_fail_nonready_command_mangled nvme_fabrics
alias symbol:nvme_uninit_ctrl_mangled nvme_core
alias symbol:config_group_init_mangled configfs
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Aliases extracted from modules themselves.
Binary file not shown.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Soft dependencies extracted from modules themselves.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Weak dependencies extracted from modules themselves.
Binary file not shown.
44 changes: 43 additions & 1 deletion testsuite/test-depmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ DEFINE_TEST(depmod_test_big_01_replace,
#if defined(KMOD_SYSCONFDIR_NOT_ETC)
.skip = true,
#endif
.description = "check depmod -I with module deletion from the big-01 module set",
.description = "check depmod -I with module replacement from the big-01 module set",
.config = {
[TC_UNAME_R] = "5.3.18",
[TC_ROOTFS] = TEST_BIG_01_REPLACE_ROOTFS,
Expand All @@ -564,4 +564,46 @@ DEFINE_TEST(depmod_test_big_01_replace,
},
});

#define TEST_BIG_01_OVERRIDE_ROOTFS TESTSUITE_ROOTFS "test-depmod/big-01-override"
static noreturn int depmod_test_big_01_override(const struct test *t)
{
const char *progname = TOOLS_DIR "/depmod";
const char *const args[] = {
progname,
"-v",
"-e",
"-E",
TEST_BIG_01_OVERRIDE_ROOTFS "/lib/modules/5.3.18/symvers",
"-I",
"-a",
NULL,
};

test_spawn_prog(progname, args);
exit(EXIT_FAILURE);
}
DEFINE_TEST(depmod_test_big_01_override,
#if defined(KMOD_SYSCONFDIR_NOT_ETC)
.skip = true,
#endif
.description = "check depmod -I with module override from the big-01 module set",
.config = {
[TC_UNAME_R] = "5.3.18",
[TC_ROOTFS] = TEST_BIG_01_OVERRIDE_ROOTFS,
},
.output = {
.regex = true,
.files = (const struct keyval[]) {
{ TEST_BIG_01_OVERRIDE_ROOTFS "/lib/modules/5.3.18/correct-modules.dep",
TEST_BIG_01_OVERRIDE_ROOTFS "/lib/modules/5.3.18/modules.dep" },
{ TEST_BIG_01_OVERRIDE_ROOTFS "/lib/modules/5.3.18/correct-modules.dep.bin",
TEST_BIG_01_OVERRIDE_ROOTFS "/lib/modules/5.3.18/modules.dep.bin" },
{ TEST_BIG_01_OVERRIDE_ROOTFS "/lib/modules/5.3.18/correct-modules.symbols",
TEST_BIG_01_OVERRIDE_ROOTFS "/lib/modules/5.3.18/modules.symbols" },
{ TEST_BIG_01_OVERRIDE_ROOTFS "/lib/modules/5.3.18/correct-modules.symbols.bin",
TEST_BIG_01_OVERRIDE_ROOTFS "/lib/modules/5.3.18/modules.symbols.bin" },
{ }
},
});

TESTSUITE_MAIN();

0 comments on commit 7902117

Please sign in to comment.