Skip to content

Commit 02ce417

Browse files
Don't use any default network stack in greentea tests
1 parent bee41f6 commit 02ce417

File tree

13 files changed

+204
-42
lines changed

13 files changed

+204
-42
lines changed

TESTS/configs/greentea_full.json5

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"mbed-trace.enable": true,
1919

2020
// Disable colored traces in tests, as the test runner does not like the terminal control chars
21-
"mbed-trace.default-config": "TRACE_ACTIVE_LEVEL_INFO | TRACE_CARRIAGE_RETURN"
21+
"mbed-trace.default-config": "TRACE_ACTIVE_LEVEL_INFO | TRACE_CARRIAGE_RETURN",
22+
23+
// Don't use any network stack as the default, so that we can manually select which one
24+
// is used in the tests.
25+
"nsapi.default-stack": null
2226
}
2327
}

connectivity/netsocket/tests/TESTS/CMakeLists.txt

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,12 @@ if(DEFAULT_IFC_IDX EQUAL -1)
55
set(TEST_SKIPPED "No default network interface on this target")
66
endif()
77

8-
# Set up variables for wi-fi SSID and password
9-
if("MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE=WIFI" IN_LIST MBED_CONFIG_DEFINITIONS)
10-
set(MBED_GREENTEA_WIFI_SECURE_SSID "" CACHE STRING "SSID of a secured wi-fi network with internet access, for greentea tests which need to connect to wifi")
11-
set(MBED_GREENTEA_WIFI_SECURE_PASSWORD "" CACHE STRING "Password to the network given by MBED_GREENTEA_WIFI_SECURE_SSID")
12-
set(MBED_GREENTEA_WIFI_SECURE_PROTOCOL "WPA2" CACHE STRING "WiFi security protocol, valid values are WEP, WPA, WPA2, WPA_WPA2, WPA3, WPA3_WPA2, NONE")
13-
14-
if("${MBED_GREENTEA_WIFI_SECURE_SSID}" STREQUAL "" OR "${MBED_GREENTEA_WIFI_SECURE_PASSWORD}" STREQUAL "")
15-
message(WARNING "MBED_GREENTEA_WIFI_SECURE_SSID and MBED_GREENTEA_WIFI_SECURE_PASSWORD must be set in order for wi-fi greentea tests to pass")
16-
else()
17-
add_compile_definitions(
18-
"MBED_GREENTEA_WIFI_SECURE_SSID=\"${MBED_GREENTEA_WIFI_SECURE_SSID}\""
19-
"MBED_GREENTEA_WIFI_SECURE_PASSWORD=\"${MBED_GREENTEA_WIFI_SECURE_PASSWORD}\""
20-
MBED_GREENTEA_WIFI_SECURE_PROTOCOL=${MBED_GREENTEA_WIFI_SECURE_PROTOCOL})
21-
endif()
8+
# TEMPORARY: netsocket tests will not compile on STM32H7 until new EMAC driver is merged because the old EMAC driver
9+
# pulls in a dependency on lwip
10+
if("TARGET_STM32H7" IN_LIST MBED_TARGET_DEFINITIONS)
11+
set(TEST_SKIPPED "Will not compile on STM32H7")
2212
endif()
2313

24-
# Pull in common util header
25-
include_directories(common)
26-
14+
add_subdirectory(common)
2715
add_subdirectory(netsocket)
2816
add_subdirectory(network)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) 2025 Jamie Smith.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(mbed-netsocket-tests-common-inc INTERFACE)
5+
target_include_directories(mbed-netsocket-tests-common-inc INTERFACE .)
6+
target_link_libraries(mbed-netsocket-tests-common-inc INTERFACE mbed-netsocket)
7+
8+
# Set up variables for wi-fi SSID and password
9+
if("MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE=WIFI" IN_LIST MBED_CONFIG_DEFINITIONS)
10+
set(MBED_GREENTEA_WIFI_SECURE_SSID "" CACHE STRING "SSID of a secured wi-fi network with internet access, for greentea tests which need to connect to wifi")
11+
set(MBED_GREENTEA_WIFI_SECURE_PASSWORD "" CACHE STRING "Password to the network given by MBED_GREENTEA_WIFI_SECURE_SSID")
12+
set(MBED_GREENTEA_WIFI_SECURE_PROTOCOL "WPA2" CACHE STRING "WiFi security protocol, valid values are WEP, WPA, WPA2, WPA_WPA2, WPA3, WPA3_WPA2, NONE")
13+
14+
if("${MBED_GREENTEA_WIFI_SECURE_SSID}" STREQUAL "" OR "${MBED_GREENTEA_WIFI_SECURE_PASSWORD}" STREQUAL "")
15+
message(WARNING "MBED_GREENTEA_WIFI_SECURE_SSID and MBED_GREENTEA_WIFI_SECURE_PASSWORD must be set in order for wi-fi greentea tests to pass")
16+
else()
17+
target_compile_definitions(mbed-netsocket-tests-common-inc INTERFACE
18+
"MBED_GREENTEA_WIFI_SECURE_SSID=\"${MBED_GREENTEA_WIFI_SECURE_SSID}\""
19+
"MBED_GREENTEA_WIFI_SECURE_PASSWORD=\"${MBED_GREENTEA_WIFI_SECURE_PASSWORD}\""
20+
MBED_GREENTEA_WIFI_SECURE_PROTOCOL=${MBED_GREENTEA_WIFI_SECURE_PROTOCOL})
21+
endif()
22+
endif()
23+
24+
# Tests can link one of the below two libraries to use lwipstack or nanostack
25+
add_library(mbed-netsocket-tests-use-lwipstack STATIC greentea_network_stack_lwipstack.cpp)
26+
target_link_libraries(mbed-netsocket-tests-use-lwipstack PUBLIC mbed-lwipstack)
27+
28+
add_library(mbed-netsocket-tests-use-nanostack STATIC greentea_network_stack_nanostack.cpp)
29+
target_link_libraries(mbed-netsocket-tests-use-nanostack PUBLIC mbed-nanostack)

connectivity/netsocket/tests/TESTS/common/greentea_get_network_interface.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,4 @@ inline NetworkInterface *get_network_interface()
7474
#endif
7575

7676
}
77-
7877
#endif //MBED_OS_GREENTEA_GET_NETWORK_INTERFACE_H
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2025 Jamie Smith, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
19+
#include "LWIPStack.h"
20+
#include "OnboardNetworkStack.h"
21+
22+
OnboardNetworkStack &OnboardNetworkStack::get_default_instance()
23+
{
24+
return LWIP::get_instance();
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2025 Jamie Smith, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "OnboardNetworkStack.h"
19+
#include "Nanostack.h"
20+
21+
OnboardNetworkStack &OnboardNetworkStack::get_default_instance()
22+
{
23+
return Nanostack::get_instance();
24+
}
25+

connectivity/netsocket/tests/TESTS/netsocket/dns/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,26 @@ endif()
2929

3030
mbed_greentea_add_test(
3131
TEST_NAME
32-
mbed-connectivity-netsocket-dns
32+
mbed-connectivity-netsocket-lwipstack-dns
3333
TEST_SOURCES
3434
${TEST_SOURCE_LIST}
3535
TEST_REQUIRED_LIBS
36-
mbed-netsocket
36+
mbed-netsocket-tests-common-inc
37+
mbed-netsocket-api
38+
mbed-netsocket-tests-use-lwipstack
3739
TEST_SKIPPED
3840
${TEST_SKIPPED}
3941
)
42+
43+
mbed_greentea_add_test(
44+
TEST_NAME
45+
mbed-connectivity-netsocket-nanostack-dns
46+
TEST_SOURCES
47+
${TEST_SOURCE_LIST}
48+
TEST_REQUIRED_LIBS
49+
mbed-netsocket-tests-common-inc
50+
mbed-netsocket-api
51+
mbed-netsocket-tests-use-nanostack
52+
TEST_SKIPPED
53+
${TEST_SKIPPED}
54+
)

connectivity/netsocket/tests/TESTS/netsocket/tcp/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,26 @@ endif()
3333

3434
mbed_greentea_add_test(
3535
TEST_NAME
36-
mbed-connectivity-netsocket-tcp
36+
mbed-connectivity-netsocket-lwipstack-tcp
3737
TEST_SOURCES
3838
${TEST_SOURCE_LIST}
3939
TEST_REQUIRED_LIBS
40-
mbed-netsocket
40+
mbed-netsocket-tests-common-inc
41+
mbed-netsocket-api
42+
mbed-netsocket-tests-use-lwipstack
43+
TEST_SKIPPED
44+
${TEST_SKIPPED}
45+
)
46+
47+
mbed_greentea_add_test(
48+
TEST_NAME
49+
mbed-connectivity-netsocket-nanostack-tcp
50+
TEST_SOURCES
51+
${TEST_SOURCE_LIST}
52+
TEST_REQUIRED_LIBS
53+
mbed-netsocket-tests-common-inc
54+
mbed-netsocket-api
55+
mbed-netsocket-tests-use-nanostack
4156
TEST_SKIPPED
4257
${TEST_SKIPPED}
4358
)

connectivity/netsocket/tests/TESTS/netsocket/tls/CMakeLists.txt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,30 @@ endif()
3333

3434
mbed_greentea_add_test(
3535
TEST_NAME
36-
mbed-connectivity-netsocket-tls
36+
mbed-connectivity-netsocket-lwipstack-tls
3737
TEST_SOURCES
3838
${TEST_SOURCE_LIST}
3939
TEST_REQUIRED_LIBS
40-
mbed-netsocket
40+
mbed-netsocket-tests-common-inc
4141
mbed-storage-blockdevice
42-
mbed-storage-littlefs
42+
mbed-storage-littlefs
43+
mbed-netsocket-api
44+
mbed-netsocket-tests-use-lwipstack
4345
TEST_SKIPPED
4446
${TEST_SKIPPED}
4547
)
48+
49+
mbed_greentea_add_test(
50+
TEST_NAME
51+
mbed-connectivity-netsocket-nanostack-tls
52+
TEST_SOURCES
53+
${TEST_SOURCE_LIST}
54+
TEST_REQUIRED_LIBS
55+
mbed-netsocket-tests-common-inc
56+
mbed-storage-blockdevice
57+
mbed-storage-littlefs
58+
mbed-netsocket-api
59+
mbed-netsocket-tests-use-nanostack
60+
TEST_SKIPPED
61+
${TEST_SKIPPED}
62+
)

connectivity/netsocket/tests/TESTS/netsocket/udp/CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,26 @@ endif()
2929

3030
mbed_greentea_add_test(
3131
TEST_NAME
32-
mbed-connectivity-netsocket-udp
32+
mbed-connectivity-netsocket-lwipstack-udp
3333
TEST_SOURCES
3434
${TEST_SOURCE_LIST}
3535
TEST_REQUIRED_LIBS
36-
mbed-netsocket
36+
mbed-netsocket-tests-common-inc
37+
mbed-netsocket-api
38+
mbed-netsocket-tests-use-lwipstack
39+
TEST_SKIPPED
40+
${TEST_SKIPPED}
41+
)
42+
43+
mbed_greentea_add_test(
44+
TEST_NAME
45+
mbed-connectivity-netsocket-nanostack-udp
46+
TEST_SOURCES
47+
${TEST_SOURCE_LIST}
48+
TEST_REQUIRED_LIBS
49+
mbed-netsocket-tests-common-inc
50+
mbed-netsocket-api
51+
mbed-netsocket-tests-use-nanostack
3752
TEST_SKIPPED
3853
${TEST_SKIPPED}
3954
)

0 commit comments

Comments
 (0)