Marco Zecchini
/
Example_RTOS
Rtos API example
mbed-os/tools/compliance/ioper_base.py@0:9fca2b23d0ba, 2019-02-23 (annotated)
- Committer:
- marcozecchini
- Date:
- Sat Feb 23 12:13:36 2019 +0000
- Revision:
- 0:9fca2b23d0ba
final commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcozecchini | 0:9fca2b23d0ba | 1 | """ |
marcozecchini | 0:9fca2b23d0ba | 2 | mbed SDK |
marcozecchini | 0:9fca2b23d0ba | 3 | Copyright (c) 2011-2015 ARM Limited |
marcozecchini | 0:9fca2b23d0ba | 4 | |
marcozecchini | 0:9fca2b23d0ba | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
marcozecchini | 0:9fca2b23d0ba | 6 | you may not use this file except in compliance with the License. |
marcozecchini | 0:9fca2b23d0ba | 7 | You may obtain a copy of the License at |
marcozecchini | 0:9fca2b23d0ba | 8 | |
marcozecchini | 0:9fca2b23d0ba | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
marcozecchini | 0:9fca2b23d0ba | 10 | |
marcozecchini | 0:9fca2b23d0ba | 11 | Unless required by applicable law or agreed to in writing, software |
marcozecchini | 0:9fca2b23d0ba | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
marcozecchini | 0:9fca2b23d0ba | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
marcozecchini | 0:9fca2b23d0ba | 14 | See the License for the specific language governing permissions and |
marcozecchini | 0:9fca2b23d0ba | 15 | limitations under the License. |
marcozecchini | 0:9fca2b23d0ba | 16 | |
marcozecchini | 0:9fca2b23d0ba | 17 | Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com> |
marcozecchini | 0:9fca2b23d0ba | 18 | |
marcozecchini | 0:9fca2b23d0ba | 19 | """ |
marcozecchini | 0:9fca2b23d0ba | 20 | |
marcozecchini | 0:9fca2b23d0ba | 21 | import sys |
marcozecchini | 0:9fca2b23d0ba | 22 | |
marcozecchini | 0:9fca2b23d0ba | 23 | try: |
marcozecchini | 0:9fca2b23d0ba | 24 | from colorama import Fore |
marcozecchini | 0:9fca2b23d0ba | 25 | except: |
marcozecchini | 0:9fca2b23d0ba | 26 | pass |
marcozecchini | 0:9fca2b23d0ba | 27 | |
marcozecchini | 0:9fca2b23d0ba | 28 | COLORAMA = 'colorama' in sys.modules |
marcozecchini | 0:9fca2b23d0ba | 29 | |
marcozecchini | 0:9fca2b23d0ba | 30 | |
marcozecchini | 0:9fca2b23d0ba | 31 | class IOperTestCaseBase(): |
marcozecchini | 0:9fca2b23d0ba | 32 | """ Interoperability test case base class |
marcozecchini | 0:9fca2b23d0ba | 33 | @return list of tuple (severity, Description) |
marcozecchini | 0:9fca2b23d0ba | 34 | Example: (result.append((IOperTestSeverity.INFO, "")) |
marcozecchini | 0:9fca2b23d0ba | 35 | """ |
marcozecchini | 0:9fca2b23d0ba | 36 | |
marcozecchini | 0:9fca2b23d0ba | 37 | def __init__(self, scope=None): |
marcozecchini | 0:9fca2b23d0ba | 38 | self.PASS = 'PASS' |
marcozecchini | 0:9fca2b23d0ba | 39 | self.INFO = 'INFO' |
marcozecchini | 0:9fca2b23d0ba | 40 | self.ERROR = 'ERROR' |
marcozecchini | 0:9fca2b23d0ba | 41 | self.WARN = 'WARN' |
marcozecchini | 0:9fca2b23d0ba | 42 | |
marcozecchini | 0:9fca2b23d0ba | 43 | self.scope = scope # Default test scope (basic, pedantic, mbed-enabled etc...) |
marcozecchini | 0:9fca2b23d0ba | 44 | |
marcozecchini | 0:9fca2b23d0ba | 45 | def test(self, param=None): |
marcozecchini | 0:9fca2b23d0ba | 46 | result = [] |
marcozecchini | 0:9fca2b23d0ba | 47 | return result |
marcozecchini | 0:9fca2b23d0ba | 48 | |
marcozecchini | 0:9fca2b23d0ba | 49 | def RED(self, text): |
marcozecchini | 0:9fca2b23d0ba | 50 | return self.color_text(text, color=Fore.RED, delim=Fore.RESET) if COLORAMA else text |
marcozecchini | 0:9fca2b23d0ba | 51 | |
marcozecchini | 0:9fca2b23d0ba | 52 | def GREEN(self, text): |
marcozecchini | 0:9fca2b23d0ba | 53 | return self.color_text(text, color=Fore.GREEN, delim=Fore.RESET) if COLORAMA else text |
marcozecchini | 0:9fca2b23d0ba | 54 | |
marcozecchini | 0:9fca2b23d0ba | 55 | def YELLOW(self, text): |
marcozecchini | 0:9fca2b23d0ba | 56 | return self.color_text(text, color=Fore.YELLOW, delim=Fore.RESET) if COLORAMA else text |
marcozecchini | 0:9fca2b23d0ba | 57 | |
marcozecchini | 0:9fca2b23d0ba | 58 | def color_text(self, text, color='', delim=''): |
marcozecchini | 0:9fca2b23d0ba | 59 | return color + text + color + delim |
marcozecchini | 0:9fca2b23d0ba | 60 | |
marcozecchini | 0:9fca2b23d0ba | 61 | def COLOR(self, severity, text): |
marcozecchini | 0:9fca2b23d0ba | 62 | colors = { |
marcozecchini | 0:9fca2b23d0ba | 63 | self.PASS : self.GREEN, |
marcozecchini | 0:9fca2b23d0ba | 64 | self.ERROR : self.RED, |
marcozecchini | 0:9fca2b23d0ba | 65 | self.WARN : self.YELLOW |
marcozecchini | 0:9fca2b23d0ba | 66 | } |
marcozecchini | 0:9fca2b23d0ba | 67 | if severity in colors: |
marcozecchini | 0:9fca2b23d0ba | 68 | return colors[severity](text) |
marcozecchini | 0:9fca2b23d0ba | 69 | return text |