Skip to content

Commit

Permalink
tests: commands: only use one subtest (#322)
Browse files Browse the repository at this point in the history
ELL 0.72 recently changed the way the subtests are executed: each one is
now executed in a dedicated process, forked from the same parent [1].

This is causing issues for the 'commands' test, because some shared info
are shared between subtests. 'info' could be created in a shared memory
with mmap(), but it looks like there are more changes needed in mptcpd
itself to cope with that, probably the memory allocated for the pm
structure and more.

Then, for the moment, it looks better and easier to simplify things, an
only use one subtest.

Link: https://git.kernel.org/pub/scm/libs/ell/ell.git/commit/?id=e0628c4 [1]

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
  • Loading branch information
matttbe authored Feb 11, 2025
1 parent ce7bced commit 48942b2
Showing 1 changed file with 51 additions and 31 deletions.
82 changes: 51 additions & 31 deletions tests/test-commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,45 @@ static void handle_rtm_deladdr(int errnum,

// -------------------------------------------------------------------

static void test_add(const char *name,
l_test_func_t function,
void *test_data)
{
l_info("Test: %s", name);
function(test_data);
}

static void exec_tests(void *user_data)
{
struct test_info *const info = user_data;

// Non-command tests.
test_add("get_port", test_get_port, NULL);
test_add("get_nm", test_get_nm, info);

// In-kernel path manager tests.
test_add("add_addr - kernel", test_add_addr_kernel, info);
test_add("get_addr", test_get_addr, info);
test_add("dump_addrs", test_dump_addrs, info);
test_add("set_flags", test_set_flags, info);
test_add("remove_addr - kernel", test_remove_addr_kernel, info);
test_add("set_limits", test_set_limits, info);
test_add("get_limits", test_get_limits, info);
test_add("flush_addrs", test_flush_addrs, info);

// User space path manager tests.
test_add("add_addr - user", test_add_addr_user, info);
test_add("add_subflow", test_add_subflow, info);
test_add("set_backup", test_set_backup, info);
test_add("remove_subflow", test_remove_subflow, info);
test_add("remove_addr - user", test_remove_addr_user, info);
}

static void run_tests(void *user_data)
{
struct test_info *const t = user_data;

l_test_run();
exec_tests(user_data);

t->tests_called = true;
}
Expand Down Expand Up @@ -690,7 +724,6 @@ static void setup_tests (void *user_data)
"--plugin-dir",
TEST_PLUGIN_DIR
};
static char **args = argv;

static int argc = L_ARRAY_SIZE(argv);

Expand All @@ -704,29 +737,6 @@ static void setup_tests (void *user_data)
mptcpd_pm_register_ops(info->pm, &pm_ops, info);

assert(registered);

l_test_init(&argc, &args);

// Non-command tests.
l_test_add("get_port", test_get_port, NULL);
l_test_add("get_nm", test_get_nm, info);

// In-kernel path manager tests.
l_test_add("add_addr - kernel", test_add_addr_kernel, info);
l_test_add("get_addr", test_get_addr, info);
l_test_add("dump_addrs", test_dump_addrs, info);
l_test_add("set_flags", test_set_flags, info);
l_test_add("remove_addr - kernel", test_remove_addr_kernel, info);
l_test_add("set_limits", test_set_limits, info);
l_test_add("get_limits", test_get_limits, info);
l_test_add("flush_addrs", test_flush_addrs, info);

// User space path manager tests.
l_test_add("add_addr - user", test_add_addr_user, info);
l_test_add("add_subflow", test_add_subflow, info);
l_test_add("set_backup", test_set_backup, info);
l_test_add("remove_subflow", test_remove_subflow, info);
l_test_add("remove_addr - user", test_remove_addr_user, info);
}

static void complete_address_setup(void *user_data)
Expand Down Expand Up @@ -863,13 +873,11 @@ static uint8_t get_prefix_len(struct sockaddr const *sa)

// -------------------------------------------------------------------

int main(void)
static void test_commands(void const *data)
{
// Skip this test if the kernel is not MPTCP capable.
tests_skip_if_no_mptcp();
(void) data;

if (!l_main_init())
return -1;
assert(l_main_init());

l_log_set_stderr();
l_debug_enable("*");
Expand Down Expand Up @@ -939,7 +947,19 @@ int main(void)
mptcpd_pm_destroy(info.pm);
mptcpd_config_destroy(info.config);

return l_main_exit() ? 0 : -1;
assert(l_main_exit());
}

int main(int argc, char *argv[])
{
// Skip this test if the kernel is not MPTCP capable.
tests_skip_if_no_mptcp();

l_test_init(&argc, &argv);

l_test_add("commands", test_commands, NULL);

return l_test_run();
}


Expand Down

0 comments on commit 48942b2

Please sign in to comment.