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