From cd628a77a2cd4b8fa8551c89f65f2d143e508b18 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Puolitaival Date: Fri, 14 Sep 2018 13:49:41 +0300 Subject: [PATCH 1/3] Include run_icetea unittests also in pytest run --- .../{run_icetea_unittest.py => run_icetea_unit_test.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/test/run_icetea/{run_icetea_unittest.py => run_icetea_unit_test.py} (100%) diff --git a/tools/test/run_icetea/run_icetea_unittest.py b/tools/test/run_icetea/run_icetea_unit_test.py similarity index 100% rename from tools/test/run_icetea/run_icetea_unittest.py rename to tools/test/run_icetea/run_icetea_unit_test.py From 1981728be98b4cd79ce90f50a3dbc25e0d3fc31e Mon Sep 17 00:00:00 2001 From: Olli-Pekka Puolitaival Date: Fri, 14 Sep 2018 13:57:08 +0300 Subject: [PATCH 2/3] Fix tests --- tools/test/run_icetea/run_icetea_unit_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/test/run_icetea/run_icetea_unit_test.py b/tools/test/run_icetea/run_icetea_unit_test.py index 052f5a4013..90db27d288 100644 --- a/tools/test/run_icetea/run_icetea_unit_test.py +++ b/tools/test/run_icetea/run_icetea_unit_test.py @@ -32,7 +32,8 @@ test_build_data = { { "id": "TEST_APPS-DEVICE-SOCKET_APP", "target_name": "K64F", - "toolchain_name": "GCC_ARM" + "toolchain_name": "GCC_ARM", + "result": "OK" } ] } From ed18665807d70c750fbd22d354cd2a332ce2ad92 Mon Sep 17 00:00:00 2001 From: Olli-Pekka Puolitaival Date: Fri, 14 Sep 2018 15:46:26 +0300 Subject: [PATCH 3/3] Fix icetea run in case that user has different boards connected same time --- tools/run_icetea.py | 14 ++++++-- tools/test/run_icetea/run_icetea_unit_test.py | 35 ++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/tools/run_icetea.py b/tools/run_icetea.py index 35a7f7066a..bf2706f035 100644 --- a/tools/run_icetea.py +++ b/tools/run_icetea.py @@ -34,7 +34,6 @@ plugins_path = abspath(join(ROOT, 'TEST_APPS', 'icetea_plugins', 'plugins_to_loa def find_build_from_build_data(build_data, id, target, toolchain): - if 'builds' not in build_data: raise Exception("build data is in wrong format, does not include builds object") @@ -86,7 +85,7 @@ def create_test_suite(target, tool, icetea_json_output, build_data, tests_by_nam test_case = { 'name': test['name'], 'config': { - 'requirements': test['requirements'] + 'requirements': set_allowed_platform(test['requirements'], target) } } @@ -104,6 +103,17 @@ def create_test_suite(target, tool, icetea_json_output, build_data, tests_by_nam return test_suite +def set_allowed_platform(requirements, target): + """ + Allowed platform restrict icetea to run tests on specific board + This targets tests to the right board in case that user has multiple ones connected same time + """ + if '*' not in requirements['duts'].keys(): + requirements['duts']['*'] = dict() + requirements['duts']['*']['allowed_platforms'] = [target] + return requirements + + def get_applications(test): ret = list() for dut in test['requirements']['duts'].values(): diff --git a/tools/test/run_icetea/run_icetea_unit_test.py b/tools/test/run_icetea/run_icetea_unit_test.py index 90db27d288..7ff1fea02e 100644 --- a/tools/test/run_icetea/run_icetea_unit_test.py +++ b/tools/test/run_icetea/run_icetea_unit_test.py @@ -21,7 +21,7 @@ ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", sys.path.insert(0, ROOT) from tools.run_icetea import find_build_from_build_data, filter_test_by_build_data, filter_test_by_name, \ - get_application_list + get_application_list, set_allowed_platform """ Unit tests for run_icetea.py @@ -143,3 +143,36 @@ def test_get_application_list_not_found(): def test_get_application_list_none(): assert 'TEST_APPS-device-socket_app' in get_application_list(icetea_json_output, None) + + +def test_set_allowed_platform_simple(): + ret = set_allowed_platform({"duts": {}}, "K66F") + assert ret['duts']['*']['allowed_platforms'] == ["K66F"] + + +def test_set_allowed_platform_normal(): + ret = set_allowed_platform({ + "duts": { + "*": { + "count": 3, + "allowed_platforms": ["K64F"], + "application": {"bin": "hex.bin"} + }, + 1: {"application": {"bin": "my_hex.bin"}}, + 2: {"application": {"bin": "my_hex2.bin"}} + } + }, "K66F") + assert ret['duts']['*']['allowed_platforms'] == ["K66F"] + + +def test_set_allowed_platform_no_changes(): + temp = { + "duts": { + "*": { + "count": 3, + "allowed_platforms": ["K64F"], + "application": {"bin": "hex.bin"} + }, + } + } + assert temp == set_allowed_platform(temp, "K64F")