Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

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