diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index 103df83924..a1b15af444 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -250,7 +250,9 @@ class Mbed: Please refer to host_test_plugins functionality """ # Flush serials to get only input after reset - self.flush() + #self.flush() + self.serial.flushInput() + self.serial.flushOutput() if self.options.forced_reset_type: result = host_tests_plugins.call_plugin('ResetMethod', self.options.forced_reset_type, disk=self.disk) else: @@ -285,6 +287,7 @@ class Mbed: copy_method = 'shell' result = host_tests_plugins.call_plugin('CopyMethod', copy_method, image_path=image_path, destination_disk=disk, program_cycle_s=self.program_cycle_s, target_mcu=self.options.micro) + return result; def flush(self): diff --git a/workspace_tools/host_tests/host_tests_plugins/__init__.py b/workspace_tools/host_tests/host_tests_plugins/__init__.py index 521ba7138b..fc4893f236 100644 --- a/workspace_tools/host_tests/host_tests_plugins/__init__.py +++ b/workspace_tools/host_tests/host_tests_plugins/__init__.py @@ -21,6 +21,7 @@ import host_test_registry import module_copy_mbed import module_copy_shell import module_copy_silabs +import module_copy_smart #import module_copy_firefox import module_copy_mps2 @@ -37,6 +38,7 @@ HOST_TEST_PLUGIN_REGISTRY = host_test_registry.HostTestRegistry() # Some plugins are commented out if they are not stable or not commonly used HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_mbed.load_plugin()) HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_shell.load_plugin()) +HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_smart.load_plugin()) HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_reset_mbed.load_plugin()) #HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_firefox.load_plugin()) diff --git a/workspace_tools/host_tests/host_tests_plugins/module_copy_smart.py b/workspace_tools/host_tests/host_tests_plugins/module_copy_smart.py new file mode 100644 index 0000000000..4d4d06818f --- /dev/null +++ b/workspace_tools/host_tests/host_tests_plugins/module_copy_smart.py @@ -0,0 +1,97 @@ +""" +mbed SDK +Copyright (c) 2011-2013 ARM Limited + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +import os +import sys +from os.path import join, basename, exists +from time import sleep +from host_test_plugins import HostTestPluginBase + + +class HostTestPluginCopyMethod_Smart(HostTestPluginBase): + + # Plugin interface + name = 'HostTestPluginCopyMethod_Smart' + type = 'CopyMethod' + stable = True + capabilities = ['smart'] + required_parameters = ['image_path', 'destination_disk', 'target_mcu'] + + def setup(self, *args, **kwargs): + """ Configure plugin, this function should be called before plugin execute() method is used. + """ + return True + + def execute(self, capability, *args, **kwargs): + """ Executes capability by name. + Each capability may directly just call some command line + program or execute building pythonic function + """ + result = False + if self.check_parameters(capability, *args, **kwargs) is True: + image_path = kwargs['image_path'] + destination_disk = kwargs['destination_disk'] + target_mcu = kwargs['target_mcu'] + # Wait for mount point to be ready + self.check_mount_point_ready(destination_disk) # Blocking + # Prepare correct command line parameter values + image_base_name = basename(image_path) + destination_path = join(destination_disk, image_base_name) + if capability == 'smart': + if os.name == 'posix': + cmd = ['cp', image_path, destination_path] + result = self.run_command(cmd, shell=False) + + cmd = ['sync'] + result = self.run_command(cmd, shell=False) + + # Give the OS and filesystem time to settle down + sleep(3) + + if not target_mcu == 'LPC1768': + remount_complete = False + for i in range(0, 60): + if exists(destination_disk) and not exists(destination_path): + remount_complete = True + break + else: + sleep(1) + + if remount_complete: + print('Remount complete') + else: + print('Remount FAILED') + + if exists(destination_disk): + print('Disk exists') + else: + print('Disk does not exist') + + if exists(destination_path): + print('Image exists') + else: + print('Image does not exist') + + result = None + + + return result + +def load_plugin(): + """ Returns plugin available in this module + """ + return HostTestPluginCopyMethod_Smart() diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index c23c37fcec..29c8d22f69 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -1707,7 +1707,6 @@ def get_autodetected_MUTS(mbeds_list, platform_name_filter=None): index = 1 for mut in mbeds_list: # Filter the MUTS if a filter is specified - if platform_name_filter and not mut['platform_name'] in platform_name_filter: continue