Skip to content

Commit 926d403

Browse files
committed
improve[net][utestcase]: standardize script construction
1 parent 3e14369 commit 926d403

File tree

2 files changed

+153
-150
lines changed

2 files changed

+153
-150
lines changed

components/net/utest/Kconfig

Lines changed: 144 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,144 @@
1-
menu "Network Unit Testcase"
2-
3-
menuconfig RT_UTEST_TC_USING_SAL
4-
select RT_USING_SAL
5-
bool "SAL Unit Testcase"
6-
default n
7-
8-
menuconfig RT_UTEST_TC_USING_NETDEV
9-
select RT_USING_NETDEV
10-
bool "netdev api test"
11-
help
12-
Enable netdev network device framework unit tests.
13-
14-
Test coverage includes:
15-
* Network connectivity (ping operations)
16-
* DHCP functionality (enable/disable/restore)
17-
* DNS configuration and hostname resolution
18-
* Interface configuration (IP/gateway/netmask)
19-
* IP address conversion functions
20-
* Device retrieval and management
21-
* Status control and callback mechanisms
22-
23-
if RT_UTEST_TC_USING_NETDEV
24-
25-
config RT_UTEST_DEFAULT_NETDEV_NAME
26-
string "Default netdev name"
27-
default "e0"
28-
help
29-
Network interface name for tests. Common values:
30-
"e0" (Ethernet), "w0" (Wireless).
31-
Ensure the device exists in your environment.
32-
endif
33-
34-
menuconfig RT_UTEST_TC_USING_LWIP
35-
select RT_USING_LWIP
36-
select RT_LWIP_NETIF_LOOPBACK
37-
bool "lwIP Unit Testcase"
38-
default n
39-
help
40-
Enable lwIP network stack unit tests including DNS resolution,
41-
TCP/UDP socket operations, and network interface tests
42-
43-
if RT_UTEST_TC_USING_LWIP
44-
45-
config RT_UTEST_LWIP_DNS_TEST
46-
bool "DNS resolution test"
47-
default y
48-
help
49-
Enable DNS resolution unit tests including gethostbyname()
50-
and gethostbyname_r() functions for hostname to IP resolution,
51-
as well as getaddrinfo() and freeaddrinfo() for address info
52-
retrieval and release. Tests verify successful resolution
53-
without hardcoded IP comparisons.
54-
55-
config RT_UTEST_LWIP_TCP_TEST
56-
bool "TCP socket test"
57-
default y
58-
help
59-
Enable TCP socket unit tests including client-server communication
60-
with echo functionality, socket creation, binding, listening,
61-
accepting connections, data transmission with varying buffer sizes,
62-
socket options (TCP_NODELAY, SO_REUSEADDR, SO_REUSEPORT),
63-
and connection management (shutdown, close).
64-
65-
config RT_UTEST_LWIP_UDP_TEST
66-
bool "UDP socket test"
67-
default y
68-
help
69-
Enable UDP socket unit tests including datagram transmission
70-
and reception, client-server echo communication, socket binding
71-
to any port, select() operations with timeout, recvfrom/sendto
72-
functions, and timeout handling for receive operations.
73-
74-
config RT_UTEST_LWIP_ICMP_TEST
75-
bool "ICMP ping test"
76-
default y
77-
help
78-
Enable ICMP ping unit tests using raw sockets to send
79-
ICMP echo requests and receive echo replies. Tests verify
80-
basic ICMP functionality with loopback address (127.0.0.1).
81-
82-
config RT_UTEST_LWIP_SOCKET_OPT_TEST
83-
bool "Socket options test"
84-
default y
85-
help
86-
Enable socket options unit tests including setsockopt()
87-
and getsockopt() functions. Tests verify setting and
88-
retrieving socket options such as SO_REUSEADDR.
89-
90-
config RT_UTEST_LWIP_ADDR_CONV_TEST
91-
bool "Address conversion test"
92-
default y
93-
help
94-
Enable address conversion unit tests including inet_addr()
95-
for converting string IP addresses to binary format and
96-
inet_ntoa() for converting binary addresses back to strings.
97-
Tests verify proper conversion functionality.
98-
99-
config RT_UTEST_LWIP_NETIF_TEST
100-
bool "Network interface management test"
101-
default y
102-
help
103-
Enable network interface management unit tests including
104-
netif_set_up(), netif_set_down(), and netif_set_default()
105-
functions. Tests verify interface state changes and
106-
default interface configuration.
107-
108-
config RT_UTEST_LWIP_TCP_PORT
109-
int "TCP test port"
110-
default 1234
111-
range 1024 65535
112-
help
113-
Configure the TCP port number for unit test communication.
114-
Must be in the range 1024-65535 to avoid system ports
115-
116-
config RT_UTEST_LWIP_UDP_PORT
117-
int "UDP test port"
118-
default 1235
119-
range 1024 65535
120-
help
121-
Configure the UDP port number for unit test communication.
122-
Must be in the range 1024-65535 to avoid system ports
123-
124-
config RT_UTEST_LWIP_TEST_URL
125-
string "Test domain name"
126-
default "www.rt-thread.org"
127-
help
128-
Configure the domain name for DNS resolution tests.
129-
This domain will be resolved to verify DNS functionality
130-
131-
config RT_UTEST_LWIP_TEST_ADDR
132-
string "Expected IP address"
133-
default "180.163.146.111"
134-
help
135-
Configure the expected IP address for DNS resolution verification.
136-
This should match the actual IP of the test domain
137-
138-
endif
139-
endmenu
1+
menuconfig RT_UTEST_TC_USING_NETWORK
2+
depends on RT_USING_UTEST
3+
bool "Network Unit Testcase"
4+
default n
5+
6+
if RT_UTEST_TC_USING_NETWORK
7+
8+
menuconfig RT_UTEST_TC_USING_SAL
9+
select RT_USING_SAL
10+
bool "SAL Unit Testcase"
11+
default n
12+
13+
menuconfig RT_UTEST_TC_USING_NETDEV
14+
select RT_USING_NETDEV
15+
bool "netdev api test"
16+
help
17+
Enable netdev network device framework unit tests.
18+
19+
Test coverage includes:
20+
* Network connectivity (ping operations)
21+
* DHCP functionality (enable/disable/restore)
22+
* DNS configuration and hostname resolution
23+
* Interface configuration (IP/gateway/netmask)
24+
* IP address conversion functions
25+
* Device retrieval and management
26+
* Status control and callback mechanisms
27+
28+
if RT_UTEST_TC_USING_NETDEV
29+
30+
config RT_UTEST_DEFAULT_NETDEV_NAME
31+
string "Default netdev name"
32+
default "e0"
33+
help
34+
Network interface name for tests. Common values:
35+
"e0" (Ethernet), "w0" (Wireless).
36+
Ensure the device exists in your environment.
37+
endif
38+
39+
menuconfig RT_UTEST_TC_USING_LWIP
40+
select RT_USING_LWIP
41+
select RT_LWIP_NETIF_LOOPBACK
42+
bool "lwIP Unit Testcase"
43+
default n
44+
help
45+
Enable lwIP network stack unit tests including DNS resolution,
46+
TCP/UDP socket operations, and network interface tests
47+
48+
if RT_UTEST_TC_USING_LWIP
49+
50+
config RT_UTEST_LWIP_DNS_TEST
51+
bool "DNS resolution test"
52+
default y
53+
help
54+
Enable DNS resolution unit tests including gethostbyname()
55+
and gethostbyname_r() functions for hostname to IP resolution,
56+
as well as getaddrinfo() and freeaddrinfo() for address info
57+
retrieval and release. Tests verify successful resolution
58+
without hardcoded IP comparisons.
59+
60+
config RT_UTEST_LWIP_TCP_TEST
61+
bool "TCP socket test"
62+
default y
63+
help
64+
Enable TCP socket unit tests including client-server communication
65+
with echo functionality, socket creation, binding, listening,
66+
accepting connections, data transmission with varying buffer sizes,
67+
socket options (TCP_NODELAY, SO_REUSEADDR, SO_REUSEPORT),
68+
and connection management (shutdown, close).
69+
70+
config RT_UTEST_LWIP_UDP_TEST
71+
bool "UDP socket test"
72+
default y
73+
help
74+
Enable UDP socket unit tests including datagram transmission
75+
and reception, client-server echo communication, socket binding
76+
to any port, select() operations with timeout, recvfrom/sendto
77+
functions, and timeout handling for receive operations.
78+
79+
config RT_UTEST_LWIP_ICMP_TEST
80+
bool "ICMP ping test"
81+
default y
82+
help
83+
Enable ICMP ping unit tests using raw sockets to send
84+
ICMP echo requests and receive echo replies. Tests verify
85+
basic ICMP functionality with loopback address (127.0.0.1).
86+
87+
config RT_UTEST_LWIP_SOCKET_OPT_TEST
88+
bool "Socket options test"
89+
default y
90+
help
91+
Enable socket options unit tests including setsockopt()
92+
and getsockopt() functions. Tests verify setting and
93+
retrieving socket options such as SO_REUSEADDR.
94+
95+
config RT_UTEST_LWIP_ADDR_CONV_TEST
96+
bool "Address conversion test"
97+
default y
98+
help
99+
Enable address conversion unit tests including inet_addr()
100+
for converting string IP addresses to binary format and
101+
inet_ntoa() for converting binary addresses back to strings.
102+
Tests verify proper conversion functionality.
103+
104+
config RT_UTEST_LWIP_NETIF_TEST
105+
bool "Network interface management test"
106+
default y
107+
help
108+
Enable network interface management unit tests including
109+
netif_set_up(), netif_set_down(), and netif_set_default()
110+
functions. Tests verify interface state changes and
111+
default interface configuration.
112+
113+
config RT_UTEST_LWIP_TCP_PORT
114+
int "TCP test port"
115+
default 1234
116+
range 1024 65535
117+
help
118+
Configure the TCP port number for unit test communication.
119+
Must be in the range 1024-65535 to avoid system ports
120+
121+
config RT_UTEST_LWIP_UDP_PORT
122+
int "UDP test port"
123+
default 1235
124+
range 1024 65535
125+
help
126+
Configure the UDP port number for unit test communication.
127+
Must be in the range 1024-65535 to avoid system ports
128+
129+
config RT_UTEST_LWIP_TEST_URL
130+
string "Test domain name"
131+
default "www.rt-thread.org"
132+
help
133+
Configure the domain name for DNS resolution tests.
134+
This domain will be resolved to verify DNS functionality
135+
136+
config RT_UTEST_LWIP_TEST_ADDR
137+
string "Expected IP address"
138+
default "180.163.146.111"
139+
help
140+
Configure the expected IP address for DNS resolution verification.
141+
This should match the actual IP of the test domain
142+
143+
endif
144+
endif

components/net/utest/SConscript

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@ cwd = GetCurrentDir()
55
src = []
66
CPPPATH = [cwd]
77

8-
if GetDepend('RT_UTEST_USING_ALL_CASES'):
8+
if GetDepend('RT_UTEST_TC_USING_LWIP'):
9+
# Add lwIP test source if enabled
10+
src += ['tc_lwip.c']
911

10-
if GetDepend('RT_UTEST_TC_USING_LWIP'):
11-
# Add lwIP test source if enabled
12-
src += ['tc_lwip.c']
12+
if GetDepend('RT_UTEST_TC_USING_NETDEV'):
13+
# Add netdev test source if enabled
14+
src += ['tc_netdev.c']
1315

14-
if GetDepend('RT_UTEST_TC_USING_NETDEV'):
15-
# Add netdev test source if enabled
16-
src += ['tc_netdev.c']
17-
18-
if GetDepend('RT_UTEST_TC_USING_SAL'):
19-
src += ['tc_sal_socket.c']
16+
if GetDepend('RT_UTEST_TC_USING_SAL'):
17+
src += ['tc_sal_socket.c']
2018

2119
# Define the test group with proper dependencies
22-
group = DefineGroup('utestcases', src, depend = ['RT_USING_UTESTCASES'], CPPPATH = CPPPATH)
20+
group = DefineGroup('utestcases', src, depend = ['RT_UTEST_TC_USING_NETWORK'], CPPPATH = CPPPATH)
2321

2422
Return('group')

0 commit comments

Comments
 (0)