adapt unit tests to additional NULL checks

This commit is contained in:
Simon Goldschmidt 2018-06-12 13:47:13 +02:00
parent 1bf323e12f
commit a26a2e1340
3 changed files with 27 additions and 6 deletions

View File

@ -32,6 +32,15 @@ etharp_remove_all(void)
} }
} }
static err_t
dummy_input_function(struct pbuf *p, struct netif *inp)
{
LWIP_UNUSED_ARG(p);
LWIP_UNUSED_ARG(inp);
fail("this netif should have no input");
return ERR_VAL;
}
static err_t static err_t
default_netif_linkoutput(struct netif *netif, struct pbuf *p) default_netif_linkoutput(struct netif *netif, struct pbuf *p)
{ {
@ -62,7 +71,7 @@ default_netif_add(void)
fail_unless(netif_default == NULL); fail_unless(netif_default == NULL);
netif_set_default(netif_add(&test_netif, &test_ipaddr, &test_netmask, netif_set_default(netif_add(&test_netif, &test_ipaddr, &test_netmask,
&test_gw, NULL, default_netif_init, NULL)); &test_gw, NULL, default_netif_init, dummy_input_function));
netif_set_up(&test_netif); netif_set_up(&test_netif);
} }

View File

@ -16,6 +16,15 @@
static struct netif test_netif6; static struct netif test_netif6;
static int linkoutput_ctr; static int linkoutput_ctr;
static err_t
dummy_input_function(struct pbuf *p, struct netif *inp)
{
LWIP_UNUSED_ARG(p);
LWIP_UNUSED_ARG(inp);
fail("this netif should have no input");
return ERR_VAL;
}
static err_t static err_t
default_netif_linkoutput(struct netif *netif, struct pbuf *p) default_netif_linkoutput(struct netif *netif, struct pbuf *p)
{ {
@ -42,7 +51,7 @@ default_netif_add(void)
{ {
struct netif *n; struct netif *n;
fail_unless(netif_default == NULL); fail_unless(netif_default == NULL);
n = netif_add_noaddr(&test_netif6, NULL, default_netif_init, NULL); n = netif_add_noaddr(&test_netif6, NULL, default_netif_init, dummy_input_function);
fail_unless(n == &test_netif6); fail_unless(n == &test_netif6);
netif_set_default(&test_netif6); netif_set_default(&test_netif6);
} }

View File

@ -46,14 +46,16 @@ static struct netif *old_netif_default;
static void static void
tcp_setup(void) tcp_setup(void)
{ {
struct tcp_pcb dummy_pcb; /* we need this for tcp_next_iss() only */
old_netif_list = netif_list; old_netif_list = netif_list;
old_netif_default = netif_default; old_netif_default = netif_default;
netif_list = NULL; netif_list = NULL;
netif_default = NULL; netif_default = NULL;
/* reset iss to default (6510) */ /* reset iss to default (6510) */
tcp_ticks = 0; tcp_ticks = 0;
tcp_ticks = 0 - (tcp_next_iss(NULL) - 6510); tcp_ticks = 0 - (tcp_next_iss(&dummy_pcb) - 6510);
tcp_next_iss(NULL); tcp_next_iss(&dummy_pcb);
tcp_ticks = 0; tcp_ticks = 0;
test_tcp_timer = 0; test_tcp_timer = 0;
@ -669,6 +671,7 @@ START_TEST(test_tcp_rto_rexmit_wraparound)
struct test_tcp_txcounters txcounters; struct test_tcp_txcounters txcounters;
struct test_tcp_counters counters; struct test_tcp_counters counters;
struct tcp_pcb* pcb; struct tcp_pcb* pcb;
struct tcp_pcb dummy_pcb_for_iss; /* we need this for tcp_next_iss() only */
err_t err; err_t err;
size_t i; size_t i;
u16_t sent_total = 0; u16_t sent_total = 0;
@ -684,8 +687,8 @@ START_TEST(test_tcp_rto_rexmit_wraparound)
/* create and initialize the pcb */ /* create and initialize the pcb */
tcp_ticks = 0; tcp_ticks = 0;
tcp_ticks = 0 - tcp_next_iss(NULL); tcp_ticks = 0 - tcp_next_iss(&dummy_pcb_for_iss);
tcp_ticks = SEQNO1 - tcp_next_iss(NULL); tcp_ticks = SEQNO1 - tcp_next_iss(&dummy_pcb_for_iss);
pcb = test_tcp_new_counters_pcb(&counters); pcb = test_tcp_new_counters_pcb(&counters);
EXPECT_RET(pcb != NULL); EXPECT_RET(pcb != NULL);
tcp_set_state(pcb, ESTABLISHED, &test_local_ip, &test_remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT); tcp_set_state(pcb, ESTABLISHED, &test_local_ip, &test_remote_ip, TEST_LOCAL_PORT, TEST_REMOTE_PORT);