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 <goldsimon@gmx.de>
This commit is contained in:
Simon Goldschmidt 2023-06-29 21:32:20 +02:00
parent e29870c15e
commit 9672405eb9

View File

@ -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));
}