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

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?

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