Skip to content

Commit 04b5f3c

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

File tree

2 files changed

+151
-150
lines changed

2 files changed

+151
-150
lines changed

components/net/utest/Kconfig

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