Skip to content

Commit 48942b2

Browse files
authored
tests: commands: only use one subtest (#322)
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) <[email protected]>
1 parent ce7bced commit 48942b2

File tree

1 file changed

+51
-31
lines changed

1 file changed

+51
-31
lines changed

tests/test-commands.c

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,45 @@ static void handle_rtm_deladdr(int errnum,
610610

611611
// -------------------------------------------------------------------
612612

613+
static void test_add(const char *name,
614+
l_test_func_t function,
615+
void *test_data)
616+
{
617+
l_info("Test: %s", name);
618+
function(test_data);
619+
}
620+
621+
static void exec_tests(void *user_data)
622+
{
623+
struct test_info *const info = user_data;
624+
625+
// Non-command tests.
626+
test_add("get_port", test_get_port, NULL);
627+
test_add("get_nm", test_get_nm, info);
628+
629+
// In-kernel path manager tests.
630+
test_add("add_addr - kernel", test_add_addr_kernel, info);
631+
test_add("get_addr", test_get_addr, info);
632+
test_add("dump_addrs", test_dump_addrs, info);
633+
test_add("set_flags", test_set_flags, info);
634+
test_add("remove_addr - kernel", test_remove_addr_kernel, info);
635+
test_add("set_limits", test_set_limits, info);
636+
test_add("get_limits", test_get_limits, info);
637+
test_add("flush_addrs", test_flush_addrs, info);
638+
639+
// User space path manager tests.
640+
test_add("add_addr - user", test_add_addr_user, info);
641+
test_add("add_subflow", test_add_subflow, info);
642+
test_add("set_backup", test_set_backup, info);
643+
test_add("remove_subflow", test_remove_subflow, info);
644+
test_add("remove_addr - user", test_remove_addr_user, info);
645+
}
646+
613647
static void run_tests(void *user_data)
614648
{
615649
struct test_info *const t = user_data;
616650

617-
l_test_run();
651+
exec_tests(user_data);
618652

619653
t->tests_called = true;
620654
}
@@ -690,7 +724,6 @@ static void setup_tests (void *user_data)
690724
"--plugin-dir",
691725
TEST_PLUGIN_DIR
692726
};
693-
static char **args = argv;
694727

695728
static int argc = L_ARRAY_SIZE(argv);
696729

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

706739
assert(registered);
707-
708-
l_test_init(&argc, &args);
709-
710-
// Non-command tests.
711-
l_test_add("get_port", test_get_port, NULL);
712-
l_test_add("get_nm", test_get_nm, info);
713-
714-
// In-kernel path manager tests.
715-
l_test_add("add_addr - kernel", test_add_addr_kernel, info);
716-
l_test_add("get_addr", test_get_addr, info);
717-
l_test_add("dump_addrs", test_dump_addrs, info);
718-
l_test_add("set_flags", test_set_flags, info);
719-
l_test_add("remove_addr - kernel", test_remove_addr_kernel, info);
720-
l_test_add("set_limits", test_set_limits, info);
721-
l_test_add("get_limits", test_get_limits, info);
722-
l_test_add("flush_addrs", test_flush_addrs, info);
723-
724-
// User space path manager tests.
725-
l_test_add("add_addr - user", test_add_addr_user, info);
726-
l_test_add("add_subflow", test_add_subflow, info);
727-
l_test_add("set_backup", test_set_backup, info);
728-
l_test_add("remove_subflow", test_remove_subflow, info);
729-
l_test_add("remove_addr - user", test_remove_addr_user, info);
730740
}
731741

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

864874
// -------------------------------------------------------------------
865875

866-
int main(void)
876+
static void test_commands(void const *data)
867877
{
868-
// Skip this test if the kernel is not MPTCP capable.
869-
tests_skip_if_no_mptcp();
878+
(void) data;
870879

871-
if (!l_main_init())
872-
return -1;
880+
assert(l_main_init());
873881

874882
l_log_set_stderr();
875883
l_debug_enable("*");
@@ -939,7 +947,19 @@ int main(void)
939947
mptcpd_pm_destroy(info.pm);
940948
mptcpd_config_destroy(info.config);
941949

942-
return l_main_exit() ? 0 : -1;
950+
assert(l_main_exit());
951+
}
952+
953+
int main(int argc, char *argv[])
954+
{
955+
// Skip this test if the kernel is not MPTCP capable.
956+
tests_skip_if_no_mptcp();
957+
958+
l_test_init(&argc, &argv);
959+
960+
l_test_add("commands", test_commands, NULL);
961+
962+
return l_test_run();
943963
}
944964

945965

0 commit comments

Comments
 (0)