diff --git a/workspace_tools/host_tests/echo.py b/workspace_tools/host_tests/echo.py index 0e6856b186..dc96f8539e 100644 --- a/workspace_tools/host_tests/echo.py +++ b/workspace_tools/host_tests/echo.py @@ -22,7 +22,7 @@ from host_test import TestResults, Test class EchoTest(Test): - """ This host test will use mbed serial port with + """ This host test will use mbed serial port with baudrate 115200 to perform echo test on that port. """ @@ -30,7 +30,7 @@ class EchoTest(Test): # Constructors TestResults.__init__(self) Test.__init__(self) - + # Test parameters self.TEST_SERIAL_BAUDRATE = 115200 self.TEST_LOOP_COUNT = 50 diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index 24dcd98829..822f3af961 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -56,6 +56,16 @@ class Mbed: help="The target disk path", metavar="DISK_PATH") + parser.add_option("-f", "--image-path", + dest="image_path", + help="Path with target's image", + metavar="IMAGE_PATH") + + parser.add_option("-c", "--copy", + dest="copy_method", + help="Copy method selector", + metavar="COPY_METHOD") + parser.add_option("-t", "--timeout", dest="timeout", help="Timeout", @@ -84,8 +94,12 @@ class Mbed: if self.options.port is None: raise Exception("The serial port of the target mbed have to be provided as command line arguments") + # Options related to copy / reset mbed device self.port = self.options.port self.disk = self.options.disk + self.image_path = self.options.image_path + self.copy_method = self.options.copy_method + self.extra_port = self.options.extra self.extra_serial = None self.serial = None @@ -157,12 +171,6 @@ class Mbed: result = None return result - def touch_file(self, path): - """ Touch file and set timestamp to items - """ - with open(path, 'a'): - os.utime(path, None) - def reset_timeout(self, timeout): """ Timeout executed just after reset command is issued """ @@ -183,6 +191,22 @@ class Mbed: reset_tout_s = self.options.forced_reset_timeout if self.options.forced_reset_timeout is not None else self.DEFAULT_RESET_TOUT self.reset_timeout(reset_tout_s) + def copy_image(self, image_path=None, disk=None, copy_method=None): + """ Copy file depending on method you want to use. Handles exception + and return code from shell copy commands. + """ + image_path = image_path if image_path is not None else self.image_path + disk = disk if disk is not None else self.disk + copy_method = copy_method if copy_method is not None else self.copy_method + + if copy_method is not None: + # 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) + else: + copy_method = 'default' + result = host_tests_plugins.call_plugin('CopyMethod', copy_method, image_path=image_path, destination_disk=disk) + return result; + def flush(self): """ Flush serial ports """ @@ -202,6 +226,7 @@ class TestResults: self.RESULT_FAILURE = 'failure' self.RESULT_ERROR = 'error' self.RESULT_IO_SERIAL = 'ioerr_serial' + self.RESULT_NO_IMAGE = 'no_image' class Test(TestResults): diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index ee177be5d5..1838916213 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -713,11 +713,13 @@ class SingleTestRunner(object): host_test_verbose = self.opts_verbose_test_result_only or self.opts_verbose host_test_reset = self.opts_mut_reset_type if reset_type is None else reset_type - single_test_result, single_test_output = self.run_host_test(test.host_test, disk, port, duration, + single_test_result, single_test_output = self.run_host_test(test.host_test, + image_path, disk, port, duration, micro=target_name, verbose=host_test_verbose, reset=host_test_reset, - reset_tout=reset_tout) + reset_tout=reset_tout, + copy_method=selected_copy_method) # Store test result test_all_result.append(single_test_result) @@ -793,7 +795,9 @@ class SingleTestRunner(object): result = test_all_result[0] return result - def run_host_test(self, name, disk, port, duration, micro=None, reset=None, reset_tout=None, verbose=False, extra_serial=None): + def run_host_test(self, name, image_path, disk, port, duration, + micro=None, reset=None, reset_tout=None, + verbose=False, extra_serial=None, copy_method=None): """ Function creates new process with host test configured with particular test case. Function also is pooling for serial port activity from process to catch all data printed by test runner and host test during test execution @@ -827,9 +831,16 @@ class SingleTestRunner(object): return result # print "{%s} port:%s disk:%s" % (name, port, disk), - cmd = ["python", "%s.py" % name, '-p', port, '-d', disk, '-t', str(duration)] + cmd = ["python", + '%s.py'% name, + '-d', disk, + '-f', '"%s"'% image_path, + '-p', port, + '-t', str(duration)] # Add extra parameters to host_test + if copy_method is not None: + cmd += ["-c", copy_method] if micro is not None: cmd += ["-m", micro] if extra_serial is not None: