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