]>
git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mps2.py
3 Copyright (c) 2011-2013 ARM Limited
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
9 http://www.apache.org/licenses/LICENSE-2.0
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.
19 from os
.path
import join
20 from host_test_plugins
import HostTestPluginBase
23 class HostTestPluginCopyMethod_MPS2(HostTestPluginBase
):
25 # MPS2 specific flashing / binary setup funcitons
26 def mps2_set_board_image_file(self
, disk
, images_cfg_path
, image0file_path
, image_name
='images.txt'):
27 """ This function will alter image cfg file.
28 Main goal of this function is to change number of images to 1, comment all
29 existing image entries and append at the end of file new entry with test path.
30 @return True when all steps succeed.
32 MBED_SDK_TEST_STAMP
= 'test suite entry'
33 image_path
= join(disk
, images_cfg_path
, image_name
)
34 new_file_lines
= [] # New configuration file lines (entries)
36 # Check each line of the image configuration file
38 with
open(image_path
, 'r') as file:
40 if re
.search('^TOTALIMAGES', line
):
41 # Check number of total images, should be 1
42 new_file_lines
.append(re
.sub('^TOTALIMAGES:[\t ]*[\d]+', 'TOTALIMAGES: 1', line
))
43 elif re
.search('; - %s[\n\r]*$'% MBED_SDK_TEST_STAMP
, line
):
44 # Look for test suite entries and remove them
45 pass # Omit all test suite entries
46 elif re
.search('^IMAGE[\d]+FILE', line
):
47 # Check all image entries and mark the ';'
48 new_file_lines
.append(';' + line
) # Comment non test suite lines
50 # Append line to new file
51 new_file_lines
.append(line
)
55 # Add new image entry with proper commented stamp
56 new_file_lines
.append('IMAGE0FILE: %s ; - %s\r\n'% (image0file_path
, MBED_SDK_TEST_STAMP
))
58 # Write all lines to file
60 with
open(image_path
, 'w') as file:
61 for line
in new_file_lines
:
68 def mps2_select_core(self
, disk
, mobo_config_name
=""):
69 """ Function selects actual core
71 # TODO: implement core selection
74 def mps2_switch_usb_auto_mounting_after_restart(self
, disk
, usb_config_name
=""):
75 """ Function alters configuration to allow USB MSD to be mounted after restarts
77 # TODO: implement USB MSD restart detection
81 name
= 'HostTestPluginCopyMethod_MPS2'
83 capabilities
= ['mps2']
84 required_parameters
= ['image_path', 'destination_disk']
86 def setup(self
, *args
, **kwargs
):
87 """ Configure plugin, this function should be called before plugin execute() method is used.
91 def execute(self
, capabilitity
, *args
, **kwargs
):
92 """ Executes capability by name.
93 Each capability may directly just call some command line
94 program or execute building pythonic function
97 if self
.check_parameters(capabilitity
, *args
, **kwargs
) is True:
98 if capabilitity
== 'mps2':
99 # TODO: Implement MPS2 firmware setup here
105 """ Returns plugin available in this module
107 return HostTestPluginCopyMethod_MPS2()