Skip to content

Commit 8bdd8b2

Browse files
committed
Add Sara-N host test hooks.
1 parent e398593 commit 8bdd8b2

File tree

4 files changed

+193
-0
lines changed

4 files changed

+193
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
* [ ```htrun``` new log format:](#-htrun-new-log-format)
4545
* [Log example](#log-example)
4646
* [End-to-end examples](#end-to-end-examples)
47+
* [Plugins](#plugins)
48+
* [SARA NBIOT EVK](#sara-nbiot-evk)
4749

4850
# Quickstart
4951

@@ -1009,3 +1011,30 @@ Here you can find references to modules and repositories contain examples of tes
10091011
* ```minar``` module contains [test cases](https://github.com/ARMmbed/minar/tree/master/test) written without ```utest```. Note: ```utest``` may use ```minar``` for callback scheduling and can't be use to test ```minar``` itself.
10101012
* ```mbed-drivers``` module contains [test cases](https://github.com/ARMmbed/mbed-drivers/tree/master/test) written with and without ```utest``` harness. Currently all ```mbed-drivers``` tests are using [build-in to ```htrun``` host tests](https://github.com/ARMmbed/htrun/tree/master/mbed_host_tests/host_tests).
10111013
* And finally ```sockets``` module contains [test cases](https://github.com/ARMmbed/sockets/tree/master/test) with [custom host tests](https://github.com/ARMmbed/sockets/tree/master/test/host_tests).
1014+
1015+
# Plugins
1016+
1017+
In order to work with platforms for which the hardware is still under development, and hence may not have an mbed interface chip, some "hook" files are required. Operation with these platforms is a matter for the platform development teams involved and is not, in general, supported by ARM.
1018+
1019+
## SARA NBIOT EVK
1020+
The SARA NBIOT EVK board must be connected to a Windows PC using a Segger JLink box, which is used for downloading code and resetting the board. The USB port on the EVK must also be connected to the same PC. You will also require access to some proprietary tools that can be requested from u-blox.
1021+
1022+
Once your mbed tests have been compiled, they may be executed with:
1023+
1024+
`python RunTests.py`
1025+
1026+
You will need to provide a few parameters to `RunTest.py`. An example command-line is:
1027+
1028+
`python RunTests.py ..\mbed-os-ublox-app COM1:9600`
1029+
1030+
This will run all the tests that were built in the `..\mbed-os-ublox-app` project on a device which has a UART connection on `COM1` at `9600` baud.
1031+
1032+
When you want to debug a single failing test, first run just that test binary by using the `-b` switch, e.g.:
1033+
1034+
`python RunTests.py ..\mbed-os-ublox-app COM1:9600 -b problematic_test`
1035+
1036+
You might want to make sure that you have compiled the test with the command-line switch `--profile mbed-os/tools/profiles/debug.json`.
1037+
1038+
With the correct binary on the target, you can start the target under your debugger and then invoke the PC side with a line of the form:
1039+
1040+
`mbedhtrun --skip-flashing --skip-reset -p COM1:9600`

mbed_host_tests/host_tests_plugins/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import module_reset_silabs
3838
import module_copy_stlink
3939
import module_reset_stlink
40+
import module_copy_ublox
41+
import module_reset_ublox
4042
#import module_copy_jn51xx
4143
#import module_reset_jn51xx
4244

@@ -58,6 +60,8 @@
5860
HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_stlink.load_plugin())
5961
HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_reset_stlink.load_plugin())
6062
HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_power_cycle_mbed.load_plugin())
63+
HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_reset_ublox.load_plugin())
64+
HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_ublox.load_plugin())
6165
#HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_jn51xx.load_plugin())
6266
#HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_reset_jn51xx.load_plugin())
6367

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2011-2015 ARM Limited
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
18+
"""
19+
20+
import os
21+
from host_test_plugins import HostTestPluginBase
22+
23+
24+
class HostTestPluginCopyMethod_ublox(HostTestPluginBase):
25+
26+
# Plugin interface
27+
name = 'HostTestPluginCopyMethod_ublox'
28+
type = 'CopyMethod'
29+
capabilities = ['ublox']
30+
required_parameters = ['image_path']
31+
32+
def is_os_supported(self, os_name=None):
33+
"""! In this implementation this plugin only is supporeted under Windows machines
34+
"""
35+
# If no OS name provided use host OS name
36+
if not os_name:
37+
os_name = self.mbed_os_support()
38+
39+
# This plugin only works on Windows
40+
if os_name and os_name.startswith('Windows'):
41+
return True
42+
return False
43+
44+
def setup(self, *args, **kwargs):
45+
"""! Configure plugin, this function should be called before plugin execute() method is used.
46+
"""
47+
self.FLASH_ERASE = 'FlashErase.exe'
48+
return True
49+
50+
def execute(self, capability, *args, **kwargs):
51+
"""! Executes capability by name
52+
53+
@param capability Capability name
54+
@param args Additional arguments
55+
@param kwargs Additional arguments
56+
57+
@details Each capability e.g. may directly just call some command line program or execute building pythonic function
58+
59+
@return Capability call return value
60+
"""
61+
result = False
62+
if self.check_parameters(capability, *args, **kwargs) is True:
63+
image_path = os.path.normpath(kwargs['image_path'])
64+
if capability == 'ublox':
65+
# Example:
66+
# FLASH_ERASE -c 2 -s 0xD7000 -l 0x20000 -f "binary_file.bin"
67+
cmd = [self.FLASH_ERASE,
68+
'-c',
69+
'A',
70+
'-s',
71+
'0xD7000',
72+
'-l',
73+
'0x20000',
74+
'-f', image_path
75+
]
76+
result = self.run_command(cmd)
77+
return result
78+
79+
80+
def load_plugin():
81+
""" Returns plugin available in this module
82+
"""
83+
return HostTestPluginCopyMethod_ublox()
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"""
2+
mbed SDK
3+
Copyright (c) 2011-2015 ARM Limited
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
18+
"""
19+
20+
from host_test_plugins import HostTestPluginBase
21+
22+
23+
class HostTestPluginResetMethod_ublox(HostTestPluginBase):
24+
25+
# Plugin interface
26+
name = 'HostTestPluginResetMethod_ublox'
27+
type = 'ResetMethod'
28+
capabilities = ['ublox']
29+
required_parameters = []
30+
stable = False
31+
32+
def is_os_supported(self, os_name=None):
33+
"""! In this implementation this plugin only is supporeted under Windows machines
34+
"""
35+
# If no OS name provided use host OS name
36+
if not os_name:
37+
os_name = self.mbed_os_support()
38+
39+
# This plugin only works on Windows
40+
if os_name and os_name.startswith('Windows'):
41+
return True
42+
return False
43+
44+
def setup(self, *args, **kwargs):
45+
"""! Configure plugin, this function should be called before plugin execute() method is used.
46+
"""
47+
# Note you need to have jlink.exe on your system path!
48+
self.JLINK = 'jlink.exe'
49+
return True
50+
51+
def execute(self, capability, *args, **kwargs):
52+
"""! Executes capability by name
53+
54+
@param capability Capability name
55+
@param args Additional arguments
56+
@param kwargs Additional arguments
57+
58+
@details Each capability e.g. may directly just call some command line program or execute building pythonic function
59+
60+
@return Capability call return value
61+
"""
62+
result = False
63+
if self.check_parameters(capability, *args, **kwargs) is True:
64+
if capability == 'ublox':
65+
# Example:
66+
# JLINK.exe --CommanderScript aCommandFile
67+
cmd = [self.JLINK,
68+
'-CommanderScript',
69+
r'reset.jlink']
70+
result = self.run_command(cmd)
71+
return result
72+
73+
74+
def load_plugin():
75+
""" Returns plugin available in this module
76+
"""
77+
return HostTestPluginResetMethod_ublox()

0 commit comments

Comments
 (0)