From 9672405eb9008511d244c35ebc57c1f6d4e6c1c1 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Thu, 29 Jun 2023 21:32:20 +0200 Subject: [PATCH] test: unit: tcp: fix tcp state tests to not break other tests On platform where check cannot fork (win32), the tcp_state tests crashed other tests. Signed-off-by: Simon Goldschmidt --- test/unit/tcp/test_tcp_state.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/unit/tcp/test_tcp_state.c b/test/unit/tcp/test_tcp_state.c index f7a737c9..afd21fce 100644 --- a/test/unit/tcp/test_tcp_state.c +++ b/test/unit/tcp/test_tcp_state.c @@ -68,7 +68,9 @@ create_listening_pcb(u16_t local_port, struct test_tcp_counters *counters) return lpcb; } -/* Setups/teardown functions */ +/* Setup/teardown functions */ +static struct netif* old_netif_list; +static struct netif* old_netif_default; static void tcp_state_setup(void) @@ -82,16 +84,25 @@ tcp_state_setup(void) tcp_ticks = 0; test_tcp_timer = 0; - /* initialize local vars */ - test_tcp_init_netif(&test_netif, &test_txcounters, &test_local_ip, &test_netmask); + + old_netif_list = netif_list; + old_netif_default = netif_default; + netif_list = NULL; + netif_default = NULL; tcp_remove_all(); + test_tcp_init_netif(&test_netif, &test_txcounters, &test_local_ip, &test_netmask); lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT)); } static void tcp_state_teardown(void) { + netif_list = NULL; + netif_default = NULL; tcp_remove_all(); + /* restore netif_list for next tests (e.g. loopif) */ + netif_list = old_netif_list; + netif_default = old_netif_default; lwip_check_ensure_no_alloc(SKIP_POOL(MEMP_SYS_TIMEOUT)); }