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_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 from os.path import realpath, join, dirname, isfile 00017 import subprocess 00018 00019 """ 00020 Tests for run_icetea.py 00021 """ 00022 this_file_dir = dirname(realpath(__file__)) 00023 hw_test_dir = join(this_file_dir, 'TEST_DIR_HW') 00024 test_dir = join(this_file_dir, 'TEST_DIR') 00025 empty_build_data = join(this_file_dir, 'empty_build_data.json') 00026 test_suite = join(this_file_dir, 'test_suite.json') 00027 run_icetea_py = join(dirname(dirname(this_file_dir)), 'run_icetea.py') 00028 assert isfile(run_icetea_py) 00029 00030 00031 def _execute_icetea(*params): 00032 command = ["python", run_icetea_py] + list(params) 00033 process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 00034 stout, sterr = process.communicate() 00035 status = process.poll() 00036 if status != 0: 00037 raise Exception("Error with {}, \nreturn code: {}, \nerror message: {}, \noutput:{}".format( 00038 " ".join(command), status, sterr, stout 00039 )) 00040 return stout.decode() 00041 00042 00043 def test_help (): 00044 """ 00045 Just test that something works 00046 :return: 00047 """ 00048 _execute_icetea('--help') 00049 00050 00051 def test_list_tests_k64f(): 00052 out = _execute_icetea('--compile-list', '--mcu', 'K64F', '--toolchain', 'GCC_ARM', '--tcdir', hw_test_dir) 00053 assert 'test_K64F_only' in out 00054 assert 'test_predefined_platforms' in out 00055 00056 00057 def test_list_tests_nucleo_l073rz(): 00058 out = _execute_icetea('--compile-list', '--mcu', 'NUCLEO_L073RZ', '--toolchain', 'GCC_ARM', '--tcdir', hw_test_dir) 00059 assert 'test_predefined_platforms' in out 00060 assert 'test_K64F_only' not in out 00061 00062 00063 def test_run(): 00064 out = _execute_icetea('--mcu', 'K64F', '--toolchain', 'GCC_ARM', '--tcdir', test_dir, '--build-data', 00065 empty_build_data, '--test-suite', test_suite, '--ignore-checks') 00066 assert 'test_print' in out 00067 assert 'test_pass' in out 00068 00069 00070 def test_run_by_name(): 00071 out = _execute_icetea('--mcu', 'K64F', '--toolchain', 'GCC_ARM', '--tcdir', test_dir, '--build-data', 00072 empty_build_data, '--test-suite', test_suite, '--tests-by-name', 'test_pass', 00073 '--ignore-checks') 00074 assert 'test_pass' in out 00075 assert 'test_print' not in out 00076 00077 00078 def test_run_hw_with_not_build_tests (): 00079 """ 00080 When test binaries are not found tests will be skipped 00081 :return: 00082 """ 00083 out = _execute_icetea('--mcu', 'K64F', '--toolchain', 'GCC_ARM', '--tcdir', hw_test_dir, '--build-data', 00084 empty_build_data, '--test-suite', test_suite) 00085 output_lines = out.split('\n') 00086 00087 # Assert that 00088 temp = list(filter(lambda x: 'test_K64F_only' in x, output_lines))[0] 00089 assert 'skip' in temp 00090 00091 temp = list(filter(lambda x: 'test_predefined_platforms' in x, output_lines))[0] 00092 assert 'skip' in temp 00093 00094 00095 def test_data_validation(): 00096 exception_happened = False 00097 try: 00098 _execute_icetea('--mcu', 'K64F', '--toolchain', 'GCC_ARM', '--tcdir', test_dir, '--build-data', 00099 empty_build_data, '--test-suite', test_suite) 00100 except BaseException: 00101 exception_happened = True 00102 assert exception_happened
Generated on Tue Aug 9 2022 00:37:19 by
1.7.2