Skip to content

Commit

Permalink
ci: Add unit test suite to validate tcp state transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
ydesp authored and goldsimon committed May 10, 2023
1 parent a6874a4 commit f50c87d
Show file tree
Hide file tree
Showing 6 changed files with 670 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/unit/Filelists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(LWIP_TESTFILES
${LWIP_TESTDIR}/mqtt/test_mqtt.c
${LWIP_TESTDIR}/tcp/tcp_helper.c
${LWIP_TESTDIR}/tcp/test_tcp_oos.c
${LWIP_TESTDIR}/tcp/test_tcp_state.c
${LWIP_TESTDIR}/tcp/test_tcp.c
${LWIP_TESTDIR}/udp/test_udp.c
${LWIP_TESTDIR}/ppp/test_pppos.c
Expand Down
1 change: 1 addition & 0 deletions test/unit/Filelists.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ TESTFILES=$(TESTDIR)/lwip_unittests.c \
$(TESTDIR)/mqtt/test_mqtt.c \
$(TESTDIR)/tcp/tcp_helper.c \
$(TESTDIR)/tcp/test_tcp_oos.c \
$(TESTDIR)/tcp/test_tcp_state.c \
$(TESTDIR)/tcp/test_tcp.c \
$(TESTDIR)/udp/test_udp.c \
$(TESTDIR)/ppp/test_pppos.c
Expand Down
2 changes: 2 additions & 0 deletions test/unit/lwip_unittests.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "udp/test_udp.h"
#include "tcp/test_tcp.h"
#include "tcp/test_tcp_oos.h"
#include "tcp/test_tcp_state.h"
#include "core/test_def.h"
#include "core/test_dns.h"
#include "core/test_mem.h"
Expand Down Expand Up @@ -79,6 +80,7 @@ int main(void)
udp_suite,
tcp_suite,
tcp_oos_suite,
tcp_state_suite,
def_suite,
dns_suite,
mem_suite,
Expand Down
7 changes: 6 additions & 1 deletion test/unit/tcp/tcp_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ tcp_remove(struct tcp_pcb* pcb_list)
while(pcb != NULL) {
pcb2 = pcb;
pcb = pcb->next;
tcp_abort(pcb2);
if (pcb2->state == LISTEN) {
tcp_close(pcb2);
} else {
tcp_abort(pcb2);
}
}
}

Expand Down Expand Up @@ -260,6 +264,7 @@ void test_tcp_input(struct pbuf *p, struct netif *inp)
ip_addr_copy_from_ip4(*ip_current_src_addr(), iphdr->src);
ip_current_netif() = inp;
ip_data.current_ip4_header = iphdr;
ip_data.current_input_netif = inp;

/* since adding IPv6, p->payload must point to tcp header, not ip header */
pbuf_header(p, -(s16_t)sizeof(struct ip_hdr));
Expand Down
Loading

0 comments on commit f50c87d

Please sign in to comment.