Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:5c4d7b2438d3 1 #!/usr/bin/env python2
switches 0:5c4d7b2438d3 2
switches 0:5c4d7b2438d3 3 """
switches 0:5c4d7b2438d3 4 mbed SDK
switches 0:5c4d7b2438d3 5 Copyright (c) 2011-2014 ARM Limited
switches 0:5c4d7b2438d3 6
switches 0:5c4d7b2438d3 7 Licensed under the Apache License, Version 2.0 (the "License");
switches 0:5c4d7b2438d3 8 you may not use this file except in compliance with the License.
switches 0:5c4d7b2438d3 9 You may obtain a copy of the License at
switches 0:5c4d7b2438d3 10
switches 0:5c4d7b2438d3 11 http://www.apache.org/licenses/LICENSE-2.0
switches 0:5c4d7b2438d3 12
switches 0:5c4d7b2438d3 13 Unless required by applicable law or agreed to in writing, software
switches 0:5c4d7b2438d3 14 distributed under the License is distributed on an "AS IS" BASIS,
switches 0:5c4d7b2438d3 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
switches 0:5c4d7b2438d3 16 See the License for the specific language governing permissions and
switches 0:5c4d7b2438d3 17 limitations under the License.
switches 0:5c4d7b2438d3 18
switches 0:5c4d7b2438d3 19 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
switches 0:5c4d7b2438d3 20 """
switches 0:5c4d7b2438d3 21
switches 0:5c4d7b2438d3 22 """
switches 0:5c4d7b2438d3 23 File format example: test_spec.json:
switches 0:5c4d7b2438d3 24 {
switches 0:5c4d7b2438d3 25 "targets": {
switches 0:5c4d7b2438d3 26 "KL46Z": ["ARM", "GCC_ARM"],
switches 0:5c4d7b2438d3 27 "LPC1768": ["ARM", "GCC_ARM", "GCC_CR", "IAR"],
switches 0:5c4d7b2438d3 28 "LPC11U24": ["uARM"],
switches 0:5c4d7b2438d3 29 "NRF51822": ["ARM"]
switches 0:5c4d7b2438d3 30 }
switches 0:5c4d7b2438d3 31 }
switches 0:5c4d7b2438d3 32
switches 0:5c4d7b2438d3 33 File format example: muts_all.json:
switches 0:5c4d7b2438d3 34 {
switches 0:5c4d7b2438d3 35 "1" : {"mcu": "LPC1768",
switches 0:5c4d7b2438d3 36 "port":"COM4",
switches 0:5c4d7b2438d3 37 "disk":"J:\\",
switches 0:5c4d7b2438d3 38 "peripherals": ["TMP102", "digital_loop", "port_loop", "analog_loop", "SD"]
switches 0:5c4d7b2438d3 39 },
switches 0:5c4d7b2438d3 40
switches 0:5c4d7b2438d3 41 "2" : {"mcu": "KL25Z",
switches 0:5c4d7b2438d3 42 "port":"COM7",
switches 0:5c4d7b2438d3 43 "disk":"G:\\",
switches 0:5c4d7b2438d3 44 "peripherals": ["digital_loop", "port_loop", "analog_loop"]
switches 0:5c4d7b2438d3 45 }
switches 0:5c4d7b2438d3 46 }
switches 0:5c4d7b2438d3 47 """
switches 0:5c4d7b2438d3 48
switches 0:5c4d7b2438d3 49
switches 0:5c4d7b2438d3 50 # Be sure that the tools directory is in the search path
switches 0:5c4d7b2438d3 51 import sys
switches 0:5c4d7b2438d3 52 from os.path import join, abspath, dirname
switches 0:5c4d7b2438d3 53
switches 0:5c4d7b2438d3 54 ROOT = abspath(join(dirname(__file__), ".."))
switches 0:5c4d7b2438d3 55 sys.path.insert(0, ROOT)
switches 0:5c4d7b2438d3 56
switches 0:5c4d7b2438d3 57
switches 0:5c4d7b2438d3 58 # Check: Extra modules which are required by core test suite
switches 0:5c4d7b2438d3 59 from tools.utils import check_required_modules
switches 0:5c4d7b2438d3 60 check_required_modules(['prettytable', 'serial'])
switches 0:5c4d7b2438d3 61
switches 0:5c4d7b2438d3 62 # Imports related to mbed build api
switches 0:5c4d7b2438d3 63 from tools.build_api import mcu_toolchain_matrix
switches 0:5c4d7b2438d3 64
switches 0:5c4d7b2438d3 65 # Imports from TEST API
switches 0:5c4d7b2438d3 66 from tools.test_api import SingleTestRunner
switches 0:5c4d7b2438d3 67 from tools.test_api import singletest_in_cli_mode
switches 0:5c4d7b2438d3 68 from tools.test_api import detect_database_verbose
switches 0:5c4d7b2438d3 69 from tools.test_api import get_json_data_from_file
switches 0:5c4d7b2438d3 70 from tools.test_api import get_avail_tests_summary_table
switches 0:5c4d7b2438d3 71 from tools.test_api import get_default_test_options_parser
switches 0:5c4d7b2438d3 72 from tools.test_api import print_muts_configuration_from_json
switches 0:5c4d7b2438d3 73 from tools.test_api import print_test_configuration_from_json
switches 0:5c4d7b2438d3 74 from tools.test_api import get_autodetected_MUTS_list
switches 0:5c4d7b2438d3 75 from tools.test_api import get_autodetected_TEST_SPEC
switches 0:5c4d7b2438d3 76 from tools.test_api import get_module_avail
switches 0:5c4d7b2438d3 77 from tools.test_exporters import ReportExporter, ResultExporterType
switches 0:5c4d7b2438d3 78
switches 0:5c4d7b2438d3 79
switches 0:5c4d7b2438d3 80 # Importing extra modules which can be not installed but if available they can extend test suite functionality
switches 0:5c4d7b2438d3 81 try:
switches 0:5c4d7b2438d3 82 import mbed_lstools
switches 0:5c4d7b2438d3 83 from tools.compliance.ioper_runner import IOperTestRunner
switches 0:5c4d7b2438d3 84 from tools.compliance.ioper_runner import get_available_oper_test_scopes
switches 0:5c4d7b2438d3 85 except:
switches 0:5c4d7b2438d3 86 pass
switches 0:5c4d7b2438d3 87
switches 0:5c4d7b2438d3 88 def get_version():
switches 0:5c4d7b2438d3 89 """ Returns test script version
switches 0:5c4d7b2438d3 90 """
switches 0:5c4d7b2438d3 91 single_test_version_major = 1
switches 0:5c4d7b2438d3 92 single_test_version_minor = 5
switches 0:5c4d7b2438d3 93 return (single_test_version_major, single_test_version_minor)
switches 0:5c4d7b2438d3 94
switches 0:5c4d7b2438d3 95
switches 0:5c4d7b2438d3 96 if __name__ == '__main__':
switches 0:5c4d7b2438d3 97 # Command line options
switches 0:5c4d7b2438d3 98 parser = get_default_test_options_parser()
switches 0:5c4d7b2438d3 99
switches 0:5c4d7b2438d3 100 parser.description = """This script allows you to run mbed defined test cases for particular MCU(s) and corresponding toolchain(s)."""
switches 0:5c4d7b2438d3 101 parser.epilog = """Example: singletest.py -i test_spec.json -M muts_all.json"""
switches 0:5c4d7b2438d3 102
switches 0:5c4d7b2438d3 103 opts = parser.parse_args()
switches 0:5c4d7b2438d3 104
switches 0:5c4d7b2438d3 105 # Print scrip version
switches 0:5c4d7b2438d3 106 if opts.version:
switches 0:5c4d7b2438d3 107 print parser.description
switches 0:5c4d7b2438d3 108 print parser.epilog
switches 0:5c4d7b2438d3 109 print "Version %d.%d"% get_version()
switches 0:5c4d7b2438d3 110 exit(0)
switches 0:5c4d7b2438d3 111
switches 0:5c4d7b2438d3 112 if opts.db_url and opts.verbose_test_configuration_only:
switches 0:5c4d7b2438d3 113 detect_database_verbose(opts.db_url)
switches 0:5c4d7b2438d3 114 exit(0)
switches 0:5c4d7b2438d3 115
switches 0:5c4d7b2438d3 116 # Print summary / information about automation test status
switches 0:5c4d7b2438d3 117 if opts.test_automation_report:
switches 0:5c4d7b2438d3 118 print get_avail_tests_summary_table(platform_filter=opts.general_filter_regex)
switches 0:5c4d7b2438d3 119 exit(0)
switches 0:5c4d7b2438d3 120
switches 0:5c4d7b2438d3 121 # Print summary / information about automation test status
switches 0:5c4d7b2438d3 122 if opts.test_case_report:
switches 0:5c4d7b2438d3 123 test_case_report_cols = ['id',
switches 0:5c4d7b2438d3 124 'automated',
switches 0:5c4d7b2438d3 125 'description',
switches 0:5c4d7b2438d3 126 'peripherals',
switches 0:5c4d7b2438d3 127 'host_test',
switches 0:5c4d7b2438d3 128 'duration',
switches 0:5c4d7b2438d3 129 'source_dir']
switches 0:5c4d7b2438d3 130 print get_avail_tests_summary_table(cols=test_case_report_cols,
switches 0:5c4d7b2438d3 131 result_summary=False,
switches 0:5c4d7b2438d3 132 join_delim='\n',
switches 0:5c4d7b2438d3 133 platform_filter=opts.general_filter_regex)
switches 0:5c4d7b2438d3 134 exit(0)
switches 0:5c4d7b2438d3 135
switches 0:5c4d7b2438d3 136 # Only prints matrix of supported toolchains
switches 0:5c4d7b2438d3 137 if opts.supported_toolchains:
switches 0:5c4d7b2438d3 138 print mcu_toolchain_matrix(platform_filter=opts.general_filter_regex)
switches 0:5c4d7b2438d3 139 exit(0)
switches 0:5c4d7b2438d3 140
switches 0:5c4d7b2438d3 141 test_spec = None
switches 0:5c4d7b2438d3 142 MUTs = None
switches 0:5c4d7b2438d3 143
switches 0:5c4d7b2438d3 144 if hasattr(opts, 'auto_detect') and opts.auto_detect:
switches 0:5c4d7b2438d3 145 # If auto_detect attribute is present, we assume other auto-detection
switches 0:5c4d7b2438d3 146 # parameters like 'toolchains_filter' are also set.
switches 0:5c4d7b2438d3 147 print "MBEDLS: Detecting connected mbed-enabled devices... "
switches 0:5c4d7b2438d3 148
switches 0:5c4d7b2438d3 149 MUTs = get_autodetected_MUTS_list()
switches 0:5c4d7b2438d3 150
switches 0:5c4d7b2438d3 151 for mut in MUTs.values():
switches 0:5c4d7b2438d3 152 print "MBEDLS: Detected %s, port: %s, mounted: %s"% (mut['mcu_unique'] if 'mcu_unique' in mut else mut['mcu'],
switches 0:5c4d7b2438d3 153 mut['port'],
switches 0:5c4d7b2438d3 154 mut['disk'])
switches 0:5c4d7b2438d3 155
switches 0:5c4d7b2438d3 156 # Set up parameters for test specification filter function (we need to set toolchains per target here)
switches 0:5c4d7b2438d3 157 use_default_toolchain = 'default' in opts.toolchains_filter if opts.toolchains_filter is not None else True
switches 0:5c4d7b2438d3 158 use_supported_toolchains = 'all' in opts.toolchains_filter if opts.toolchains_filter is not None else False
switches 0:5c4d7b2438d3 159 toolchain_filter = opts.toolchains_filter
switches 0:5c4d7b2438d3 160 platform_name_filter = opts.general_filter_regex if opts.general_filter_regex is not None else opts.general_filter_regex
switches 0:5c4d7b2438d3 161 # Test specification with information about each target and associated toolchain
switches 0:5c4d7b2438d3 162 test_spec = get_autodetected_TEST_SPEC(MUTs.values(),
switches 0:5c4d7b2438d3 163 use_default_toolchain=use_default_toolchain,
switches 0:5c4d7b2438d3 164 use_supported_toolchains=use_supported_toolchains,
switches 0:5c4d7b2438d3 165 toolchain_filter=toolchain_filter,
switches 0:5c4d7b2438d3 166 platform_name_filter=platform_name_filter)
switches 0:5c4d7b2438d3 167 else:
switches 0:5c4d7b2438d3 168 # Open file with test specification
switches 0:5c4d7b2438d3 169 # test_spec_filename tells script which targets and their toolchain(s)
switches 0:5c4d7b2438d3 170 # should be covered by the test scenario
switches 0:5c4d7b2438d3 171 opts.auto_detect = False
switches 0:5c4d7b2438d3 172 test_spec = get_json_data_from_file(opts.test_spec_filename) if opts.test_spec_filename else None
switches 0:5c4d7b2438d3 173 if test_spec is None:
switches 0:5c4d7b2438d3 174 if not opts.test_spec_filename:
switches 0:5c4d7b2438d3 175 parser.print_help()
switches 0:5c4d7b2438d3 176 exit(-1)
switches 0:5c4d7b2438d3 177
switches 0:5c4d7b2438d3 178 # Get extra MUTs if applicable
switches 0:5c4d7b2438d3 179 MUTs = get_json_data_from_file(opts.muts_spec_filename) if opts.muts_spec_filename else None
switches 0:5c4d7b2438d3 180
switches 0:5c4d7b2438d3 181 if MUTs is None:
switches 0:5c4d7b2438d3 182 if not opts.muts_spec_filename:
switches 0:5c4d7b2438d3 183 parser.print_help()
switches 0:5c4d7b2438d3 184 exit(-1)
switches 0:5c4d7b2438d3 185
switches 0:5c4d7b2438d3 186 if opts.verbose_test_configuration_only:
switches 0:5c4d7b2438d3 187 print "MUTs configuration in %s:" % ('auto-detected' if opts.auto_detect else opts.muts_spec_filename)
switches 0:5c4d7b2438d3 188 if MUTs:
switches 0:5c4d7b2438d3 189 print print_muts_configuration_from_json(MUTs, platform_filter=opts.general_filter_regex)
switches 0:5c4d7b2438d3 190 print
switches 0:5c4d7b2438d3 191 print "Test specification in %s:" % ('auto-detected' if opts.auto_detect else opts.test_spec_filename)
switches 0:5c4d7b2438d3 192 if test_spec:
switches 0:5c4d7b2438d3 193 print print_test_configuration_from_json(test_spec)
switches 0:5c4d7b2438d3 194 exit(0)
switches 0:5c4d7b2438d3 195
switches 0:5c4d7b2438d3 196 if get_module_avail('mbed_lstools'):
switches 0:5c4d7b2438d3 197 if opts.operability_checks:
switches 0:5c4d7b2438d3 198 # Check if test scope is valid and run tests
switches 0:5c4d7b2438d3 199 test_scope = get_available_oper_test_scopes()
switches 0:5c4d7b2438d3 200 if opts.operability_checks in test_scope:
switches 0:5c4d7b2438d3 201 tests = IOperTestRunner(scope=opts.operability_checks)
switches 0:5c4d7b2438d3 202 test_results = tests.run()
switches 0:5c4d7b2438d3 203
switches 0:5c4d7b2438d3 204 # Export results in form of JUnit XML report to separate file
switches 0:5c4d7b2438d3 205 if opts.report_junit_file_name:
switches 0:5c4d7b2438d3 206 report_exporter = ReportExporter(ResultExporterType.JUNIT_OPER)
switches 0:5c4d7b2438d3 207 report_exporter.report_to_file(test_results, opts.report_junit_file_name)
switches 0:5c4d7b2438d3 208 else:
switches 0:5c4d7b2438d3 209 print "Unknown interoperability test scope name: '%s'" % (opts.operability_checks)
switches 0:5c4d7b2438d3 210 print "Available test scopes: %s" % (','.join(["'%s'" % n for n in test_scope]))
switches 0:5c4d7b2438d3 211
switches 0:5c4d7b2438d3 212 exit(0)
switches 0:5c4d7b2438d3 213
switches 0:5c4d7b2438d3 214 # Verbose test specification and MUTs configuration
switches 0:5c4d7b2438d3 215 if MUTs and opts.verbose:
switches 0:5c4d7b2438d3 216 print print_muts_configuration_from_json(MUTs)
switches 0:5c4d7b2438d3 217 if test_spec and opts.verbose:
switches 0:5c4d7b2438d3 218 print print_test_configuration_from_json(test_spec)
switches 0:5c4d7b2438d3 219
switches 0:5c4d7b2438d3 220 if opts.only_build_tests:
switches 0:5c4d7b2438d3 221 # We are skipping testing phase, and suppress summary
switches 0:5c4d7b2438d3 222 opts.suppress_summary = True
switches 0:5c4d7b2438d3 223
switches 0:5c4d7b2438d3 224 single_test = SingleTestRunner(_global_loops_count=opts.test_global_loops_value,
switches 0:5c4d7b2438d3 225 _test_loops_list=opts.test_loops_list,
switches 0:5c4d7b2438d3 226 _muts=MUTs,
switches 0:5c4d7b2438d3 227 _clean=opts.clean,
switches 0:5c4d7b2438d3 228 _parser=parser,
switches 0:5c4d7b2438d3 229 _opts=opts,
switches 0:5c4d7b2438d3 230 _opts_db_url=opts.db_url,
switches 0:5c4d7b2438d3 231 _opts_log_file_name=opts.log_file_name,
switches 0:5c4d7b2438d3 232 _opts_report_html_file_name=opts.report_html_file_name,
switches 0:5c4d7b2438d3 233 _opts_report_junit_file_name=opts.report_junit_file_name,
switches 0:5c4d7b2438d3 234 _opts_report_build_file_name=opts.report_build_file_name,
switches 0:5c4d7b2438d3 235 _opts_report_text_file_name=opts.report_text_file_name,
switches 0:5c4d7b2438d3 236 _test_spec=test_spec,
switches 0:5c4d7b2438d3 237 _opts_goanna_for_mbed_sdk=opts.goanna_for_mbed_sdk,
switches 0:5c4d7b2438d3 238 _opts_goanna_for_tests=opts.goanna_for_tests,
switches 0:5c4d7b2438d3 239 _opts_shuffle_test_order=opts.shuffle_test_order,
switches 0:5c4d7b2438d3 240 _opts_shuffle_test_seed=opts.shuffle_test_seed,
switches 0:5c4d7b2438d3 241 _opts_test_by_names=opts.test_by_names,
switches 0:5c4d7b2438d3 242 _opts_peripheral_by_names=opts.peripheral_by_names,
switches 0:5c4d7b2438d3 243 _opts_test_only_peripheral=opts.test_only_peripheral,
switches 0:5c4d7b2438d3 244 _opts_test_only_common=opts.test_only_common,
switches 0:5c4d7b2438d3 245 _opts_verbose_skipped_tests=opts.verbose_skipped_tests,
switches 0:5c4d7b2438d3 246 _opts_verbose_test_result_only=opts.verbose_test_result_only,
switches 0:5c4d7b2438d3 247 _opts_verbose=opts.verbose,
switches 0:5c4d7b2438d3 248 _opts_firmware_global_name=opts.firmware_global_name,
switches 0:5c4d7b2438d3 249 _opts_only_build_tests=opts.only_build_tests,
switches 0:5c4d7b2438d3 250 _opts_parallel_test_exec=opts.parallel_test_exec,
switches 0:5c4d7b2438d3 251 _opts_suppress_summary=opts.suppress_summary,
switches 0:5c4d7b2438d3 252 _opts_test_x_toolchain_summary=opts.test_x_toolchain_summary,
switches 0:5c4d7b2438d3 253 _opts_copy_method=opts.copy_method,
switches 0:5c4d7b2438d3 254 _opts_mut_reset_type=opts.mut_reset_type,
switches 0:5c4d7b2438d3 255 _opts_jobs=opts.jobs,
switches 0:5c4d7b2438d3 256 _opts_waterfall_test=opts.waterfall_test,
switches 0:5c4d7b2438d3 257 _opts_consolidate_waterfall_test=opts.consolidate_waterfall_test,
switches 0:5c4d7b2438d3 258 _opts_extend_test_timeout=opts.extend_test_timeout,
switches 0:5c4d7b2438d3 259 _opts_auto_detect=opts.auto_detect)
switches 0:5c4d7b2438d3 260
switches 0:5c4d7b2438d3 261 # Runs test suite in CLI mode
switches 0:5c4d7b2438d3 262 if (singletest_in_cli_mode(single_test)):
switches 0:5c4d7b2438d3 263 exit(0)
switches 0:5c4d7b2438d3 264 else:
switches 0:5c4d7b2438d3 265 exit(-1)