Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

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