Skip to content

Commit e982eed

Browse files
committed
Add option to add a configuration file for modules
1 parent 8c0bc78 commit e982eed

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

tools/test.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
parser.add_argument("--net-config", dest="net_config", type=str,
8888
default="EthernetInterface", help="Limit the tests to a networkinterface")
8989

90+
parser.add_argument("--module-config", dest="module_config", type=str,
91+
default=None, help="Test config for a module")
92+
9093
parser.add_argument("--test-spec", dest="test_spec",
9194
default=None, help="Destination path for a test spec file that can be used by the Greentea automated test tool")
9295

@@ -136,19 +139,21 @@
136139
"Currently set search path: %s"
137140
% (toolchain, search_path))
138141

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
142+
# Assign config file. Precedence: module_config>net_config>app_config
143+
# TODO: merge configs if there are multiple
144+
if options.module_config:
145+
config = options.module_config
146+
elif find_configs(mcu):
147+
net_configs = find_configs(mcu) # will be {} if target has no network configs
144148
config = net_configs[options.net_config]
145149
else:
146150
config = options.app_config
147151

148152
# Find all tests in the relevant paths
149153
for path in all_paths:
150154
all_tests.update(find_tests(path, mcu, toolchain,
151-
app_config=config))
155+
app_config=config,
156+
module_config=options.module_config))
152157

153158
# Filter tests by name if specified
154159
if options.names:

tools/test_api.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,7 @@ def find_configs(target_name):
20062006
except AttributeError:
20072007
return {}
20082008

2009-
def find_tests(base_dir, target_name, toolchain_name, app_config=None):
2009+
def find_tests(base_dir, target_name, toolchain_name, app_config=None, module_config=None):
20102010
""" Finds all tests in a directory recursively
20112011
base_dir: path to the directory to scan for tests (ex. 'path/to/project')
20122012
target_name: name of the target to use for scanning (ex. 'K64F')
@@ -2046,6 +2046,11 @@ def find_tests(base_dir, target_name, toolchain_name, app_config=None):
20462046
test_group_directory_path, test_case_directory = os.path.split(d)
20472047
test_group_directory = os.path.basename(test_group_directory_path)
20482048

2049+
# If the target has no network interface configuration, netsocket tests fail to compile
2050+
if not module_config and not configs and \
2051+
(test_case_directory == 'netsocket' or test_group_directory == 'netsocket'):
2052+
continue
2053+
20492054
# Check to make sure discoverd folder is not in a host test directory
20502055
if test_case_directory != 'host_tests' and test_group_directory != 'host_tests':
20512056
test_name = test_path_to_name(d, base_dir)

0 commit comments

Comments
 (0)