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