Clone of official tools

Committer:
Anders Blomdell
Date:
Thu Feb 04 17:17:13 2021 +0100
Revision:
47:21ae3e5a7128
Parent:
43:2a7da56ebd24
Add a few normpath calls

Who changed what in which revision?

UserRevisionLine numberNew contents of line
theotherjimmy 43:2a7da56ebd24 1 #! /usr/bin/env python2
theotherjimmy 43:2a7da56ebd24 2 """
theotherjimmy 43:2a7da56ebd24 3 Copyright 2018 ARM Limited
theotherjimmy 43:2a7da56ebd24 4 Licensed under the Apache License, Version 2.0 (the "License");
theotherjimmy 43:2a7da56ebd24 5 you may not use this file except in compliance with the License.
theotherjimmy 43:2a7da56ebd24 6 You may obtain a copy of the License at
theotherjimmy 43:2a7da56ebd24 7
theotherjimmy 43:2a7da56ebd24 8 http://www.apache.org/licenses/LICENSE-2.0
theotherjimmy 43:2a7da56ebd24 9
theotherjimmy 43:2a7da56ebd24 10 Unless required by applicable law or agreed to in writing, software
theotherjimmy 43:2a7da56ebd24 11 distributed under the License is distributed on an "AS IS" BASIS,
theotherjimmy 43:2a7da56ebd24 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
theotherjimmy 43:2a7da56ebd24 13 See the License for the specific language governing permissions and
theotherjimmy 43:2a7da56ebd24 14 limitations under the License.
theotherjimmy 43:2a7da56ebd24 15 """
theotherjimmy 43:2a7da56ebd24 16
theotherjimmy 43:2a7da56ebd24 17 from __future__ import print_function, division, absolute_import
theotherjimmy 43:2a7da56ebd24 18 import sys
theotherjimmy 43:2a7da56ebd24 19 import os
theotherjimmy 43:2a7da56ebd24 20 import re
theotherjimmy 43:2a7da56ebd24 21 from os.path import abspath, join, dirname, relpath, sep
theotherjimmy 43:2a7da56ebd24 22 import json
theotherjimmy 43:2a7da56ebd24 23 import traceback
theotherjimmy 43:2a7da56ebd24 24 from fnmatch import translate
theotherjimmy 43:2a7da56ebd24 25 from argparse import ArgumentParser
theotherjimmy 43:2a7da56ebd24 26
theotherjimmy 43:2a7da56ebd24 27 ROOT = abspath(join(dirname(__file__), '..'))
theotherjimmy 43:2a7da56ebd24 28 sys.path.insert(0, ROOT)
theotherjimmy 43:2a7da56ebd24 29
theotherjimmy 43:2a7da56ebd24 30 from tools.config import ConfigException
theotherjimmy 43:2a7da56ebd24 31 from tools.utils import cmd, run_cmd
theotherjimmy 43:2a7da56ebd24 32
theotherjimmy 43:2a7da56ebd24 33 plugins_path = abspath(join(ROOT, 'TEST_APPS', 'icetea_plugins', 'plugins_to_load.py'))
theotherjimmy 43:2a7da56ebd24 34
theotherjimmy 43:2a7da56ebd24 35
theotherjimmy 43:2a7da56ebd24 36 def find_build_from_build_data(build_data, id, target, toolchain):
theotherjimmy 43:2a7da56ebd24 37 if 'builds' not in build_data:
theotherjimmy 43:2a7da56ebd24 38 raise Exception("build data is in wrong format, does not include builds object")
theotherjimmy 43:2a7da56ebd24 39
theotherjimmy 43:2a7da56ebd24 40 for build in build_data['builds']:
theotherjimmy 43:2a7da56ebd24 41 if 'id' in build.keys() \
theotherjimmy 43:2a7da56ebd24 42 and id.upper() in build['id'].upper() \
theotherjimmy 43:2a7da56ebd24 43 and 'target_name' in build.keys() \
theotherjimmy 43:2a7da56ebd24 44 and target.upper() == build['target_name'].upper() \
theotherjimmy 43:2a7da56ebd24 45 and 'toolchain_name' in build.keys() \
theotherjimmy 43:2a7da56ebd24 46 and toolchain.upper() == build['toolchain_name'].upper() \
theotherjimmy 43:2a7da56ebd24 47 and 'result' in build.keys() \
theotherjimmy 43:2a7da56ebd24 48 and "OK" == build['result']:
theotherjimmy 43:2a7da56ebd24 49 return build
theotherjimmy 43:2a7da56ebd24 50 return None
theotherjimmy 43:2a7da56ebd24 51
theotherjimmy 43:2a7da56ebd24 52
theotherjimmy 43:2a7da56ebd24 53 def create_test_suite(target, tool, icetea_json_output, build_data, tests_by_name):
theotherjimmy 43:2a7da56ebd24 54 """
theotherjimmy 43:2a7da56ebd24 55 Create test suite content
theotherjimmy 43:2a7da56ebd24 56 :param target:
theotherjimmy 43:2a7da56ebd24 57 :param tool:
theotherjimmy 43:2a7da56ebd24 58 :param icetea_json_output:
theotherjimmy 43:2a7da56ebd24 59 :param build_data:
theotherjimmy 43:2a7da56ebd24 60 :return:
theotherjimmy 43:2a7da56ebd24 61 """
theotherjimmy 43:2a7da56ebd24 62 test_suite = dict()
theotherjimmy 43:2a7da56ebd24 63 test_suite['testcases'] = list()
theotherjimmy 43:2a7da56ebd24 64
theotherjimmy 43:2a7da56ebd24 65 for test in icetea_json_output:
theotherjimmy 43:2a7da56ebd24 66 skip = False
theotherjimmy 43:2a7da56ebd24 67
theotherjimmy 43:2a7da56ebd24 68 for dut in test['requirements']['duts'].values():
theotherjimmy 43:2a7da56ebd24 69 # Set binary path based on application name
theotherjimmy 43:2a7da56ebd24 70 if 'application' in dut.keys() and 'name' in dut['application'].keys():
theotherjimmy 43:2a7da56ebd24 71 build = find_build_from_build_data(
theotherjimmy 43:2a7da56ebd24 72 build_data=build_data,
theotherjimmy 43:2a7da56ebd24 73 id=dut['application']['name'],
theotherjimmy 43:2a7da56ebd24 74 target=target,
theotherjimmy 43:2a7da56ebd24 75 toolchain=tool)
theotherjimmy 43:2a7da56ebd24 76 if build:
theotherjimmy 43:2a7da56ebd24 77 try:
theotherjimmy 43:2a7da56ebd24 78 dut['application']['bin'] = build['bin_fullpath']
theotherjimmy 43:2a7da56ebd24 79 except KeyError:
theotherjimmy 43:2a7da56ebd24 80 raise Exception('Full path is missing from build: {}'.format(build))
theotherjimmy 43:2a7da56ebd24 81 else:
theotherjimmy 43:2a7da56ebd24 82 skip = True
theotherjimmy 43:2a7da56ebd24 83
theotherjimmy 43:2a7da56ebd24 84 if not tests_by_name or is_test_in_test_by_name(test['name'], tests_by_name):
theotherjimmy 43:2a7da56ebd24 85 test_case = {
theotherjimmy 43:2a7da56ebd24 86 'name': test['name'],
theotherjimmy 43:2a7da56ebd24 87 'config': {
theotherjimmy 43:2a7da56ebd24 88 'requirements': set_allowed_platform(test['requirements'], target)
theotherjimmy 43:2a7da56ebd24 89 }
theotherjimmy 43:2a7da56ebd24 90 }
theotherjimmy 43:2a7da56ebd24 91
theotherjimmy 43:2a7da56ebd24 92 # Skip test if not binary path
theotherjimmy 43:2a7da56ebd24 93 if skip:
theotherjimmy 43:2a7da56ebd24 94 test_case['config']['execution'] = {
theotherjimmy 43:2a7da56ebd24 95 'skip': {
theotherjimmy 43:2a7da56ebd24 96 'value': True,
theotherjimmy 43:2a7da56ebd24 97 'reason': "Test requiring application binary not build"
theotherjimmy 43:2a7da56ebd24 98 }
theotherjimmy 43:2a7da56ebd24 99 }
theotherjimmy 43:2a7da56ebd24 100
theotherjimmy 43:2a7da56ebd24 101 test_suite['testcases'].append(test_case)
theotherjimmy 43:2a7da56ebd24 102
theotherjimmy 43:2a7da56ebd24 103 return test_suite
theotherjimmy 43:2a7da56ebd24 104
theotherjimmy 43:2a7da56ebd24 105
theotherjimmy 43:2a7da56ebd24 106 def set_allowed_platform(requirements, target):
theotherjimmy 43:2a7da56ebd24 107 """
theotherjimmy 43:2a7da56ebd24 108 Allowed platform restrict icetea to run tests on specific board
theotherjimmy 43:2a7da56ebd24 109 This targets tests to the right board in case that user has multiple ones connected same time
theotherjimmy 43:2a7da56ebd24 110 """
theotherjimmy 43:2a7da56ebd24 111 if '*' not in requirements['duts'].keys():
theotherjimmy 43:2a7da56ebd24 112 requirements['duts']['*'] = dict()
theotherjimmy 43:2a7da56ebd24 113 requirements['duts']['*']['allowed_platforms'] = [target]
theotherjimmy 43:2a7da56ebd24 114 return requirements
theotherjimmy 43:2a7da56ebd24 115
theotherjimmy 43:2a7da56ebd24 116
theotherjimmy 43:2a7da56ebd24 117 def get_applications(test):
theotherjimmy 43:2a7da56ebd24 118 ret = list()
theotherjimmy 43:2a7da56ebd24 119 for dut in test['requirements']['duts'].values():
theotherjimmy 43:2a7da56ebd24 120 if 'application' in dut.keys() and 'name' in dut['application'].keys():
theotherjimmy 43:2a7da56ebd24 121 ret.append(dut['application']['name'])
theotherjimmy 43:2a7da56ebd24 122 return ret
theotherjimmy 43:2a7da56ebd24 123
theotherjimmy 43:2a7da56ebd24 124
theotherjimmy 43:2a7da56ebd24 125 def filter_test_by_build_data(icetea_json_output, build_data, target, toolchain):
theotherjimmy 43:2a7da56ebd24 126 if not build_data:
theotherjimmy 43:2a7da56ebd24 127 return icetea_json_output
theotherjimmy 43:2a7da56ebd24 128
theotherjimmy 43:2a7da56ebd24 129 ret = list()
theotherjimmy 43:2a7da56ebd24 130 for test in icetea_json_output:
theotherjimmy 43:2a7da56ebd24 131 for dut in test['requirements']['duts'].values():
theotherjimmy 43:2a7da56ebd24 132 if 'application' in dut.keys() and 'name' in dut['application'].keys():
theotherjimmy 43:2a7da56ebd24 133 id = dut['application']['name']
theotherjimmy 43:2a7da56ebd24 134 if find_build_from_build_data(build_data, id, target, toolchain):
theotherjimmy 43:2a7da56ebd24 135 # Test requiring build found
theotherjimmy 43:2a7da56ebd24 136 ret.append(test)
theotherjimmy 43:2a7da56ebd24 137 return ret
theotherjimmy 43:2a7da56ebd24 138
theotherjimmy 43:2a7da56ebd24 139
theotherjimmy 43:2a7da56ebd24 140 def filter_test_by_name(icetea_json_output, test_by_name):
theotherjimmy 43:2a7da56ebd24 141 if not test_by_name:
theotherjimmy 43:2a7da56ebd24 142 return icetea_json_output
theotherjimmy 43:2a7da56ebd24 143 ret = list()
theotherjimmy 43:2a7da56ebd24 144 for test_temp in icetea_json_output:
theotherjimmy 43:2a7da56ebd24 145 if is_test_in_test_by_name(test_temp['name'], test_by_name) and test_temp not in ret:
theotherjimmy 43:2a7da56ebd24 146 ret.append(test_temp)
theotherjimmy 43:2a7da56ebd24 147 return ret
theotherjimmy 43:2a7da56ebd24 148
theotherjimmy 43:2a7da56ebd24 149
theotherjimmy 43:2a7da56ebd24 150 def get_applications_from_test(test):
theotherjimmy 43:2a7da56ebd24 151 ret = list()
theotherjimmy 43:2a7da56ebd24 152 if u'requirements' in test.keys() and u'duts' in test[u'requirements']:
theotherjimmy 43:2a7da56ebd24 153 for name, dut in test[u'requirements'][u'duts'].items():
theotherjimmy 43:2a7da56ebd24 154 if u'application' in dut.keys() and u'name' in dut[u'application']:
theotherjimmy 43:2a7da56ebd24 155 ret.append(dut[u'application'][u'name'])
theotherjimmy 43:2a7da56ebd24 156 return ret
theotherjimmy 43:2a7da56ebd24 157
theotherjimmy 43:2a7da56ebd24 158
theotherjimmy 43:2a7da56ebd24 159 def get_application_list(icetea_json_output, tests_by_name):
theotherjimmy 43:2a7da56ebd24 160 """ Return comma separated list of application which are used in tests """
theotherjimmy 43:2a7da56ebd24 161 ret = list()
theotherjimmy 43:2a7da56ebd24 162 for test in filter_test_by_name(icetea_json_output, tests_by_name):
theotherjimmy 43:2a7da56ebd24 163 ret.extend(get_applications_from_test(test))
theotherjimmy 43:2a7da56ebd24 164 # Remove duplicates
theotherjimmy 43:2a7da56ebd24 165 return list(set(ret))
theotherjimmy 43:2a7da56ebd24 166
theotherjimmy 43:2a7da56ebd24 167
theotherjimmy 43:2a7da56ebd24 168 def icetea_tests(target, tcdir, verbose):
theotherjimmy 43:2a7da56ebd24 169 command = ['icetea', '--tcdir', tcdir, '--list', '--json', '--platform_filter', target] \
theotherjimmy 43:2a7da56ebd24 170 + (['-v'] if verbose else [])
theotherjimmy 43:2a7da56ebd24 171
theotherjimmy 43:2a7da56ebd24 172 stdout, stderr, returncode = run_cmd(command)
theotherjimmy 43:2a7da56ebd24 173
theotherjimmy 43:2a7da56ebd24 174 if returncode != 0:
theotherjimmy 43:2a7da56ebd24 175 raise Exception(
theotherjimmy 43:2a7da56ebd24 176 "Error when running icetea. \ncwd:{} \nCommand:'{}' \noutput:{}".format(os.getcwd(), ' '.join(command),
theotherjimmy 43:2a7da56ebd24 177 stderr.decode()))
theotherjimmy 43:2a7da56ebd24 178
theotherjimmy 43:2a7da56ebd24 179 return json.loads(stdout)
theotherjimmy 43:2a7da56ebd24 180
theotherjimmy 43:2a7da56ebd24 181
theotherjimmy 43:2a7da56ebd24 182 def is_test_in_test_by_name(test_name, test_by_name):
theotherjimmy 43:2a7da56ebd24 183 for tbn_temp in test_by_name:
theotherjimmy 43:2a7da56ebd24 184 if re.search(translate(tbn_temp), test_name):
theotherjimmy 43:2a7da56ebd24 185 return True
theotherjimmy 43:2a7da56ebd24 186 return False
theotherjimmy 43:2a7da56ebd24 187
theotherjimmy 43:2a7da56ebd24 188
theotherjimmy 43:2a7da56ebd24 189 def check_tests(icetea_json_output):
theotherjimmy 43:2a7da56ebd24 190 """
theotherjimmy 43:2a7da56ebd24 191 Check that all tests have all necessary information
theotherjimmy 43:2a7da56ebd24 192 :return:
theotherjimmy 43:2a7da56ebd24 193 """
theotherjimmy 43:2a7da56ebd24 194 for test in icetea_json_output:
theotherjimmy 43:2a7da56ebd24 195 if not get_applications_from_test(test):
theotherjimmy 43:2a7da56ebd24 196 raise Exception('Test {} does not have application with correct name'.format(test['name']))
theotherjimmy 43:2a7da56ebd24 197
theotherjimmy 43:2a7da56ebd24 198
theotherjimmy 43:2a7da56ebd24 199 def load_build_data(build_data_path):
theotherjimmy 43:2a7da56ebd24 200 """
theotherjimmy 43:2a7da56ebd24 201 :return: build_data.json content as dict and None if build data is not available
theotherjimmy 43:2a7da56ebd24 202 """
theotherjimmy 43:2a7da56ebd24 203 if not os.path.isfile(build_data_path):
theotherjimmy 43:2a7da56ebd24 204 return None
theotherjimmy 43:2a7da56ebd24 205 return json.load(open(build_data_path))
theotherjimmy 43:2a7da56ebd24 206
theotherjimmy 43:2a7da56ebd24 207
theotherjimmy 43:2a7da56ebd24 208 if __name__ == '__main__':
theotherjimmy 43:2a7da56ebd24 209 try:
theotherjimmy 43:2a7da56ebd24 210 # Parse Options
theotherjimmy 43:2a7da56ebd24 211 parser = ArgumentParser()
theotherjimmy 43:2a7da56ebd24 212
theotherjimmy 43:2a7da56ebd24 213 parser.add_argument('-m', '--mcu',
theotherjimmy 43:2a7da56ebd24 214 dest='target',
theotherjimmy 43:2a7da56ebd24 215 default=None,
theotherjimmy 43:2a7da56ebd24 216 help='Test target MCU',
theotherjimmy 43:2a7da56ebd24 217 required=True)
theotherjimmy 43:2a7da56ebd24 218
theotherjimmy 43:2a7da56ebd24 219 parser.add_argument('-t', '--toolchain',
theotherjimmy 43:2a7da56ebd24 220 dest='toolchain',
theotherjimmy 43:2a7da56ebd24 221 default=None,
theotherjimmy 43:2a7da56ebd24 222 help='Toolchain',
theotherjimmy 43:2a7da56ebd24 223 required=True)
theotherjimmy 43:2a7da56ebd24 224
theotherjimmy 43:2a7da56ebd24 225 parser.add_argument('--build-data',
theotherjimmy 43:2a7da56ebd24 226 dest='build_data',
theotherjimmy 43:2a7da56ebd24 227 default=None,
theotherjimmy 43:2a7da56ebd24 228 help='Detail data from build')
theotherjimmy 43:2a7da56ebd24 229
theotherjimmy 43:2a7da56ebd24 230 parser.add_argument('--test-suite',
theotherjimmy 43:2a7da56ebd24 231 dest='test_suite',
theotherjimmy 43:2a7da56ebd24 232 default=None,
theotherjimmy 43:2a7da56ebd24 233 help='Path used for test suite file')
theotherjimmy 43:2a7da56ebd24 234
theotherjimmy 43:2a7da56ebd24 235 parser.add_argument('-n', '--tests-by-name',
theotherjimmy 43:2a7da56ebd24 236 dest='tests_by_name',
theotherjimmy 43:2a7da56ebd24 237 default=None,
theotherjimmy 43:2a7da56ebd24 238 help='Limit the tests to a list (ex. test1,test2,test3)')
theotherjimmy 43:2a7da56ebd24 239
theotherjimmy 43:2a7da56ebd24 240 parser.add_argument('--tcdir',
theotherjimmy 43:2a7da56ebd24 241 dest='tcdir',
theotherjimmy 43:2a7da56ebd24 242 default='TEST_APPS',
theotherjimmy 43:2a7da56ebd24 243 help='Test case directory',
theotherjimmy 43:2a7da56ebd24 244 required=False)
theotherjimmy 43:2a7da56ebd24 245
theotherjimmy 43:2a7da56ebd24 246 parser.add_argument('--compile-list',
theotherjimmy 43:2a7da56ebd24 247 action='store_true',
theotherjimmy 43:2a7da56ebd24 248 dest='compile_list',
theotherjimmy 43:2a7da56ebd24 249 default=False,
theotherjimmy 43:2a7da56ebd24 250 help='List tests, which applications can be compiled')
theotherjimmy 43:2a7da56ebd24 251
theotherjimmy 43:2a7da56ebd24 252 parser.add_argument('--run-list',
theotherjimmy 43:2a7da56ebd24 253 action='store_true',
theotherjimmy 43:2a7da56ebd24 254 dest='run_list',
theotherjimmy 43:2a7da56ebd24 255 default=False,
theotherjimmy 43:2a7da56ebd24 256 help='List tests, which applications are compiled and ready for run')
theotherjimmy 43:2a7da56ebd24 257
theotherjimmy 43:2a7da56ebd24 258 parser.add_argument('--application-list',
theotherjimmy 43:2a7da56ebd24 259 action='store_true',
theotherjimmy 43:2a7da56ebd24 260 dest='application_list',
theotherjimmy 43:2a7da56ebd24 261 default=False,
theotherjimmy 43:2a7da56ebd24 262 help='List applications that need to be build')
theotherjimmy 43:2a7da56ebd24 263
theotherjimmy 43:2a7da56ebd24 264 parser.add_argument('--ignore-checks',
theotherjimmy 43:2a7da56ebd24 265 action='store_true',
theotherjimmy 43:2a7da56ebd24 266 dest='ignore_checks',
theotherjimmy 43:2a7da56ebd24 267 default=False,
theotherjimmy 43:2a7da56ebd24 268 help='Ignore data validation checks')
theotherjimmy 43:2a7da56ebd24 269
theotherjimmy 43:2a7da56ebd24 270 parser.add_argument('-v', '--verbose',
theotherjimmy 43:2a7da56ebd24 271 action='store_true',
theotherjimmy 43:2a7da56ebd24 272 dest='verbose',
theotherjimmy 43:2a7da56ebd24 273 default=False,
theotherjimmy 43:2a7da56ebd24 274 help='Verbose diagnostic output')
theotherjimmy 43:2a7da56ebd24 275
theotherjimmy 43:2a7da56ebd24 276 options = parser.parse_args()
theotherjimmy 43:2a7da56ebd24 277
theotherjimmy 43:2a7da56ebd24 278 icetea_json_output = icetea_tests(options.target, options.tcdir, options.verbose)
theotherjimmy 43:2a7da56ebd24 279 tests_by_name = options.tests_by_name.split(',') if options.tests_by_name else None
theotherjimmy 43:2a7da56ebd24 280 build_data = load_build_data(options.build_data) if options.build_data else None
theotherjimmy 43:2a7da56ebd24 281
theotherjimmy 43:2a7da56ebd24 282 if not options.ignore_checks:
theotherjimmy 43:2a7da56ebd24 283 check_tests(icetea_json_output)
theotherjimmy 43:2a7da56ebd24 284
theotherjimmy 43:2a7da56ebd24 285 if options.compile_list:
theotherjimmy 43:2a7da56ebd24 286 print('Available icetea tests for build \'{}-{}\', location \'{}\''.format(
theotherjimmy 43:2a7da56ebd24 287 options.target, options.toolchain, options.tcdir))
theotherjimmy 43:2a7da56ebd24 288 for test in icetea_json_output:
theotherjimmy 43:2a7da56ebd24 289 print(
theotherjimmy 43:2a7da56ebd24 290 'Test Case:\n Name: {name}\n Path: .{sep}{filepath}\n Test applications: .{sep}{apps}'.format(
theotherjimmy 43:2a7da56ebd24 291 name=test['name'],
theotherjimmy 43:2a7da56ebd24 292 sep=sep,
theotherjimmy 43:2a7da56ebd24 293 filepath=relpath(test['filepath'], ROOT),
theotherjimmy 43:2a7da56ebd24 294 apps=''.join(get_applications(test)).replace('-', os.path.sep)))
theotherjimmy 43:2a7da56ebd24 295
theotherjimmy 43:2a7da56ebd24 296 elif options.run_list:
theotherjimmy 43:2a7da56ebd24 297 print('Available icetea tests for build \'{}-{}\', location \'{}\''.format(
theotherjimmy 43:2a7da56ebd24 298 options.target, options.toolchain, options.tcdir))
theotherjimmy 43:2a7da56ebd24 299
theotherjimmy 43:2a7da56ebd24 300 # Filters
theotherjimmy 43:2a7da56ebd24 301 tests = filter_test_by_name(icetea_json_output, tests_by_name)
theotherjimmy 43:2a7da56ebd24 302 if build_data:
theotherjimmy 43:2a7da56ebd24 303 tests = filter_test_by_build_data(tests, build_data, options.target, options.toolchain)
theotherjimmy 43:2a7da56ebd24 304
theotherjimmy 43:2a7da56ebd24 305 for test in tests:
theotherjimmy 43:2a7da56ebd24 306 print(' test \'{name}\''.format(name=test['name']))
theotherjimmy 43:2a7da56ebd24 307
theotherjimmy 43:2a7da56ebd24 308 elif options.application_list:
theotherjimmy 43:2a7da56ebd24 309 print(','.join(get_application_list(icetea_json_output, tests_by_name)))
theotherjimmy 43:2a7da56ebd24 310
theotherjimmy 43:2a7da56ebd24 311 else:
theotherjimmy 43:2a7da56ebd24 312 if not build_data:
theotherjimmy 43:2a7da56ebd24 313 raise Exception("Build data file does not exist: {}".format(options.build_data))
theotherjimmy 43:2a7da56ebd24 314
theotherjimmy 43:2a7da56ebd24 315 test_suite = create_test_suite(options.target, options.toolchain, icetea_json_output, build_data,
theotherjimmy 43:2a7da56ebd24 316 tests_by_name)
theotherjimmy 43:2a7da56ebd24 317
theotherjimmy 43:2a7da56ebd24 318 if not test_suite['testcases']:
theotherjimmy 43:2a7da56ebd24 319 raise Exception("Test suite is empty. Check that --tcdir and --tests-by-name have correct values")
theotherjimmy 43:2a7da56ebd24 320
theotherjimmy 43:2a7da56ebd24 321 if not options.test_suite:
theotherjimmy 43:2a7da56ebd24 322 raise Exception('--test-suite is required when running tests')
theotherjimmy 43:2a7da56ebd24 323
theotherjimmy 43:2a7da56ebd24 324 with open(options.test_suite, 'w') as f:
theotherjimmy 43:2a7da56ebd24 325 json.dump(test_suite, f, indent=2)
theotherjimmy 43:2a7da56ebd24 326
theotherjimmy 43:2a7da56ebd24 327 # List just for debug
theotherjimmy 43:2a7da56ebd24 328 if options.verbose:
theotherjimmy 43:2a7da56ebd24 329 cmd(['icetea', '--tcdir', options.tcdir, '--list'] + (['-v'] if options.verbose else []))
theotherjimmy 43:2a7da56ebd24 330
theotherjimmy 43:2a7da56ebd24 331 cmd(['icetea', '--tcdir', options.tcdir, '--suite', options.test_suite, '--clean', '--plugin_path',
theotherjimmy 43:2a7da56ebd24 332 plugins_path] + (['-v'] if options.verbose else []))
theotherjimmy 43:2a7da56ebd24 333
theotherjimmy 43:2a7da56ebd24 334 except KeyboardInterrupt as e:
theotherjimmy 43:2a7da56ebd24 335 print('\n[CTRL+c] exit')
theotherjimmy 43:2a7da56ebd24 336 except ConfigException as e:
theotherjimmy 43:2a7da56ebd24 337 # Catching ConfigException here to prevent a traceback
theotherjimmy 43:2a7da56ebd24 338 print('[ERROR] {}'.format(e))
theotherjimmy 43:2a7da56ebd24 339 except Exception as e:
theotherjimmy 43:2a7da56ebd24 340 traceback.print_exc(file=sys.stdout)
theotherjimmy 43:2a7da56ebd24 341 print('[ERROR] {}'.format(e))
theotherjimmy 43:2a7da56ebd24 342 sys.exit(1)