![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/UNITTESTS/unit_test/options.py@0:8fdf9a60065b, 2018-10-10 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | """ |
kadonotakashi | 0:8fdf9a60065b | 2 | Copyright (c) 2018, Arm Limited |
kadonotakashi | 0:8fdf9a60065b | 3 | SPDX-License-Identifier: Apache-2.0 |
kadonotakashi | 0:8fdf9a60065b | 4 | |
kadonotakashi | 0:8fdf9a60065b | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 6 | you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 7 | You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 8 | |
kadonotakashi | 0:8fdf9a60065b | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 10 | |
kadonotakashi | 0:8fdf9a60065b | 11 | Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 14 | See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 15 | limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 16 | |
kadonotakashi | 0:8fdf9a60065b | 17 | |
kadonotakashi | 0:8fdf9a60065b | 18 | UNIT TEST OPTIONS |
kadonotakashi | 0:8fdf9a60065b | 19 | """ |
kadonotakashi | 0:8fdf9a60065b | 20 | |
kadonotakashi | 0:8fdf9a60065b | 21 | import argparse |
kadonotakashi | 0:8fdf9a60065b | 22 | import logging |
kadonotakashi | 0:8fdf9a60065b | 23 | |
kadonotakashi | 0:8fdf9a60065b | 24 | from .settings import CMAKE_GENERATORS, MAKE_PROGRAMS, COVERAGE_ARGS |
kadonotakashi | 0:8fdf9a60065b | 25 | from .get_tools import get_make_tool |
kadonotakashi | 0:8fdf9a60065b | 26 | |
kadonotakashi | 0:8fdf9a60065b | 27 | def get_options_parser(): |
kadonotakashi | 0:8fdf9a60065b | 28 | """ |
kadonotakashi | 0:8fdf9a60065b | 29 | Create a unit test options parser. |
kadonotakashi | 0:8fdf9a60065b | 30 | |
kadonotakashi | 0:8fdf9a60065b | 31 | Returns a parser object |
kadonotakashi | 0:8fdf9a60065b | 32 | """ |
kadonotakashi | 0:8fdf9a60065b | 33 | |
kadonotakashi | 0:8fdf9a60065b | 34 | parser = argparse.ArgumentParser() |
kadonotakashi | 0:8fdf9a60065b | 35 | |
kadonotakashi | 0:8fdf9a60065b | 36 | log_group = parser.add_mutually_exclusive_group() |
kadonotakashi | 0:8fdf9a60065b | 37 | |
kadonotakashi | 0:8fdf9a60065b | 38 | log_group.add_argument("-v", |
kadonotakashi | 0:8fdf9a60065b | 39 | "--verbose", |
kadonotakashi | 0:8fdf9a60065b | 40 | help="Verbose output", |
kadonotakashi | 0:8fdf9a60065b | 41 | action="store_const", |
kadonotakashi | 0:8fdf9a60065b | 42 | const=logging.getLevelName(logging.DEBUG), |
kadonotakashi | 0:8fdf9a60065b | 43 | dest="log_level") |
kadonotakashi | 0:8fdf9a60065b | 44 | |
kadonotakashi | 0:8fdf9a60065b | 45 | log_group.add_argument("--quiet", |
kadonotakashi | 0:8fdf9a60065b | 46 | help="Quiet output", |
kadonotakashi | 0:8fdf9a60065b | 47 | action="store_const", |
kadonotakashi | 0:8fdf9a60065b | 48 | const=logging.getLevelName(logging.ERROR), |
kadonotakashi | 0:8fdf9a60065b | 49 | dest="log_level") |
kadonotakashi | 0:8fdf9a60065b | 50 | |
kadonotakashi | 0:8fdf9a60065b | 51 | parser.add_argument("--compile", |
kadonotakashi | 0:8fdf9a60065b | 52 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 53 | help="Only compile unit tests", |
kadonotakashi | 0:8fdf9a60065b | 54 | dest="compile_only") |
kadonotakashi | 0:8fdf9a60065b | 55 | |
kadonotakashi | 0:8fdf9a60065b | 56 | parser.add_argument("--run", |
kadonotakashi | 0:8fdf9a60065b | 57 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 58 | help="Only run unit tests", |
kadonotakashi | 0:8fdf9a60065b | 59 | dest="run_only") |
kadonotakashi | 0:8fdf9a60065b | 60 | |
kadonotakashi | 0:8fdf9a60065b | 61 | parser.add_argument("-c", |
kadonotakashi | 0:8fdf9a60065b | 62 | "--clean", |
kadonotakashi | 0:8fdf9a60065b | 63 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 64 | help="Clean the build directory", |
kadonotakashi | 0:8fdf9a60065b | 65 | dest="clean") |
kadonotakashi | 0:8fdf9a60065b | 66 | |
kadonotakashi | 0:8fdf9a60065b | 67 | parser.add_argument("-d", |
kadonotakashi | 0:8fdf9a60065b | 68 | "--debug", |
kadonotakashi | 0:8fdf9a60065b | 69 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 70 | help="Enable debug build", |
kadonotakashi | 0:8fdf9a60065b | 71 | dest="debug_build") |
kadonotakashi | 0:8fdf9a60065b | 72 | |
kadonotakashi | 0:8fdf9a60065b | 73 | parser.add_argument("--coverage", |
kadonotakashi | 0:8fdf9a60065b | 74 | choices=COVERAGE_ARGS, |
kadonotakashi | 0:8fdf9a60065b | 75 | help="Generate code coverage report", |
kadonotakashi | 0:8fdf9a60065b | 76 | dest="coverage") |
kadonotakashi | 0:8fdf9a60065b | 77 | |
kadonotakashi | 0:8fdf9a60065b | 78 | parser.add_argument("--include-headers", |
kadonotakashi | 0:8fdf9a60065b | 79 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 80 | help="Include headers to coverage reports, defaults to false.", |
kadonotakashi | 0:8fdf9a60065b | 81 | dest="include_headers") |
kadonotakashi | 0:8fdf9a60065b | 82 | |
kadonotakashi | 0:8fdf9a60065b | 83 | parser.add_argument("-m", |
kadonotakashi | 0:8fdf9a60065b | 84 | "--make-program", |
kadonotakashi | 0:8fdf9a60065b | 85 | default=get_make_tool(), |
kadonotakashi | 0:8fdf9a60065b | 86 | choices=MAKE_PROGRAMS, |
kadonotakashi | 0:8fdf9a60065b | 87 | help="Which make program to use", |
kadonotakashi | 0:8fdf9a60065b | 88 | dest="make_program") |
kadonotakashi | 0:8fdf9a60065b | 89 | |
kadonotakashi | 0:8fdf9a60065b | 90 | parser.add_argument("-g", |
kadonotakashi | 0:8fdf9a60065b | 91 | "--generator", |
kadonotakashi | 0:8fdf9a60065b | 92 | choices=CMAKE_GENERATORS, |
kadonotakashi | 0:8fdf9a60065b | 93 | help="Which CMake generator to use", |
kadonotakashi | 0:8fdf9a60065b | 94 | dest="cmake_generator") |
kadonotakashi | 0:8fdf9a60065b | 95 | |
kadonotakashi | 0:8fdf9a60065b | 96 | parser.add_argument("-r", |
kadonotakashi | 0:8fdf9a60065b | 97 | "--regex", |
kadonotakashi | 0:8fdf9a60065b | 98 | help="Run tests matching a regular expression", |
kadonotakashi | 0:8fdf9a60065b | 99 | dest="test_regex") |
kadonotakashi | 0:8fdf9a60065b | 100 | |
kadonotakashi | 0:8fdf9a60065b | 101 | parser.add_argument("--build", |
kadonotakashi | 0:8fdf9a60065b | 102 | default="build", |
kadonotakashi | 0:8fdf9a60065b | 103 | help="Build directory. Default: UNITTESTS/build/", |
kadonotakashi | 0:8fdf9a60065b | 104 | dest="build") |
kadonotakashi | 0:8fdf9a60065b | 105 | |
kadonotakashi | 0:8fdf9a60065b | 106 | parser.add_argument("--new", |
kadonotakashi | 0:8fdf9a60065b | 107 | action="append", |
kadonotakashi | 0:8fdf9a60065b | 108 | help="Source file from which to generate test files. E.g. rtos/Semaphore.cpp", |
kadonotakashi | 0:8fdf9a60065b | 109 | metavar="FILEPATH", |
kadonotakashi | 0:8fdf9a60065b | 110 | dest="new_files") |
kadonotakashi | 0:8fdf9a60065b | 111 | |
kadonotakashi | 0:8fdf9a60065b | 112 | return parser |
kadonotakashi | 0:8fdf9a60065b | 113 | |
kadonotakashi | 0:8fdf9a60065b | 114 | def pretty_print_test_options(options=None): |
kadonotakashi | 0:8fdf9a60065b | 115 | """ |
kadonotakashi | 0:8fdf9a60065b | 116 | Pretty print test options |
kadonotakashi | 0:8fdf9a60065b | 117 | |
kadonotakashi | 0:8fdf9a60065b | 118 | Keyword arguments: |
kadonotakashi | 0:8fdf9a60065b | 119 | options - options |
kadonotakashi | 0:8fdf9a60065b | 120 | """ |
kadonotakashi | 0:8fdf9a60065b | 121 | |
kadonotakashi | 0:8fdf9a60065b | 122 | if options is None: |
kadonotakashi | 0:8fdf9a60065b | 123 | return |
kadonotakashi | 0:8fdf9a60065b | 124 | |
kadonotakashi | 0:8fdf9a60065b | 125 | # Mode |
kadonotakashi | 0:8fdf9a60065b | 126 | logging.info(""" |
kadonotakashi | 0:8fdf9a60065b | 127 | ##################### |
kadonotakashi | 0:8fdf9a60065b | 128 | Mbed OS unit testing: |
kadonotakashi | 0:8fdf9a60065b | 129 | ##################### |
kadonotakashi | 0:8fdf9a60065b | 130 | """) |
kadonotakashi | 0:8fdf9a60065b | 131 | |
kadonotakashi | 0:8fdf9a60065b | 132 | logging.info("Steps:\n") |
kadonotakashi | 0:8fdf9a60065b | 133 | |
kadonotakashi | 0:8fdf9a60065b | 134 | logging.info(" [%s] \tPrepare build directory", "AUTO") |
kadonotakashi | 0:8fdf9a60065b | 135 | logging.info(" \t\t - Clean: %s", options.clean) |
kadonotakashi | 0:8fdf9a60065b | 136 | logging.info(" \t\t - Directory: %s\n", options.build) |
kadonotakashi | 0:8fdf9a60065b | 137 | status = "SET" if options.compile_only else "UNSET" |
kadonotakashi | 0:8fdf9a60065b | 138 | logging.info(" [%s] \tBuild unit tests", status) |
kadonotakashi | 0:8fdf9a60065b | 139 | logging.info(" \t\t - Debug: %s", options.debug_build) |
kadonotakashi | 0:8fdf9a60065b | 140 | logging.info(" \t\t - CMake generator: %s", options.cmake_generator) |
kadonotakashi | 0:8fdf9a60065b | 141 | logging.info(" \t\t - Make program: %s\n", options.make_program) |
kadonotakashi | 0:8fdf9a60065b | 142 | status = "SET" if options.run_only else "UNSET" |
kadonotakashi | 0:8fdf9a60065b | 143 | logging.info(" [%s] \tRun unit tests", status) |
kadonotakashi | 0:8fdf9a60065b | 144 | logging.info(" \t\t - Filter: %s\n", options.test_regex) |
kadonotakashi | 0:8fdf9a60065b | 145 | if options.coverage: |
kadonotakashi | 0:8fdf9a60065b | 146 | logging.info(" [%s] \tGenerate coverage reports", "SET") |
kadonotakashi | 0:8fdf9a60065b | 147 | logging.info(" \t\t - Output: %s", options.coverage) |
kadonotakashi | 0:8fdf9a60065b | 148 | logging.info(" \t\t - Include headers: %s", options.include_headers) |