Skip to content

Commit

Permalink
XXX: testsuite: make all output.files relative to TC_ROOTFS
Browse files Browse the repository at this point in the history
With this commit all our tests have a single entrypoint (from a
file-system POV) which means we get a lot less duplication, all test
specific files (be that config, input, expectations, etc) are in
designated folders.

As result, this paves the route to running the tests in chroot-like
enviroment were we can drop-in the folder, adjust the module rootfs
location in path.so or equivalent and have the test(s) churn.

Signed-off-by: Emil Velikov <[email protected]>
  • Loading branch information
evelikov committed Nov 21, 2024
1 parent 273d8fc commit 873a260
Showing 1 changed file with 27 additions and 44 deletions.
71 changes: 27 additions & 44 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 "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 "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 "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,13 +67,12 @@ 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" },
{ },
},
});
Expand All @@ -104,33 +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 "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 @@ -139,13 +125,12 @@ 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" },
{ },
},
});
Expand All @@ -159,7 +144,7 @@ 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,
Expand All @@ -169,7 +154,7 @@ DEFINE_TEST(depmod_detect_loop,

#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 @@ -178,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,7 +176,7 @@ DEFINE_TEST(depmod_search_order_external_first,

#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 @@ -200,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 @@ -213,7 +198,7 @@ DEFINE_TEST(depmod_search_order_external_last,

#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 @@ -222,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 @@ -233,8 +218,7 @@ DEFINE_TEST(depmod_search_order_override,
},
});

#define CHECK_WEAKDEP_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 @@ -243,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

0 comments on commit 873a260

Please sign in to comment.