Skip to content

Commit 8c0bc78

Browse files
committed
Allow tools to use networkinterface configs in tests
1 parent 8f9242f commit 8c0bc78

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

targets/targets.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,9 @@
608608
"detect_code": ["0240"],
609609
"device_has": ["ANALOGIN", "ANALOGOUT", "I2C", "I2CSLAVE", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE", "STDIO_MESSAGES", "STORAGE", "TRNG", "FLASH"],
610610
"features": ["LWIP", "STORAGE"],
611+
"network_test_configurations" : {
612+
"EthernetInterface" : "mbed-os/tools/test/network_test_configs/EthernetInterface.json"
613+
},
611614
"release_versions": ["2", "5"],
612615
"device_name": "MK64FN1M0xxx12",
613616
"bootloader_supported": true

tools/test.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
sys.path.insert(0, ROOT)
2828

2929
from tools.config import ConfigException
30-
from tools.test_api import test_path_to_name, find_tests, print_tests, build_tests, test_spec_from_test_builds
30+
from tools.test_api import test_path_to_name, find_tests, find_configs, print_tests, build_tests, test_spec_from_test_builds
3131
from tools.options import get_default_options_parser, extract_profile, extract_mcus
3232
from tools.build_api import build_project, build_library
3333
from tools.build_api import print_build_memory_usage
@@ -84,6 +84,9 @@
8484
parser.add_argument("-n", "--names", dest="names", type=argparse_many(str),
8585
default=None, help="Limit the tests to a comma separated list of names")
8686

87+
parser.add_argument("--net-config", dest="net_config", type=str,
88+
default="EthernetInterface", help="Limit the tests to a networkinterface")
89+
8790
parser.add_argument("--test-spec", dest="test_spec",
8891
default=None, help="Destination path for a test spec file that can be used by the Greentea automated test tool")
8992

@@ -133,10 +136,19 @@
133136
"Currently set search path: %s"
134137
% (toolchain, search_path))
135138

139+
net_configs = find_configs(mcu) # will be {} if target has no network configs
140+
# If there is no app config and the target has network configs
141+
# TODO: merge app_config and net_config if there is both
142+
if net_configs and not options.app_config:
143+
# use a specified network config
144+
config = net_configs[options.net_config]
145+
else:
146+
config = options.app_config
147+
136148
# Find all tests in the relevant paths
137149
for path in all_paths:
138150
all_tests.update(find_tests(path, mcu, toolchain,
139-
app_config=options.app_config))
151+
app_config=config))
140152

141153
# Filter tests by name if specified
142154
if options.names:
@@ -192,7 +204,7 @@
192204
properties=build_properties, name="mbed-build",
193205
macros=options.macros, verbose=options.verbose,
194206
notify=notify, archive=False,
195-
app_config=options.app_config,
207+
app_config=config,
196208
build_profile=profile)
197209

198210
library_build_success = True
@@ -220,7 +232,7 @@
220232
notify=notify,
221233
jobs=options.jobs,
222234
continue_on_build_fail=options.continue_on_build_fail,
223-
app_config=options.app_config,
235+
app_config=config,
224236
build_profile=profile,
225237
stats_depth=options.stats_depth)
226238

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"config": {
3+
"header-file": {
4+
"help" : "String for including your driver header file",
5+
"value" : "\"EthernetInterface.h\""
6+
},
7+
"object-construction" : {
8+
"value" : "new EthernetInterface()"
9+
},
10+
"connect-statement" : {
11+
"help" : "Must use 'net' variable name",
12+
"value" : "((EthernetInterface *)net)->connect()"
13+
},
14+
"echo-server-addr" : {
15+
"help" : "IP address of echo server",
16+
"value" : "\"195.34.89.241\""
17+
},
18+
"echo-server-port" : {
19+
"help" : "Port of echo server",
20+
"value" : "7"
21+
},
22+
"tcp-echo-prefix" : {
23+
"help" : "Some servers send a prefix before echoed message",
24+
"value" : "\"u-blox AG TCP/UDP test service\\n\""
25+
}
26+
}
27+
}

tools/test_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,13 @@ def test_path_to_name(path, base):
19991999

20002000
return "-".join(name_parts).lower()
20012001

2002+
def find_configs(target_name):
2003+
target = TARGET_MAP[target_name]
2004+
try:
2005+
return target.network_test_configurations
2006+
except AttributeError:
2007+
return {}
2008+
20022009
def find_tests(base_dir, target_name, toolchain_name, app_config=None):
20032010
""" Finds all tests in a directory recursively
20042011
base_dir: path to the directory to scan for tests (ex. 'path/to/project')
@@ -2010,6 +2017,8 @@ def find_tests(base_dir, target_name, toolchain_name, app_config=None):
20102017

20112018
tests = {}
20122019

2020+
configs = find_configs(target_name)
2021+
20132022
# Prepare the toolchain
20142023
toolchain = prepare_toolchain([base_dir], None, target_name, toolchain_name,
20152024
silent=True, app_config=app_config)

0 commit comments

Comments
 (0)