Maxim nexpaq / nexpaq_dev
Committer:
nexpaq
Date:
Fri Nov 04 20:27:58 2016 +0000
Revision:
0:6c56fb4bc5f0
Moving to library for sharing updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 """
nexpaq 0:6c56fb4bc5f0 2 mbed SDK
nexpaq 0:6c56fb4bc5f0 3 Copyright (c) 2011-2015 ARM Limited
nexpaq 0:6c56fb4bc5f0 4
nexpaq 0:6c56fb4bc5f0 5 Licensed under the Apache License, Version 2.0 (the "License");
nexpaq 0:6c56fb4bc5f0 6 you may not use this file except in compliance with the License.
nexpaq 0:6c56fb4bc5f0 7 You may obtain a copy of the License at
nexpaq 0:6c56fb4bc5f0 8
nexpaq 0:6c56fb4bc5f0 9 http://www.apache.org/licenses/LICENSE-2.0
nexpaq 0:6c56fb4bc5f0 10
nexpaq 0:6c56fb4bc5f0 11 Unless required by applicable law or agreed to in writing, software
nexpaq 0:6c56fb4bc5f0 12 distributed under the License is distributed on an "AS IS" BASIS,
nexpaq 0:6c56fb4bc5f0 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 0:6c56fb4bc5f0 14 See the License for the specific language governing permissions and
nexpaq 0:6c56fb4bc5f0 15 limitations under the License.
nexpaq 0:6c56fb4bc5f0 16
nexpaq 0:6c56fb4bc5f0 17 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
nexpaq 0:6c56fb4bc5f0 18
nexpaq 0:6c56fb4bc5f0 19 """
nexpaq 0:6c56fb4bc5f0 20
nexpaq 0:6c56fb4bc5f0 21 from ioper_base import IOperTestCaseBase
nexpaq 0:6c56fb4bc5f0 22
nexpaq 0:6c56fb4bc5f0 23
nexpaq 0:6c56fb4bc5f0 24 class IOperTest_TargetID(IOperTestCaseBase):
nexpaq 0:6c56fb4bc5f0 25 """ tests related to target_id value
nexpaq 0:6c56fb4bc5f0 26 """
nexpaq 0:6c56fb4bc5f0 27
nexpaq 0:6c56fb4bc5f0 28 def __init__(self, scope=None):
nexpaq 0:6c56fb4bc5f0 29 IOperTestCaseBase.__init__(self, scope)
nexpaq 0:6c56fb4bc5f0 30 self.TARGET_ID_LEN = 24
nexpaq 0:6c56fb4bc5f0 31
nexpaq 0:6c56fb4bc5f0 32 def test_target_id_format(self, target_id, target_id_name):
nexpaq 0:6c56fb4bc5f0 33 # Expected length == 24, eg. "02400203D94B0E7724B7F3CF"
nexpaq 0:6c56fb4bc5f0 34 result = []
nexpaq 0:6c56fb4bc5f0 35 target_id_len = len(target_id) if target_id else 0
nexpaq 0:6c56fb4bc5f0 36 if target_id_len == self.TARGET_ID_LEN:
nexpaq 0:6c56fb4bc5f0 37 result.append((self.PASS, "TARGET_ID_LEN", self.scope, "%s '%s' is %d chars long " % (target_id_name, target_id, target_id_len)))
nexpaq 0:6c56fb4bc5f0 38 result.append((self.INFO, "FW_VER_STR", self.scope, "%s Version String is %s.%s.%s " % (target_id_name,
nexpaq 0:6c56fb4bc5f0 39 target_id[0:4],
nexpaq 0:6c56fb4bc5f0 40 target_id[4:8],
nexpaq 0:6c56fb4bc5f0 41 target_id[8:24],
nexpaq 0:6c56fb4bc5f0 42 )))
nexpaq 0:6c56fb4bc5f0 43 else:
nexpaq 0:6c56fb4bc5f0 44 result.append((self.ERROR, "TARGET_ID_LEN", self.scope, "%s '%s' is %d chars long. Expected %d chars" % (target_id_name, target_id, target_id_len, self.TARGET_ID_LEN)))
nexpaq 0:6c56fb4bc5f0 45 return result
nexpaq 0:6c56fb4bc5f0 46
nexpaq 0:6c56fb4bc5f0 47 def test_decode_target_id(self, target_id, target_id_name):
nexpaq 0:6c56fb4bc5f0 48 result = []
nexpaq 0:6c56fb4bc5f0 49 target_id_len = len(target_id) if target_id else 0
nexpaq 0:6c56fb4bc5f0 50 if target_id_len >= 4:
nexpaq 0:6c56fb4bc5f0 51 result.append((self.INFO, "FW_VEN_CODE", self.scope, "%s Vendor Code is '%s'" % (target_id_name, target_id[0:2])))
nexpaq 0:6c56fb4bc5f0 52 result.append((self.INFO, "FW_PLAT_CODE", self.scope, "%s Platform Code is '%s'" % (target_id_name, target_id[2:4])))
nexpaq 0:6c56fb4bc5f0 53 result.append((self.INFO, "FW_VER", self.scope, "%s Firmware Version is '%s'" % (target_id_name, target_id[4:8])))
nexpaq 0:6c56fb4bc5f0 54 result.append((self.INFO, "FW_HASH_SEC", self.scope, "%s Hash of secret is '%s'" % (target_id_name, target_id[8:24])))
nexpaq 0:6c56fb4bc5f0 55 return result
nexpaq 0:6c56fb4bc5f0 56
nexpaq 0:6c56fb4bc5f0 57 def test(self, param=None):
nexpaq 0:6c56fb4bc5f0 58 result = []
nexpaq 0:6c56fb4bc5f0 59 if param:
nexpaq 0:6c56fb4bc5f0 60 pass
nexpaq 0:6c56fb4bc5f0 61 return result
nexpaq 0:6c56fb4bc5f0 62
nexpaq 0:6c56fb4bc5f0 63
nexpaq 0:6c56fb4bc5f0 64 class IOperTest_TargetID_Basic(IOperTest_TargetID):
nexpaq 0:6c56fb4bc5f0 65 """ Basic interoperability tests checking TargetID compliance
nexpaq 0:6c56fb4bc5f0 66 """
nexpaq 0:6c56fb4bc5f0 67
nexpaq 0:6c56fb4bc5f0 68 def __init__(self, scope=None):
nexpaq 0:6c56fb4bc5f0 69 IOperTest_TargetID.__init__(self, scope)
nexpaq 0:6c56fb4bc5f0 70
nexpaq 0:6c56fb4bc5f0 71 def test(self, param=None):
nexpaq 0:6c56fb4bc5f0 72 result = []
nexpaq 0:6c56fb4bc5f0 73
nexpaq 0:6c56fb4bc5f0 74 if param:
nexpaq 0:6c56fb4bc5f0 75 result.append((self.PASS, "TARGET_ID", self.scope, "TargetID '%s' found" % param['target_id']))
nexpaq 0:6c56fb4bc5f0 76
nexpaq 0:6c56fb4bc5f0 77 # Check if target name can be decoded with mbed-ls
nexpaq 0:6c56fb4bc5f0 78 if param['platform_name']:
nexpaq 0:6c56fb4bc5f0 79 result.append((self.PASS, "TARGET_ID_DECODE", self.scope, "TargetID '%s' decoded as '%s'" % (param['target_id'][0:4], param['platform_name'])))
nexpaq 0:6c56fb4bc5f0 80 else:
nexpaq 0:6c56fb4bc5f0 81 result.append((self.ERROR, "TARGET_ID_DECODE", self.scope, "TargetID '%s'... not decoded" % (param['target_id'] if param['target_id'] else '')))
nexpaq 0:6c56fb4bc5f0 82
nexpaq 0:6c56fb4bc5f0 83 # Test for USBID and mbed.htm consistency
nexpaq 0:6c56fb4bc5f0 84 if param['target_id_mbed_htm'] == param['target_id_usb_id']:
nexpaq 0:6c56fb4bc5f0 85 result.append((self.PASS, "TARGET_ID_MATCH", self.scope, "TargetID (USBID) and TargetID (mbed.htm) match"))
nexpaq 0:6c56fb4bc5f0 86 else:
nexpaq 0:6c56fb4bc5f0 87 text = "TargetID (USBID) and TargetID (mbed.htm) don't match: '%s' != '%s'" % (param['target_id_usb_id'], param['target_id_mbed_htm'])
nexpaq 0:6c56fb4bc5f0 88 result.append((self.WARN, "TARGET_ID_MATCH", self.scope, text))
nexpaq 0:6c56fb4bc5f0 89 else:
nexpaq 0:6c56fb4bc5f0 90 result.append((self.ERROR, "TARGET_ID", self.scope, "TargetID not found"))
nexpaq 0:6c56fb4bc5f0 91 return result
nexpaq 0:6c56fb4bc5f0 92
nexpaq 0:6c56fb4bc5f0 93 class IOperTest_TargetID_MbedEnabled(IOperTest_TargetID):
nexpaq 0:6c56fb4bc5f0 94 """ Basic interoperability tests checking TargetID compliance
nexpaq 0:6c56fb4bc5f0 95 """
nexpaq 0:6c56fb4bc5f0 96
nexpaq 0:6c56fb4bc5f0 97 def __init__(self, scope=None):
nexpaq 0:6c56fb4bc5f0 98 IOperTest_TargetID.__init__(self, scope)
nexpaq 0:6c56fb4bc5f0 99
nexpaq 0:6c56fb4bc5f0 100 def test(self, param=None):
nexpaq 0:6c56fb4bc5f0 101 result = []
nexpaq 0:6c56fb4bc5f0 102
nexpaq 0:6c56fb4bc5f0 103 if param:
nexpaq 0:6c56fb4bc5f0 104 # Target ID tests:
nexpaq 0:6c56fb4bc5f0 105 result += self.test_target_id_format(param['target_id_usb_id'], "TargetId (USBID)")
nexpaq 0:6c56fb4bc5f0 106 result += self.test_target_id_format(param['target_id_mbed_htm'], "TargetId (mbed.htm)")
nexpaq 0:6c56fb4bc5f0 107
nexpaq 0:6c56fb4bc5f0 108 # Some extra info about TargetID itself
nexpaq 0:6c56fb4bc5f0 109 result += self.test_decode_target_id(param['target_id_usb_id'], "TargetId (USBID)")
nexpaq 0:6c56fb4bc5f0 110 result += self.test_decode_target_id(param['target_id_mbed_htm'], "TargetId (mbed.htm)")
nexpaq 0:6c56fb4bc5f0 111 return result