Maxim nexpaq / nexpaq_dev
Committer:
nexpaq
Date:
Fri Nov 04 20:27:58 2016 +0000
Revision:
0:6c56fb4bc5f0
Moving to library for sharing updates

Who changed what in which revision?

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