mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #1298 from PrzemekWirkus/bugfix_default_copy_method_shell2
Tools: singletest.py option -c with shell copy method as default copy methodpull/1300/head^2
commit
846f487a1a
|
@ -250,11 +250,14 @@ class Mbed:
|
||||||
""" Copy file depending on method you want to use. Handles exception
|
""" Copy file depending on method you want to use. Handles exception
|
||||||
and return code from shell copy commands.
|
and return code from shell copy commands.
|
||||||
"""
|
"""
|
||||||
if copy_method is not None:
|
|
||||||
# image_path - Where is binary with target's firmware
|
# image_path - Where is binary with target's firmware
|
||||||
result = host_tests_plugins.call_plugin('CopyMethod', copy_method, image_path=image_path, destination_disk=disk)
|
if copy_method is not None:
|
||||||
|
# We override 'default' method with 'shell' method
|
||||||
|
if copy_method == 'default':
|
||||||
|
copy_method = 'shell'
|
||||||
else:
|
else:
|
||||||
copy_method = 'default'
|
copy_method = 'shell'
|
||||||
|
|
||||||
result = host_tests_plugins.call_plugin('CopyMethod', copy_method, image_path=image_path, destination_disk=disk)
|
result = host_tests_plugins.call_plugin('CopyMethod', copy_method, image_path=image_path, destination_disk=disk)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class HostTestPluginCopyMethod_Mbed(HostTestPluginBase):
|
||||||
name = 'HostTestPluginCopyMethod_Mbed'
|
name = 'HostTestPluginCopyMethod_Mbed'
|
||||||
type = 'CopyMethod'
|
type = 'CopyMethod'
|
||||||
stable = True
|
stable = True
|
||||||
capabilities = ['default']
|
capabilities = ['shutil', 'default']
|
||||||
required_parameters = ['image_path', 'destination_disk']
|
required_parameters = ['image_path', 'destination_disk']
|
||||||
|
|
||||||
def setup(self, *args, **kwargs):
|
def setup(self, *args, **kwargs):
|
||||||
|
@ -49,14 +49,15 @@ class HostTestPluginCopyMethod_Mbed(HostTestPluginBase):
|
||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def execute(self, capabilitity, *args, **kwargs):
|
def execute(self, capability, *args, **kwargs):
|
||||||
""" Executes capability by name.
|
""" Executes capability by name.
|
||||||
Each capability may directly just call some command line
|
Each capability may directly just call some command line
|
||||||
program or execute building pythonic function
|
program or execute building pythonic function
|
||||||
"""
|
"""
|
||||||
result = False
|
result = False
|
||||||
if self.check_parameters(capabilitity, *args, **kwargs) is True:
|
if self.check_parameters(capability, *args, **kwargs) is True:
|
||||||
if capabilitity == 'default':
|
# Capability 'default' is a dummy capability
|
||||||
|
if capability == 'shutil':
|
||||||
image_path = kwargs['image_path']
|
image_path = kwargs['image_path']
|
||||||
destination_disk = kwargs['destination_disk']
|
destination_disk = kwargs['destination_disk']
|
||||||
# Wait for mount point to be ready
|
# Wait for mount point to be ready
|
||||||
|
|
|
@ -34,13 +34,13 @@ class HostTestPluginCopyMethod_Shell(HostTestPluginBase):
|
||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def execute(self, capabilitity, *args, **kwargs):
|
def execute(self, capability, *args, **kwargs):
|
||||||
""" Executes capability by name.
|
""" Executes capability by name.
|
||||||
Each capability may directly just call some command line
|
Each capability may directly just call some command line
|
||||||
program or execute building pythonic function
|
program or execute building pythonic function
|
||||||
"""
|
"""
|
||||||
result = False
|
result = False
|
||||||
if self.check_parameters(capabilitity, *args, **kwargs) is True:
|
if self.check_parameters(capability, *args, **kwargs) is True:
|
||||||
image_path = kwargs['image_path']
|
image_path = kwargs['image_path']
|
||||||
destination_disk = kwargs['destination_disk']
|
destination_disk = kwargs['destination_disk']
|
||||||
# Wait for mount point to be ready
|
# Wait for mount point to be ready
|
||||||
|
@ -48,14 +48,17 @@ class HostTestPluginCopyMethod_Shell(HostTestPluginBase):
|
||||||
# Prepare correct command line parameter values
|
# Prepare correct command line parameter values
|
||||||
image_base_name = basename(image_path)
|
image_base_name = basename(image_path)
|
||||||
destination_path = join(destination_disk, image_base_name)
|
destination_path = join(destination_disk, image_base_name)
|
||||||
if capabilitity == 'shell':
|
if capability == 'shell':
|
||||||
if os.name == 'nt': capabilitity = 'copy'
|
if os.name == 'nt': capability = 'copy'
|
||||||
elif os.name == 'posix': capabilitity = 'cp'
|
elif os.name == 'posix': capability = 'cp'
|
||||||
if capabilitity == 'cp' or capabilitity == 'copy' or capabilitity == 'xcopy':
|
if capability == 'cp' or capability == 'copy' or capability == 'copy':
|
||||||
copy_method = capabilitity
|
copy_method = capability
|
||||||
cmd = [copy_method, image_path, destination_path]
|
cmd = [copy_method, image_path, destination_path]
|
||||||
shell = not capabilitity == 'cp'
|
if os.name == 'posix':
|
||||||
result = self.run_command(cmd, shell=shell)
|
result = self.run_command(cmd, shell=False)
|
||||||
|
result = self.run_command(["sync"])
|
||||||
|
else:
|
||||||
|
result = self.run_command(cmd)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue