Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
run_icetea_unit_test.py
00001 """ 00002 Copyright 2018 ARM Limited 00003 Licensed under the Apache License, Version 2.0 (the "License"); 00004 you may not use this file except in compliance with the License. 00005 You may obtain a copy of the License at 00006 00007 http://www.apache.org/licenses/LICENSE-2.0 00008 00009 Unless required by applicable law or agreed to in writing, software 00010 distributed under the License is distributed on an "AS IS" BASIS, 00011 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 See the License for the specific language governing permissions and 00013 limitations under the License. 00014 """ 00015 00016 import os 00017 import sys 00018 00019 ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", 00020 "..")) 00021 sys.path.insert(0, ROOT) 00022 00023 from tools.run_icetea import find_build_from_build_data, filter_test_by_build_data, filter_test_by_name, \ 00024 get_application_list, set_allowed_platform 00025 00026 """ 00027 Unit tests for run_icetea.py 00028 """ 00029 00030 test_build_data = { 00031 'builds': [ 00032 { 00033 "id": "TEST_APPS-DEVICE-SOCKET_APP", 00034 "target_name": "K64F", 00035 "toolchain_name": "GCC_ARM", 00036 "result": "OK" 00037 } 00038 ] 00039 } 00040 00041 00042 def test_find_build_from_build_data_empty(): 00043 assert find_build_from_build_data(build_data={'builds': []}, id="something", target="K64F", 00044 toolchain="GCC_ARM") is None 00045 00046 00047 def test_find_build_from_build_data_wrong_target(): 00048 assert find_build_from_build_data(build_data=test_build_data, id="TEST_APPS-DEVICE-SOCKET_APP", target="AAAA", 00049 toolchain="GCC_ARM") is None 00050 00051 00052 def test_find_build_from_build_data(): 00053 assert find_build_from_build_data(build_data=test_build_data, id="TEST_APPS-DEVICE-SOCKET_APP", target="K64F", 00054 toolchain="GCC_ARM") is not None 00055 00056 00057 icetea_json_output = [ 00058 { 00059 "status": "released", 00060 "requirements": { 00061 "duts": { 00062 "1": { 00063 "nick": "dut1" 00064 }, 00065 "*": { 00066 "count": 1, 00067 "application": { 00068 "bin": None, 00069 "name": "TEST_APPS-device-socket_app" 00070 }, 00071 "type": "hardware" 00072 } 00073 }, 00074 "external": { 00075 "apps": [] 00076 } 00077 }, 00078 "name": "UDPSOCKET_BIND_PORT", 00079 "filepath": "/Users/test/mbed-os/TEST_APPS/testcases/SOCKET_BIND_PORT.py", 00080 "title": "udpsocket open and bind port", 00081 "component": [ 00082 "mbed-os", 00083 "netsocket" 00084 ], 00085 "compatible": { 00086 "framework": { 00087 "version": ">=1.0.0", 00088 "name": "Icetea" 00089 }, 00090 "hw": { 00091 "value": True 00092 }, 00093 "automation": { 00094 "value": True 00095 } 00096 }, 00097 "subtype": "socket", 00098 "purpose": "Verify UDPSocket can be created, opened and port binded", 00099 "type": "smoke", 00100 "sub_type": None 00101 } 00102 ] 00103 00104 00105 def test_filter_test_by_build_data_when_data_is_empty(): 00106 assert filter_test_by_build_data( 00107 icetea_json_output=icetea_json_output, 00108 build_data=None, 00109 target="K64F", 00110 toolchain="GCC_ARM" 00111 ) == icetea_json_output 00112 00113 00114 def test_filter_test_by_build_data(): 00115 temp = filter_test_by_build_data( 00116 icetea_json_output=icetea_json_output, 00117 build_data=test_build_data, 00118 target="K64F", 00119 toolchain="GCC_ARM" 00120 ) 00121 assert len(temp) > 0 00122 00123 00124 def test_filter_test_by_name(): 00125 assert len(filter_test_by_name(icetea_json_output, ['UDPSOCKET_BIND_PORT'])) > 0 00126 00127 00128 def test_filter_test_by_name_when_not_found(): 00129 assert filter_test_by_name(icetea_json_output, ['AAA']) == list() 00130 00131 00132 def test_filter_test_by_name_when_name_is_empty(): 00133 assert filter_test_by_name(icetea_json_output, None) == icetea_json_output 00134 00135 00136 def test_get_application_list(): 00137 assert 'TEST_APPS-device-socket_app' in get_application_list(icetea_json_output, ['UDPSOCKET_BIND_PORT']) 00138 00139 00140 def test_get_application_list_not_found(): 00141 assert 'TEST_APPS-device-socket_app' not in get_application_list(icetea_json_output, ['SOMETHING_ELSE']) 00142 00143 00144 def test_get_application_list_none(): 00145 assert 'TEST_APPS-device-socket_app' in get_application_list(icetea_json_output, None) 00146 00147 00148 def test_set_allowed_platform_simple(): 00149 ret = set_allowed_platform({"duts": {}}, "K66F") 00150 assert ret['duts']['*']['allowed_platforms'] == ["K66F"] 00151 00152 00153 def test_set_allowed_platform_normal(): 00154 ret = set_allowed_platform({ 00155 "duts": { 00156 "*": { 00157 "count": 3, 00158 "allowed_platforms": ["K64F"], 00159 "application": {"bin": "hex.bin"} 00160 }, 00161 1: {"application": {"bin": "my_hex.bin"}}, 00162 2: {"application": {"bin": "my_hex2.bin"}} 00163 } 00164 }, "K66F") 00165 assert ret['duts']['*']['allowed_platforms'] == ["K66F"] 00166 00167 00168 def test_set_allowed_platform_no_changes(): 00169 temp = { 00170 "duts": { 00171 "*": { 00172 "count": 3, 00173 "allowed_platforms": ["K64F"], 00174 "application": {"bin": "hex.bin"} 00175 }, 00176 } 00177 } 00178 assert temp == set_allowed_platform(temp, "K64F")
Generated on Tue Aug 9 2022 00:37:19 by
1.7.2