Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Nov 11 20:59:50 2016 +0000
Revision:
0:5c4d7b2438d3
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:5c4d7b2438d3 1 #!/usr/bin/env python2
switches 0:5c4d7b2438d3 2 """
switches 0:5c4d7b2438d3 3 mbed SDK
switches 0:5c4d7b2438d3 4 Copyright (c) 2011-2015 ARM Limited
switches 0:5c4d7b2438d3 5
switches 0:5c4d7b2438d3 6 Licensed under the Apache License, Version 2.0 (the "License");
switches 0:5c4d7b2438d3 7 you may not use this file except in compliance with the License.
switches 0:5c4d7b2438d3 8 You may obtain a copy of the License at
switches 0:5c4d7b2438d3 9
switches 0:5c4d7b2438d3 10 http://www.apache.org/licenses/LICENSE-2.0
switches 0:5c4d7b2438d3 11
switches 0:5c4d7b2438d3 12 Unless required by applicable law or agreed to in writing, software
switches 0:5c4d7b2438d3 13 distributed under the License is distributed on an "AS IS" BASIS,
switches 0:5c4d7b2438d3 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
switches 0:5c4d7b2438d3 15 See the License for the specific language governing permissions and
switches 0:5c4d7b2438d3 16 limitations under the License.
switches 0:5c4d7b2438d3 17
switches 0:5c4d7b2438d3 18 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
switches 0:5c4d7b2438d3 19
switches 0:5c4d7b2438d3 20 """
switches 0:5c4d7b2438d3 21
switches 0:5c4d7b2438d3 22 import sys
switches 0:5c4d7b2438d3 23 import mbed_lstools
switches 0:5c4d7b2438d3 24 from prettytable import PrettyTable
switches 0:5c4d7b2438d3 25
switches 0:5c4d7b2438d3 26 try:
switches 0:5c4d7b2438d3 27 from colorama import init
switches 0:5c4d7b2438d3 28 except:
switches 0:5c4d7b2438d3 29 pass
switches 0:5c4d7b2438d3 30
switches 0:5c4d7b2438d3 31 COLORAMA = 'colorama' in sys.modules
switches 0:5c4d7b2438d3 32
switches 0:5c4d7b2438d3 33 from ioper_base import IOperTestCaseBase
switches 0:5c4d7b2438d3 34 from ioper_test_fs import IOperTest_FileStructure_Basic
switches 0:5c4d7b2438d3 35 from ioper_test_fs import IOperTest_FileStructure_MbedEnabled
switches 0:5c4d7b2438d3 36 from ioper_test_target_id import IOperTest_TargetID_Basic
switches 0:5c4d7b2438d3 37 from ioper_test_target_id import IOperTest_TargetID_MbedEnabled
switches 0:5c4d7b2438d3 38
switches 0:5c4d7b2438d3 39
switches 0:5c4d7b2438d3 40 TEST_LIST = [IOperTest_TargetID_Basic('basic'),
switches 0:5c4d7b2438d3 41 IOperTest_TargetID_MbedEnabled('mbed-enabled'),
switches 0:5c4d7b2438d3 42 IOperTest_FileStructure_Basic('basic'),
switches 0:5c4d7b2438d3 43 IOperTest_FileStructure_MbedEnabled('mbed-enabled'),
switches 0:5c4d7b2438d3 44 IOperTestCaseBase('all'), # Dummy used to add 'all' option
switches 0:5c4d7b2438d3 45 ]
switches 0:5c4d7b2438d3 46
switches 0:5c4d7b2438d3 47
switches 0:5c4d7b2438d3 48 class IOperTestRunner():
switches 0:5c4d7b2438d3 49 """ Calls all i/face interoperability tests
switches 0:5c4d7b2438d3 50 """
switches 0:5c4d7b2438d3 51
switches 0:5c4d7b2438d3 52 def __init__(self, scope=None):
switches 0:5c4d7b2438d3 53 """ Test scope:
switches 0:5c4d7b2438d3 54 'pedantic' - all
switches 0:5c4d7b2438d3 55 'mbed-enabled' - let's try to check if this device is mbed-enabled
switches 0:5c4d7b2438d3 56 'basic' - just simple, passive tests (no device flashing)
switches 0:5c4d7b2438d3 57 """
switches 0:5c4d7b2438d3 58 self.requested_scope = scope # Test scope given by user
switches 0:5c4d7b2438d3 59 self.raw_test_results = {} # Raw test results, can be used by exporters: { Platform: [test results]}
switches 0:5c4d7b2438d3 60
switches 0:5c4d7b2438d3 61 # Test scope definitions
switches 0:5c4d7b2438d3 62 self.SCOPE_BASIC = 'basic' # Basic tests, sanity checks
switches 0:5c4d7b2438d3 63 self.SCOPE_MBED_ENABLED = 'mbed-enabled' # Let's try to check if this device is mbed-enabled
switches 0:5c4d7b2438d3 64 self.SCOPE_PEDANTIC = 'pedantic' # Extensive tests
switches 0:5c4d7b2438d3 65 self.SCOPE_ALL = 'all' # All tests, equal to highest scope level
switches 0:5c4d7b2438d3 66
switches 0:5c4d7b2438d3 67 # This structure will help us sort test scopes so we can include them
switches 0:5c4d7b2438d3 68 # e.g. pedantic also includes basic and mbed-enabled tests
switches 0:5c4d7b2438d3 69 self.scopes = {self.SCOPE_BASIC : 0,
switches 0:5c4d7b2438d3 70 self.SCOPE_MBED_ENABLED : 1,
switches 0:5c4d7b2438d3 71 self.SCOPE_PEDANTIC : 2,
switches 0:5c4d7b2438d3 72 self.SCOPE_ALL : 99,
switches 0:5c4d7b2438d3 73 }
switches 0:5c4d7b2438d3 74
switches 0:5c4d7b2438d3 75 if COLORAMA:
switches 0:5c4d7b2438d3 76 init() # colorama.init()
switches 0:5c4d7b2438d3 77
switches 0:5c4d7b2438d3 78 def run(self):
switches 0:5c4d7b2438d3 79 """ Run tests, calculate overall score and print test results
switches 0:5c4d7b2438d3 80 """
switches 0:5c4d7b2438d3 81 mbeds = mbed_lstools.create()
switches 0:5c4d7b2438d3 82 muts_list = mbeds.list_mbeds()
switches 0:5c4d7b2438d3 83 test_base = IOperTestCaseBase()
switches 0:5c4d7b2438d3 84
switches 0:5c4d7b2438d3 85 self.raw_test_results = {}
switches 0:5c4d7b2438d3 86 for i, mut in enumerate(muts_list):
switches 0:5c4d7b2438d3 87 result = []
switches 0:5c4d7b2438d3 88 self.raw_test_results[mut['platform_name']] = []
switches 0:5c4d7b2438d3 89
switches 0:5c4d7b2438d3 90 print "MBEDLS: Detected %s, port: %s, mounted: %s"% (mut['platform_name'],
switches 0:5c4d7b2438d3 91 mut['serial_port'],
switches 0:5c4d7b2438d3 92 mut['mount_point'])
switches 0:5c4d7b2438d3 93 print "Running interoperability test suite, scope '%s'" % (self.requested_scope)
switches 0:5c4d7b2438d3 94 for test_case in TEST_LIST:
switches 0:5c4d7b2438d3 95 if self.scopes[self.requested_scope] >= self.scopes[test_case.scope]:
switches 0:5c4d7b2438d3 96 res = test_case.test(param=mut)
switches 0:5c4d7b2438d3 97 result.extend(res)
switches 0:5c4d7b2438d3 98 self.raw_test_results[mut['platform_name']].extend(res)
switches 0:5c4d7b2438d3 99
switches 0:5c4d7b2438d3 100 columns = ['Platform', 'Test Case', 'Result', 'Scope', 'Description']
switches 0:5c4d7b2438d3 101 pt = PrettyTable(columns)
switches 0:5c4d7b2438d3 102 for col in columns:
switches 0:5c4d7b2438d3 103 pt.align[col] = 'l'
switches 0:5c4d7b2438d3 104
switches 0:5c4d7b2438d3 105 for tr in result:
switches 0:5c4d7b2438d3 106 severity, tr_name, tr_scope, text = tr
switches 0:5c4d7b2438d3 107 tr = (test_base.COLOR(severity, mut['platform_name']),
switches 0:5c4d7b2438d3 108 test_base.COLOR(severity, tr_name),
switches 0:5c4d7b2438d3 109 test_base.COLOR(severity, severity),
switches 0:5c4d7b2438d3 110 test_base.COLOR(severity, tr_scope),
switches 0:5c4d7b2438d3 111 test_base.COLOR(severity, text))
switches 0:5c4d7b2438d3 112 pt.add_row(list(tr))
switches 0:5c4d7b2438d3 113 print pt.get_string(border=True, sortby='Result')
switches 0:5c4d7b2438d3 114 if i + 1 < len(muts_list):
switches 0:5c4d7b2438d3 115 print
switches 0:5c4d7b2438d3 116 return self.raw_test_results
switches 0:5c4d7b2438d3 117
switches 0:5c4d7b2438d3 118 def get_available_oper_test_scopes():
switches 0:5c4d7b2438d3 119 """ Get list of available test scopes
switches 0:5c4d7b2438d3 120 """
switches 0:5c4d7b2438d3 121 scopes = set()
switches 0:5c4d7b2438d3 122 for oper_test in TEST_LIST:
switches 0:5c4d7b2438d3 123 if oper_test.scope is not None:
switches 0:5c4d7b2438d3 124 scopes.add(oper_test.scope)
switches 0:5c4d7b2438d3 125 return list(scopes)