dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
nexpaq
Date:
Sat Sep 17 16:32:05 2016 +0000
Revision:
1:55a6170b404f
checking in for sharing

Who changed what in which revision?

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