mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

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