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