Skip to content

Commit 6c10a75

Browse files
committed
[utest]add lwip api testcase.
1 parent afb3f22 commit 6c10a75

File tree

6 files changed

+1054
-0
lines changed

6 files changed

+1054
-0
lines changed

.github/utest/lwip/lwip.cfg

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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_MULTICAST_TEST=y
17+
CONFIG_RT_UTEST_LWIP_TCP_PORT=1234
18+
CONFIG_RT_UTEST_LWIP_UDP_PORT=1235
19+
CONFIG_RT_UTEST_LWIP_TEST_URL="www.rt-thread.org"
20+
CONFIG_RT_UTEST_LWIP_TEST_ADDR="180.163.146.111"
21+
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: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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 getaddrinfo() API tests
18+
19+
config RT_UTEST_LWIP_TCP_TEST
20+
bool "TCP socket test"
21+
default y
22+
help
23+
Enable TCP socket unit tests including client-server communication,
24+
socket options, and connection management tests
25+
26+
config RT_UTEST_LWIP_UDP_TEST
27+
bool "UDP socket test"
28+
default y
29+
help
30+
Enable UDP socket unit tests including datagram transmission,
31+
select() operations, and timeout handling tests
32+
33+
config RT_UTEST_LWIP_ICMP_TEST
34+
bool "ICMP ping test"
35+
default y
36+
help
37+
Enable ICMP ping unit tests
38+
39+
config RT_UTEST_LWIP_SOCKET_OPT_TEST
40+
bool "Socket options test"
41+
default y
42+
help
43+
Enable socket options unit tests
44+
45+
config RT_UTEST_LWIP_ADDR_CONV_TEST
46+
bool "Address conversion test"
47+
default y
48+
help
49+
Enable address conversion unit tests
50+
51+
config RT_UTEST_LWIP_NETIF_TEST
52+
bool "Network interface management test"
53+
default y
54+
help
55+
Enable network interface management unit tests
56+
57+
config RT_UTEST_LWIP_TCP_PORT
58+
int "TCP test port"
59+
default 1234
60+
range 1024 65535
61+
help
62+
Configure the TCP port number for unit test communication.
63+
Must be in the range 1024-65535 to avoid system ports
64+
65+
config RT_UTEST_LWIP_UDP_PORT
66+
int "UDP test port"
67+
default 1235
68+
range 1024 65535
69+
help
70+
Configure the UDP port number for unit test communication.
71+
Must be in the range 1024-65535 to avoid system ports
72+
73+
config RT_UTEST_LWIP_TEST_URL
74+
string "Test domain name"
75+
default "www.rt-thread.org"
76+
help
77+
Configure the domain name for DNS resolution tests.
78+
This domain will be resolved to verify DNS functionality
79+
80+
config RT_UTEST_LWIP_TEST_ADDR
81+
string "Expected IP address"
82+
default "180.163.146.111"
83+
help
84+
Configure the expected IP address for DNS resolution verification.
85+
This should match the actual IP of the test domain
86+
87+
endif
88+
endmenu
89+
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 += ['lwip_tc.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)