mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
TCP unit tests: fix that ip.rterr stats are increased (some unit tests had no netif set)
This commit is contained in:
parent
679d3fd5b3
commit
5db6bb02d6
@ -260,18 +260,21 @@ static err_t test_tcp_netif_output(struct netif *netif, struct pbuf *p,
|
|||||||
{
|
{
|
||||||
struct test_tcp_txcounters *txcounters = (struct test_tcp_txcounters*)netif->state;
|
struct test_tcp_txcounters *txcounters = (struct test_tcp_txcounters*)netif->state;
|
||||||
LWIP_UNUSED_ARG(ipaddr);
|
LWIP_UNUSED_ARG(ipaddr);
|
||||||
txcounters->num_tx_calls++;
|
if (txcounters != NULL)
|
||||||
txcounters->num_tx_bytes += p->tot_len;
|
{
|
||||||
if (txcounters->copy_tx_packets) {
|
txcounters->num_tx_calls++;
|
||||||
struct pbuf *p_copy = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
|
txcounters->num_tx_bytes += p->tot_len;
|
||||||
err_t err;
|
if (txcounters->copy_tx_packets) {
|
||||||
EXPECT(p_copy != NULL);
|
struct pbuf *p_copy = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
|
||||||
err = pbuf_copy(p_copy, p);
|
err_t err;
|
||||||
EXPECT(err == ERR_OK);
|
EXPECT(p_copy != NULL);
|
||||||
if (txcounters->tx_packets == NULL) {
|
err = pbuf_copy(p_copy, p);
|
||||||
txcounters->tx_packets = p_copy;
|
EXPECT(err == ERR_OK);
|
||||||
} else {
|
if (txcounters->tx_packets == NULL) {
|
||||||
pbuf_cat(txcounters->tx_packets, p_copy);
|
txcounters->tx_packets = p_copy;
|
||||||
|
} else {
|
||||||
|
pbuf_cat(txcounters->tx_packets, p_copy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -282,9 +285,11 @@ void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcoun
|
|||||||
{
|
{
|
||||||
struct netif *n;
|
struct netif *n;
|
||||||
memset(netif, 0, sizeof(struct netif));
|
memset(netif, 0, sizeof(struct netif));
|
||||||
memset(txcounters, 0, sizeof(struct test_tcp_txcounters));
|
if (txcounters != NULL) {
|
||||||
|
memset(txcounters, 0, sizeof(struct test_tcp_txcounters));
|
||||||
|
netif->state = txcounters;
|
||||||
|
}
|
||||||
netif->output = test_tcp_netif_output;
|
netif->output = test_tcp_netif_output;
|
||||||
netif->state = txcounters;
|
|
||||||
netif->flags |= NETIF_FLAG_UP;
|
netif->flags |= NETIF_FLAG_UP;
|
||||||
ip_addr_copy(netif->netmask, *netmask);
|
ip_addr_copy(netif->netmask, *netmask);
|
||||||
ip_addr_copy(netif->ip_addr, *ip_addr);
|
ip_addr_copy(netif->ip_addr, *ip_addr);
|
||||||
|
@ -45,8 +45,9 @@ tcp_setup(void)
|
|||||||
static void
|
static void
|
||||||
tcp_teardown(void)
|
tcp_teardown(void)
|
||||||
{
|
{
|
||||||
netif_list = NULL;
|
|
||||||
tcp_remove_all();
|
tcp_remove_all();
|
||||||
|
netif_list = NULL;
|
||||||
|
netif_default = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,16 +78,19 @@ START_TEST(test_tcp_recv_inseq)
|
|||||||
struct tcp_pcb* pcb;
|
struct tcp_pcb* pcb;
|
||||||
struct pbuf* p;
|
struct pbuf* p;
|
||||||
char data[] = {1, 2, 3, 4};
|
char data[] = {1, 2, 3, 4};
|
||||||
ip_addr_t remote_ip, local_ip;
|
ip_addr_t remote_ip, local_ip, netmask;
|
||||||
u16_t data_len;
|
u16_t data_len;
|
||||||
u16_t remote_port = 0x100, local_port = 0x101;
|
u16_t remote_port = 0x100, local_port = 0x101;
|
||||||
struct netif netif;
|
struct netif netif;
|
||||||
|
struct test_tcp_txcounters txcounters;
|
||||||
LWIP_UNUSED_ARG(_i);
|
LWIP_UNUSED_ARG(_i);
|
||||||
|
|
||||||
/* initialize local vars */
|
/* initialize local vars */
|
||||||
memset(&netif, 0, sizeof(netif));
|
memset(&netif, 0, sizeof(netif));
|
||||||
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
||||||
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
||||||
|
IP4_ADDR(&netmask, 255, 255, 255, 0);
|
||||||
|
test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask);
|
||||||
data_len = sizeof(data);
|
data_len = sizeof(data);
|
||||||
/* initialize counter struct */
|
/* initialize counter struct */
|
||||||
memset(&counters, 0, sizeof(counters));
|
memset(&counters, 0, sizeof(counters));
|
||||||
|
@ -127,6 +127,8 @@ static void
|
|||||||
tcp_oos_teardown(void)
|
tcp_oos_teardown(void)
|
||||||
{
|
{
|
||||||
tcp_remove_all();
|
tcp_remove_all();
|
||||||
|
netif_list = NULL;
|
||||||
|
netif_default = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -146,7 +148,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
|
|||||||
5, 6, 7, 8,
|
5, 6, 7, 8,
|
||||||
9, 10, 11, 12,
|
9, 10, 11, 12,
|
||||||
13, 14, 15, 16};
|
13, 14, 15, 16};
|
||||||
ip_addr_t remote_ip, local_ip;
|
ip_addr_t remote_ip, local_ip, netmask;
|
||||||
u16_t data_len;
|
u16_t data_len;
|
||||||
u16_t remote_port = 0x100, local_port = 0x101;
|
u16_t remote_port = 0x100, local_port = 0x101;
|
||||||
struct netif netif;
|
struct netif netif;
|
||||||
@ -156,6 +158,8 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
|
|||||||
memset(&netif, 0, sizeof(netif));
|
memset(&netif, 0, sizeof(netif));
|
||||||
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
||||||
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
||||||
|
IP4_ADDR(&netmask, 255, 255, 255, 0);
|
||||||
|
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
|
||||||
data_len = sizeof(data);
|
data_len = sizeof(data);
|
||||||
/* initialize counter struct */
|
/* initialize counter struct */
|
||||||
memset(&counters, 0, sizeof(counters));
|
memset(&counters, 0, sizeof(counters));
|
||||||
@ -286,7 +290,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||||||
5, 6, 7, 8,
|
5, 6, 7, 8,
|
||||||
9, 10, 11, 12,
|
9, 10, 11, 12,
|
||||||
13, 14, 15, 16};
|
13, 14, 15, 16};
|
||||||
ip_addr_t remote_ip, local_ip;
|
ip_addr_t remote_ip, local_ip, netmask;
|
||||||
u16_t data_len;
|
u16_t data_len;
|
||||||
u16_t remote_port = 0x100, local_port = 0x101;
|
u16_t remote_port = 0x100, local_port = 0x101;
|
||||||
struct netif netif;
|
struct netif netif;
|
||||||
@ -296,6 +300,8 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
|
|||||||
memset(&netif, 0, sizeof(netif));
|
memset(&netif, 0, sizeof(netif));
|
||||||
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
||||||
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
||||||
|
IP4_ADDR(&netmask, 255, 255, 255, 0);
|
||||||
|
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
|
||||||
data_len = sizeof(data);
|
data_len = sizeof(data);
|
||||||
/* initialize counter struct */
|
/* initialize counter struct */
|
||||||
memset(&counters, 0, sizeof(counters));
|
memset(&counters, 0, sizeof(counters));
|
||||||
@ -457,7 +463,7 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
|
|||||||
struct test_tcp_counters counters;
|
struct test_tcp_counters counters;
|
||||||
struct tcp_pcb* pcb;
|
struct tcp_pcb* pcb;
|
||||||
struct pbuf *pinseq, *p_ovr;
|
struct pbuf *pinseq, *p_ovr;
|
||||||
ip_addr_t remote_ip, local_ip;
|
ip_addr_t remote_ip, local_ip, netmask;
|
||||||
u16_t remote_port = 0x100, local_port = 0x101;
|
u16_t remote_port = 0x100, local_port = 0x101;
|
||||||
struct netif netif;
|
struct netif netif;
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
@ -471,6 +477,8 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
|
|||||||
memset(&netif, 0, sizeof(netif));
|
memset(&netif, 0, sizeof(netif));
|
||||||
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
||||||
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
||||||
|
IP4_ADDR(&netmask, 255, 255, 255, 0);
|
||||||
|
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
|
||||||
/* initialize counter struct */
|
/* initialize counter struct */
|
||||||
memset(&counters, 0, sizeof(counters));
|
memset(&counters, 0, sizeof(counters));
|
||||||
counters.expected_data_len = TCP_WND;
|
counters.expected_data_len = TCP_WND;
|
||||||
@ -547,7 +555,7 @@ START_TEST(test_tcp_recv_ooseq_max_bytes)
|
|||||||
struct test_tcp_counters counters;
|
struct test_tcp_counters counters;
|
||||||
struct tcp_pcb* pcb;
|
struct tcp_pcb* pcb;
|
||||||
struct pbuf *p_ovr;
|
struct pbuf *p_ovr;
|
||||||
ip_addr_t remote_ip, local_ip;
|
ip_addr_t remote_ip, local_ip, netmask;
|
||||||
u16_t remote_port = 0x100, local_port = 0x101;
|
u16_t remote_port = 0x100, local_port = 0x101;
|
||||||
struct netif netif;
|
struct netif netif;
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
@ -561,6 +569,8 @@ START_TEST(test_tcp_recv_ooseq_max_bytes)
|
|||||||
memset(&netif, 0, sizeof(netif));
|
memset(&netif, 0, sizeof(netif));
|
||||||
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
||||||
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
||||||
|
IP4_ADDR(&netmask, 255, 255, 255, 0);
|
||||||
|
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
|
||||||
/* initialize counter struct */
|
/* initialize counter struct */
|
||||||
memset(&counters, 0, sizeof(counters));
|
memset(&counters, 0, sizeof(counters));
|
||||||
counters.expected_data_len = TCP_WND;
|
counters.expected_data_len = TCP_WND;
|
||||||
@ -626,7 +636,7 @@ START_TEST(test_tcp_recv_ooseq_max_pbufs)
|
|||||||
struct test_tcp_counters counters;
|
struct test_tcp_counters counters;
|
||||||
struct tcp_pcb* pcb;
|
struct tcp_pcb* pcb;
|
||||||
struct pbuf *p_ovr;
|
struct pbuf *p_ovr;
|
||||||
ip_addr_t remote_ip, local_ip;
|
ip_addr_t remote_ip, local_ip, netmask;
|
||||||
u16_t remote_port = 0x100, local_port = 0x101;
|
u16_t remote_port = 0x100, local_port = 0x101;
|
||||||
struct netif netif;
|
struct netif netif;
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
@ -640,6 +650,8 @@ START_TEST(test_tcp_recv_ooseq_max_pbufs)
|
|||||||
memset(&netif, 0, sizeof(netif));
|
memset(&netif, 0, sizeof(netif));
|
||||||
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
||||||
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
||||||
|
IP4_ADDR(&netmask, 255, 255, 255, 0);
|
||||||
|
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
|
||||||
/* initialize counter struct */
|
/* initialize counter struct */
|
||||||
memset(&counters, 0, sizeof(counters));
|
memset(&counters, 0, sizeof(counters));
|
||||||
counters.expected_data_len = TCP_WND;
|
counters.expected_data_len = TCP_WND;
|
||||||
@ -727,7 +739,7 @@ static void test_tcp_recv_ooseq_double_FINs(int delay_packet)
|
|||||||
struct test_tcp_counters counters;
|
struct test_tcp_counters counters;
|
||||||
struct tcp_pcb* pcb;
|
struct tcp_pcb* pcb;
|
||||||
struct pbuf *p_normal_fin, *p_data_after_fin, *p, *p_2nd_fin_ooseq;
|
struct pbuf *p_normal_fin, *p_data_after_fin, *p, *p_2nd_fin_ooseq;
|
||||||
ip_addr_t remote_ip, local_ip;
|
ip_addr_t remote_ip, local_ip, netmask;
|
||||||
u16_t remote_port = 0x100, local_port = 0x101;
|
u16_t remote_port = 0x100, local_port = 0x101;
|
||||||
struct netif netif;
|
struct netif netif;
|
||||||
u32_t exp_rx_calls = 0, exp_rx_bytes = 0, exp_close_calls = 0, exp_oos_pbufs = 0, exp_oos_tcplen = 0;
|
u32_t exp_rx_calls = 0, exp_rx_bytes = 0, exp_close_calls = 0, exp_oos_pbufs = 0, exp_oos_tcplen = 0;
|
||||||
@ -742,6 +754,8 @@ static void test_tcp_recv_ooseq_double_FINs(int delay_packet)
|
|||||||
memset(&netif, 0, sizeof(netif));
|
memset(&netif, 0, sizeof(netif));
|
||||||
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
IP4_ADDR(&local_ip, 192, 168, 1, 1);
|
||||||
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
|
||||||
|
IP4_ADDR(&netmask, 255, 255, 255, 0);
|
||||||
|
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
|
||||||
/* initialize counter struct */
|
/* initialize counter struct */
|
||||||
memset(&counters, 0, sizeof(counters));
|
memset(&counters, 0, sizeof(counters));
|
||||||
counters.expected_data_len = TCP_WND;
|
counters.expected_data_len = TCP_WND;
|
||||||
|
Loading…
Reference in New Issue
Block a user