Skip to content

RFC: Consolidate test rootfs in single place #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testsuite/test-blacklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static int blacklist_1(const struct test *t)

DEFINE_TEST(blacklist_1, .description = "check if modules are correctly blacklisted",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-blacklist/",
[TC_ROOTFS] = "test-blacklist/",
});

TESTSUITE_MAIN();
2 changes: 1 addition & 1 deletion testsuite/test-dependencies.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ DEFINE_TEST(test_dependencies,
.description = "test if kmod_module_get_dependencies works",
.config = {
[TC_UNAME_R] = TEST_UNAME,
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-dependencies/",
[TC_ROOTFS] = "test-dependencies/",
});

TESTSUITE_MAIN();
84 changes: 32 additions & 52 deletions testsuite/test-depmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
test_spawn_prog(TOOLS_DIR "/depmod", \
(const char *[]){ TOOLS_DIR "/depmod", ##__VA_ARGS__, NULL })

#define MODULES_UNAME "4.4.4"
#define MODULES_ORDER_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-order-compressed"
#define MODULES_ORDER_LIB_MODULES MODULES_ORDER_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME
static noreturn int depmod_modules_order_for_compressed(const struct test *t)
{
EXEC_DEPMOD();
Expand All @@ -29,22 +26,18 @@ static noreturn int depmod_modules_order_for_compressed(const struct test *t)
DEFINE_TEST(depmod_modules_order_for_compressed,
.description = "check if depmod let aliases in right order when using compressed modules",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_ROOTFS] = MODULES_ORDER_ROOTFS,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = "test-depmod/modules-order-compressed",
},
.output = {
.files = (const struct keyval[]) {
{ MODULES_ORDER_LIB_MODULES "/correct-modules.alias",
MODULES_ORDER_LIB_MODULES "/modules.alias" },
{ "correct-modules.alias", "modules.alias" },
{ },
},
});

#define MODULES_OUTDIR_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-outdir"
#define MODULES_OUTDIR_LIB_MODULES_OUTPUT \
MODULES_OUTDIR_ROOTFS "/outdir" MODULE_DIRECTORY "/" MODULES_UNAME
#define MODULES_OUTDIR_LIB_MODULES_INPUT \
MODULES_OUTDIR_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME
MODULES_OUTDIR_ROOTFS "/outdir" MODULE_DIRECTORY "/" "4.4.4"
static noreturn int depmod_modules_outdir(const struct test *t)
{
EXEC_DEPMOD("--outdir", "/outdir/");
Expand All @@ -53,8 +46,8 @@ static noreturn int depmod_modules_outdir(const struct test *t)
DEFINE_TEST(depmod_modules_outdir,
.description = "check if depmod honours the outdir option",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_ROOTFS] = MODULES_OUTDIR_ROOTFS,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = "test-depmod/modules-outdir",
},
.output = {
.files = (const struct keyval[]) {
Expand All @@ -66,9 +59,6 @@ DEFINE_TEST(depmod_modules_outdir,
},
});

#define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-simple"
#define SEARCH_ORDER_SIMPLE_LIB_MODULES \
SEARCH_ORDER_SIMPLE_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME
static noreturn int depmod_search_order_simple(const struct test *t)
{
EXEC_DEPMOD();
Expand All @@ -77,20 +67,19 @@ static noreturn int depmod_search_order_simple(const struct test *t)
DEFINE_TEST(depmod_search_order_simple,
.description = "check if depmod honor search order in config",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_ROOTFS] = SEARCH_ORDER_SIMPLE_ROOTFS,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = "test-depmod/search-order-simple"
},
.output = {
.files = (const struct keyval[]) {
{ SEARCH_ORDER_SIMPLE_LIB_MODULES "/correct-modules.dep",
SEARCH_ORDER_SIMPLE_LIB_MODULES "/modules.dep" },
{ "correct-modules.dep", "modules.dep" },
{ },
},
});

#define ANOTHER_MODDIR "/foobar"
#define RELATIVE_MODDIR "foobar2"
#define MODULES_ANOTHER_MODDIR_ROOTFS TESTSUITE_ROOTFS "test-depmod/another-moddir"
#define MODULES_ANOTHER_MODDIR_ROOTFS "test-depmod/another-moddir"
static noreturn int depmod_another_moddir(const struct test *t)
{
EXEC_DEPMOD("-m", ANOTHER_MODDIR);
Expand All @@ -104,34 +93,30 @@ static noreturn int depmod_another_moddir_relative(const struct test *t)
DEFINE_TEST(depmod_another_moddir,
.description = "check depmod -m flag",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = MODULES_ANOTHER_MODDIR_ROOTFS,
},
.output = {
.files = (const struct keyval[]) {
{ MODULES_ANOTHER_MODDIR_ROOTFS "/correct-modules.dep",
MODULES_ANOTHER_MODDIR_ROOTFS ANOTHER_MODDIR "/" MODULES_UNAME "/modules.dep" },
MODULES_ANOTHER_MODDIR_ROOTFS ANOTHER_MODDIR "/" "4.4.4" "/modules.dep" },
{ },
},
});
DEFINE_TEST(depmod_another_moddir_relative,
.description = "check depmod -m flag with relative dir",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = MODULES_ANOTHER_MODDIR_ROOTFS,
},
.output = {
.files = (const struct keyval[]) {
{ MODULES_ANOTHER_MODDIR_ROOTFS "/correct-modules.dep",
MODULES_ANOTHER_MODDIR_ROOTFS "/" RELATIVE_MODDIR "/" MODULES_UNAME "/modules.dep" },
MODULES_ANOTHER_MODDIR_ROOTFS "/" RELATIVE_MODDIR "/" "4.4.4" "/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)
{
EXEC_DEPMOD();
Expand All @@ -140,18 +125,17 @@ static noreturn int depmod_search_order_same_prefix(const struct test *t)
DEFINE_TEST(depmod_search_order_same_prefix,
.description = "check if depmod honor search order in config with same prefix",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_ROOTFS] = SEARCH_ORDER_SAME_PREFIX_ROOTFS,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = "test-depmod/search-order-same-prefix",
},
.output = {
.files = (const struct keyval[]) {
{ SEARCH_ORDER_SAME_PREFIX_LIB_MODULES "/correct-modules.dep",
SEARCH_ORDER_SAME_PREFIX_LIB_MODULES "/modules.dep" },
{ "correct-modules.dep", "modules.dep" },
{ },
},
});

#define DETECT_LOOP_ROOTFS TESTSUITE_ROOTFS "test-depmod/detect-loop"
#define DETECT_LOOP_ROOTFS "test-depmod/detect-loop"
static noreturn int depmod_detect_loop(const struct test *t)
{
EXEC_DEPMOD();
Expand All @@ -160,18 +144,17 @@ static noreturn int depmod_detect_loop(const struct test *t)
DEFINE_TEST(depmod_detect_loop,
.description = "check if depmod detects module loops correctly",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = DETECT_LOOP_ROOTFS,
},
.expected_fail = true,
.output = {
.err = DETECT_LOOP_ROOTFS "/correct.txt",
});

#define SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS \
TESTSUITE_ROOTFS "test-depmod/search-order-external-first"
#define SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS "test-depmod/search-order-external-first"
#define SEARCH_ORDER_EXTERNAL_FIRST_LIB_MODULES \
SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME
SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS MODULE_DIRECTORY "/" "4.4.4"
static noreturn int depmod_search_order_external_first(const struct test *t)
{
EXEC_DEPMOD();
Expand All @@ -180,7 +163,7 @@ static noreturn int depmod_search_order_external_first(const struct test *t)
DEFINE_TEST(depmod_search_order_external_first,
.description = "check if depmod honor external keyword with higher priority",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS,
},
.output = {
Expand All @@ -191,10 +174,9 @@ DEFINE_TEST(depmod_search_order_external_first,
},
});

#define SEARCH_ORDER_EXTERNAL_LAST_ROOTFS \
TESTSUITE_ROOTFS "test-depmod/search-order-external-last"
#define SEARCH_ORDER_EXTERNAL_LAST_ROOTFS "test-depmod/search-order-external-last"
#define SEARCH_ORDER_EXTERNAL_LAST_LIB_MODULES \
SEARCH_ORDER_EXTERNAL_LAST_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME
SEARCH_ORDER_EXTERNAL_LAST_ROOTFS MODULE_DIRECTORY "/" "4.4.4"
static noreturn int depmod_search_order_external_last(const struct test *t)
{
EXEC_DEPMOD();
Expand All @@ -203,7 +185,7 @@ static noreturn int depmod_search_order_external_last(const struct test *t)
DEFINE_TEST(depmod_search_order_external_last,
.description = "check if depmod honor external keyword with lower priority",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_LAST_ROOTFS,
},
.output = {
Expand All @@ -214,9 +196,9 @@ DEFINE_TEST(depmod_search_order_external_last,
},
});

#define SEARCH_ORDER_OVERRIDE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-override"
#define SEARCH_ORDER_OVERRIDE_ROOTFS "test-depmod/search-order-override"
#define SEARCH_ORDER_OVERRIDE_LIB_MODULES \
SEARCH_ORDER_OVERRIDE_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME
SEARCH_ORDER_OVERRIDE_ROOTFS MODULE_DIRECTORY "/" "4.4.4"
static noreturn int depmod_search_order_override(const struct test *t)
{
EXEC_DEPMOD();
Expand All @@ -225,7 +207,7 @@ static noreturn int depmod_search_order_override(const struct test *t)
DEFINE_TEST(depmod_search_order_override,
.description = "check if depmod honor override keyword",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = SEARCH_ORDER_OVERRIDE_ROOTFS,
},
.output = {
Expand All @@ -236,8 +218,7 @@ DEFINE_TEST(depmod_search_order_override,
},
});

#define CHECK_WEAKDEP_ROOTFS TESTSUITE_ROOTFS "test-depmod/check-weakdep"
#define CHECK_WEAKDEP_LIB_MODULES CHECK_WEAKDEP_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME
#define CHECK_WEAKDEP_LIB_MODULES CHECK_WEAKDEP_ROOTFS MODULE_DIRECTORY "/" "4.4.4"
static noreturn int depmod_check_weakdep(const struct test *t)
{
EXEC_DEPMOD();
Expand All @@ -246,13 +227,12 @@ static noreturn int depmod_check_weakdep(const struct test *t)
DEFINE_TEST(depmod_check_weakdep,
.description = "check weakdep output",
.config = {
[TC_UNAME_R] = MODULES_UNAME,
[TC_ROOTFS] = CHECK_WEAKDEP_ROOTFS,
[TC_UNAME_R] = "4.4.4",
[TC_ROOTFS] = "test-depmod/check-weakdep",
},
.output = {
.files = (const struct keyval[]) {
{ CHECK_WEAKDEP_LIB_MODULES "/correct-modules.weakdep",
CHECK_WEAKDEP_LIB_MODULES "/modules.weakdep" },
{ "correct-modules.weakdep", "modules.weakdep" },
{ },
},
});
Expand Down
9 changes: 4 additions & 5 deletions testsuite/test-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ DEFINE_TEST_WITH_FUNC(
.description =
"test if kmod_load_resources works (recent modprobe on kernel without modules.builtin.modinfo)",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-init-load-resources/",
[TC_ROOTFS] = "test-init-load-resources/",
[TC_UNAME_R] = "5.6.0",
});

Expand All @@ -53,8 +53,7 @@ DEFINE_TEST_WITH_FUNC(
.description =
"test if kmod_load_resources works with empty modules.builtin.aliases.bin (recent depmod on kernel without modules.builtin.modinfo)",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS
"test-init-load-resources-empty-builtin-aliases-bin/",
[TC_ROOTFS] = "test-init-load-resources-empty-builtin-aliases-bin/",
[TC_UNAME_R] = "5.6.0",
});

Expand Down Expand Up @@ -102,7 +101,7 @@ static noreturn int test_insert(const struct test *t)
DEFINE_TEST(test_insert,
.description = "test if libkmod's insert_module returns ok",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-init/",
[TC_ROOTFS] = "test-init/",
[TC_INIT_MODULE_RETCODES] = "bla:1:20",
},
.modules_loaded = "mod_simple");
Expand Down Expand Up @@ -149,7 +148,7 @@ static noreturn int test_remove(const struct test *t)
DEFINE_TEST(
test_remove, .description = "test if libkmod's remove_module returns ok",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-remove/",
[TC_ROOTFS] = "test-remove/",
[TC_DELETE_MODULE_RETCODES] = "mod-simple:0:0:bla:-1:" STRINGIFY(ENOENT),
});

Expand Down
4 changes: 2 additions & 2 deletions testsuite/test-initstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ DEFINE_TEST(
.description =
"test if libkmod return correct initstate for builtin module from lookup",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-initstate",
[TC_ROOTFS] = "test-initstate",
[TC_UNAME_R] = "4.4.4",
});

Expand Down Expand Up @@ -104,7 +104,7 @@ DEFINE_TEST(test_initstate_from_name,
.description =
"test if libkmod return correct initstate for builtin module from name",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-initstate",
[TC_ROOTFS] = "test-initstate",
[TC_UNAME_R] = "4.4.4",
});

Expand Down
4 changes: 2 additions & 2 deletions testsuite/test-loaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ static int loaded_1(const struct test *t)
DEFINE_TEST(loaded_1,
.description = "check if list of module is created",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-loaded/",
[TC_ROOTFS] = "test-loaded/",
},
.output = {
.out = TESTSUITE_ROOTFS "test-loaded/correct.txt",
.out = "test-loaded/correct.txt",
});

TESTSUITE_MAIN();
16 changes: 8 additions & 8 deletions testsuite/test-modinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ static const char *progname = TOOLS_DIR "/modinfo";
DEFINE_TEST(test_modinfo_##_field, \
.description = "check " #_field " output of modinfo for different architectures", \
.config = { \
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-modinfo/", \
[TC_ROOTFS] = "test-modinfo/", \
}, \
.output = { \
.out = TESTSUITE_ROOTFS "test-modinfo/correct-" #_field #_flavor ".txt", \
.out = "test-modinfo/correct-" #_field #_flavor ".txt", \
})

/* TODO: add cross-compiled modules to the test */
Expand Down Expand Up @@ -72,10 +72,10 @@ static noreturn int test_modinfo_signature(const struct test *t)
DEFINE_TEST(test_modinfo_signature,
.description = "check signatures are correct for modinfo is correct for i686, ppc64, s390x and x86_64",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-modinfo/",
[TC_ROOTFS] = "test-modinfo/",
},
.output = {
.out = TESTSUITE_ROOTFS "test-modinfo/correct.txt",
.out = "test-modinfo/correct.txt",
});
#endif

Expand All @@ -95,11 +95,11 @@ static noreturn int test_modinfo_external(const struct test *t)
DEFINE_TEST(test_modinfo_external,
.description = "check if modinfo finds external module",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-modinfo/external",
[TC_ROOTFS] = "test-modinfo/external",
[TC_UNAME_R] = "4.4.4",
},
.output = {
.out = TESTSUITE_ROOTFS "test-modinfo/correct-external.txt",
.out = "test-modinfo/correct-external.txt",
})

static noreturn int test_modinfo_builtin(const struct test *t)
Expand All @@ -117,11 +117,11 @@ static noreturn int test_modinfo_builtin(const struct test *t)
DEFINE_TEST(test_modinfo_builtin,
.description = "check if modinfo finds builtin module",
.config = {
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-modinfo/builtin",
[TC_ROOTFS] = "test-modinfo/builtin",
[TC_UNAME_R] = "6.11.0",
},
.output = {
.out = TESTSUITE_ROOTFS "test-modinfo/correct-builtin.txt",
.out = "test-modinfo/correct-builtin.txt",
})

TESTSUITE_MAIN();
Loading
Loading