Skip to content

Commit 4832f04

Browse files
committed
[utest][lwip]add lwip api testcase.
1 parent 1034e5b commit 4832f04

File tree

6 files changed

+1152
-0
lines changed

6 files changed

+1152
-0
lines changed

.github/utest/lwip/lwip.cfg

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# dependencies
2+
CONFIG_RT_CONSOLEBUF_SIZE=1024
3+
CONFIG_RT_NAME_MAX=24
4+
CONFIG_RT_USING_CI_ACTION=y
5+
6+
CONFIG_RT_LWIP_NETIF_LOOPBACK=y
7+
CONFIG_LWIP_NETIF_LOOPBACK=1
8+
CONFIG_RT_UTEST_TC_USING_LWIP=y
9+
CONFIG_RT_UTEST_LWIP_DNS_TEST=y
10+
CONFIG_RT_UTEST_LWIP_TCP_TEST=y
11+
CONFIG_RT_UTEST_LWIP_UDP_TEST=y
12+
CONFIG_RT_UTEST_LWIP_ICMP_TEST=y
13+
CONFIG_RT_UTEST_LWIP_SOCKET_OPT_TEST=y
14+
CONFIG_RT_UTEST_LWIP_ADDR_CONV_TEST=y
15+
CONFIG_RT_UTEST_LWIP_NETIF_TEST=y
16+
CONFIG_RT_UTEST_LWIP_TCP_PORT=1234
17+
CONFIG_RT_UTEST_LWIP_UDP_PORT=1235
18+
CONFIG_RT_UTEST_LWIP_TEST_URL="www.rt-thread.org"
19+
CONFIG_RT_UTEST_LWIP_TEST_ADDR="180.163.146.111"
20+
CONFIG_BSP_DRV_EMAC=y

.github/workflows/utest_auto_run.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ jobs:
5858
- platform: { UTEST: "A9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"" }
5959
config_file: "cpp11/cpp11.cfg"
6060

61+
- platform: { UTEST: "A9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"" }
62+
config_file: "lwip/lwip.cfg"
63+
6164
env:
6265
TEST_QEMU_ARCH: ${{ matrix.platform.QEMU_ARCH }}
6366
TEST_QEMU_MACHINE: ${{ matrix.platform.QEMU_MACHINE }}

Kconfig.utestcases

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ rsource "src/klibc/utest/Kconfig"
2323

2424
rsource "components/drivers/audio/utest/Kconfig"
2525
rsource "components/dfs/utest/Kconfig"
26+
rsource "components/net/utest/Kconfig"
2627

2728
endif
2829

components/net/utest/Kconfig

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
if RT_USING_LWIP
2+
menu "LwIP Network Unit Testcase"
3+
4+
config RT_UTEST_TC_USING_LWIP
5+
bool "lwIP API test"
6+
help
7+
Enable lwIP network stack unit tests including DNS resolution,
8+
TCP/UDP socket operations, and network interface tests
9+
10+
if RT_UTEST_TC_USING_LWIP
11+
12+
config RT_UTEST_LWIP_DNS_TEST
13+
bool "DNS resolution test"
14+
default y
15+
help
16+
Enable DNS resolution unit tests including gethostbyname()
17+
and gethostbyname_r() functions for hostname to IP resolution,
18+
as well as getaddrinfo() and freeaddrinfo() for address info
19+
retrieval and release. Tests verify successful resolution
20+
without hardcoded IP comparisons.
21+
22+
config RT_UTEST_LWIP_TCP_TEST
23+
bool "TCP socket test"
24+
default y
25+
help
26+
Enable TCP socket unit tests including client-server communication
27+
with echo functionality, socket creation, binding, listening,
28+
accepting connections, data transmission with varying buffer sizes,
29+
socket options (TCP_NODELAY, SO_REUSEADDR, SO_REUSEPORT),
30+
and connection management (shutdown, close).
31+
32+
config RT_UTEST_LWIP_UDP_TEST
33+
bool "UDP socket test"
34+
default y
35+
help
36+
Enable UDP socket unit tests including datagram transmission
37+
and reception, client-server echo communication, socket binding
38+
to any port, select() operations with timeout, recvfrom/sendto
39+
functions, and timeout handling for receive operations.
40+
41+
config RT_UTEST_LWIP_ICMP_TEST
42+
bool "ICMP ping test"
43+
default y
44+
help
45+
Enable ICMP ping unit tests using raw sockets to send
46+
ICMP echo requests and receive echo replies. Tests verify
47+
basic ICMP functionality with loopback address (127.0.0.1).
48+
49+
config RT_UTEST_LWIP_SOCKET_OPT_TEST
50+
bool "Socket options test"
51+
default y
52+
help
53+
Enable socket options unit tests including setsockopt()
54+
and getsockopt() functions. Tests verify setting and
55+
retrieving socket options such as SO_REUSEADDR.
56+
57+
config RT_UTEST_LWIP_ADDR_CONV_TEST
58+
bool "Address conversion test"
59+
default y
60+
help
61+
Enable address conversion unit tests including inet_addr()
62+
for converting string IP addresses to binary format and
63+
inet_ntoa() for converting binary addresses back to strings.
64+
Tests verify proper conversion functionality.
65+
66+
config RT_UTEST_LWIP_NETIF_TEST
67+
bool "Network interface management test"
68+
default y
69+
help
70+
Enable network interface management unit tests including
71+
netif_set_up(), netif_set_down(), and netif_set_default()
72+
functions. Tests verify interface state changes and
73+
default interface configuration.
74+
75+
config RT_UTEST_LWIP_TCP_PORT
76+
int "TCP test port"
77+
default 1234
78+
range 1024 65535
79+
help
80+
Configure the TCP port number for unit test communication.
81+
Must be in the range 1024-65535 to avoid system ports
82+
83+
config RT_UTEST_LWIP_UDP_PORT
84+
int "UDP test port"
85+
default 1235
86+
range 1024 65535
87+
help
88+
Configure the UDP port number for unit test communication.
89+
Must be in the range 1024-65535 to avoid system ports
90+
91+
config RT_UTEST_LWIP_TEST_URL
92+
string "Test domain name"
93+
default "www.rt-thread.org"
94+
help
95+
Configure the domain name for DNS resolution tests.
96+
This domain will be resolved to verify DNS functionality
97+
98+
config RT_UTEST_LWIP_TEST_ADDR
99+
string "Expected IP address"
100+
default "180.163.146.111"
101+
help
102+
Configure the expected IP address for DNS resolution verification.
103+
This should match the actual IP of the test domain
104+
105+
endif
106+
endmenu
107+
endif

components/net/utest/SConscript

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Import('rtconfig')
2+
from building import *
3+
4+
cwd = GetCurrentDir()
5+
src = []
6+
CPPPATH = [cwd]
7+
8+
if GetDepend('RT_UTEST_TC_USING_LWIP'):
9+
# Add lwIP test source if enabled
10+
src += ['tc_lwip.c']
11+
12+
# Define the test group with proper dependencies
13+
group = DefineGroup('utestcases', src, depend = ['RT_USING_UTESTCASES', 'RT_USING_LWIP'], CPPPATH = CPPPATH)
14+
15+
Return('group')

0 commit comments

Comments
 (0)