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