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