Skip to content

Commit fd02bbb

Browse files
Olli-Pekka PuolitaivalCruz Monrreal II
authored andcommitted
Fix icetea run in case that user has different boards connected same time
1 parent 2ab73d2 commit fd02bbb

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

tools/run_icetea.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535

3636
def find_build_from_build_data(build_data, id, target, toolchain):
37-
3837
if 'builds' not in build_data:
3938
raise Exception("build data is in wrong format, does not include builds object")
4039

@@ -86,7 +85,7 @@ def create_test_suite(target, tool, icetea_json_output, build_data, tests_by_nam
8685
test_case = {
8786
'name': test['name'],
8887
'config': {
89-
'requirements': test['requirements']
88+
'requirements': set_allowed_platform(test['requirements'], target)
9089
}
9190
}
9291

@@ -104,6 +103,17 @@ def create_test_suite(target, tool, icetea_json_output, build_data, tests_by_nam
104103
return test_suite
105104

106105

106+
def set_allowed_platform(requirements, target):
107+
"""
108+
Allowed platform restrict icetea to run tests on specific board
109+
This targets tests to the right board in case that user has multiple ones connected same time
110+
"""
111+
if '*' not in requirements['duts'].keys():
112+
requirements['duts']['*'] = dict()
113+
requirements['duts']['*']['allowed_platforms'] = [target]
114+
return requirements
115+
116+
107117
def get_applications(test):
108118
ret = list()
109119
for dut in test['requirements']['duts'].values():

tools/test/run_icetea/run_icetea_unit_test.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
sys.path.insert(0, ROOT)
2222

2323
from tools.run_icetea import find_build_from_build_data, filter_test_by_build_data, filter_test_by_name, \
24-
get_application_list
24+
get_application_list, set_allowed_platform
2525

2626
"""
2727
Unit tests for run_icetea.py
@@ -143,3 +143,36 @@ def test_get_application_list_not_found():
143143

144144
def test_get_application_list_none():
145145
assert 'TEST_APPS-device-socket_app' in get_application_list(icetea_json_output, None)
146+
147+
148+
def test_set_allowed_platform_simple():
149+
ret = set_allowed_platform({"duts": {}}, "K66F")
150+
assert ret['duts']['*']['allowed_platforms'] == ["K66F"]
151+
152+
153+
def test_set_allowed_platform_normal():
154+
ret = set_allowed_platform({
155+
"duts": {
156+
"*": {
157+
"count": 3,
158+
"allowed_platforms": ["K64F"],
159+
"application": {"bin": "hex.bin"}
160+
},
161+
1: {"application": {"bin": "my_hex.bin"}},
162+
2: {"application": {"bin": "my_hex2.bin"}}
163+
}
164+
}, "K66F")
165+
assert ret['duts']['*']['allowed_platforms'] == ["K66F"]
166+
167+
168+
def test_set_allowed_platform_no_changes():
169+
temp = {
170+
"duts": {
171+
"*": {
172+
"count": 3,
173+
"allowed_platforms": ["K64F"],
174+
"application": {"bin": "hex.bin"}
175+
},
176+
}
177+
}
178+
assert temp == set_allowed_platform(temp, "K64F")

0 commit comments

Comments
 (0)