Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Wed Oct 10 00:33:53 2018 +0000
Revision:
0:8fdf9a60065b
how to make mbed librry

Who changed what in which revision?

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