|
75 | 75 | import optparse
|
76 | 76 | import pprint
|
77 | 77 | import re
|
| 78 | +import os |
78 | 79 | from types import ListType
|
79 | 80 | from prettytable import PrettyTable
|
80 | 81 |
|
@@ -140,6 +141,9 @@ class SingleTestRunner(object):
|
140 | 141 | TEST_RESULT_FAIL = "FAIL"
|
141 | 142 | TEST_RESULT_ERROR = "ERROR"
|
142 | 143 | TEST_RESULT_UNDEF = "UNDEF"
|
| 144 | + TEST_RESULT_IOERR_COPY = "IOERR_COPY" |
| 145 | + TEST_RESULT_IOERR_DISK = "IOERR_DISK" |
| 146 | + TEST_RESULT_TIMEOUT = "TIMEOUT" |
143 | 147 |
|
144 | 148 | # mbed test suite -> SingleTestRunner
|
145 | 149 | TEST_RESULT_MAPPING = {"success" : TEST_RESULT_OK,
|
@@ -170,12 +174,29 @@ def file_copy_method_selector(self, image_path, disk, copy_method):
|
170 | 174 | fdst.write(buf)
|
171 | 175 | IOError: [Errno 28] No space left on device
|
172 | 176 | """
|
| 177 | + result = True |
| 178 | + resutl_msg = "" |
173 | 179 | if copy_method == "cp" or copy_method == "copy" or copy_method == "xcopy":
|
174 |
| - cmd = [copy_method, image_path.encode('ascii', 'ignore'), disk.encode('ascii', 'ignore') + basename(image_path).encode('ascii', 'ignore')] |
175 |
| - call(cmd, shell=True) |
| 180 | + cmd = [copy_method, |
| 181 | + image_path.encode('ascii', 'ignore'), |
| 182 | + disk.encode('ascii', 'ignore') + basename(image_path).encode('ascii', 'ignore')] |
| 183 | + try: |
| 184 | + ret = call(cmd, shell=True) |
| 185 | + if ret: |
| 186 | + resutl_msg = "Return code: %d. Command: "% ret + " ".join(cmd) |
| 187 | + result = False |
| 188 | + except Exception, e: |
| 189 | + resutl_msg = e |
| 190 | + result = False |
176 | 191 | else:
|
| 192 | + copy_method = "shutils.copy()" |
177 | 193 | # Default python method
|
178 |
| - copy(image_path, disk) |
| 194 | + try: |
| 195 | + copy(image_path, disk) |
| 196 | + except Exception, e: |
| 197 | + resutl_msg = e |
| 198 | + result = False |
| 199 | + return result, resutl_msg, copy_method |
179 | 200 |
|
180 | 201 | def delete_file(file_path):
|
181 | 202 | """ Remove file from the system """
|
@@ -232,18 +253,25 @@ def handle(self, test_spec, target_name, toolchain_name):
|
232 | 253 | disk += '/'
|
233 | 254 |
|
234 | 255 | # Choose one method of copy files to mbed virtual drive
|
235 |
| - self.file_copy_method_selector(image_path, disk, opts.copy_method) |
236 |
| - |
237 |
| - # Copy Extra Files |
238 |
| - if not target_by_mcu.is_disk_virtual and test.extra_files: |
239 |
| - for f in test.extra_files: |
240 |
| - copy(f, disk) |
241 |
| - |
242 |
| - sleep(target_by_mcu.program_cycle_s()) |
| 256 | + _copy_res, _err_msg, _copy_method = self.file_copy_method_selector(image_path, disk, opts.copy_method) |
243 | 257 |
|
244 | 258 | # Host test execution
|
245 | 259 | start_host_exec_time = time()
|
246 |
| - test_result = self.run_host_test(test.host_test, disk, port, duration, opts.verbose) |
| 260 | + |
| 261 | + if not _copy_res: # Serial port copy error |
| 262 | + test_result = "IOERR_COPY" |
| 263 | + print "Error: Copy method '%s'. %s"% (_copy_method, _err_msg) |
| 264 | + else: |
| 265 | + # Copy Extra Files |
| 266 | + if not target_by_mcu.is_disk_virtual and test.extra_files: |
| 267 | + for f in test.extra_files: |
| 268 | + copy(f, disk) |
| 269 | + |
| 270 | + sleep(target_by_mcu.program_cycle_s()) |
| 271 | + # Host test execution |
| 272 | + start_host_exec_time = time() |
| 273 | + test_result = self.run_host_test(test.host_test, disk, port, duration, opts.verbose) |
| 274 | + |
247 | 275 | elapsed_time = time() - start_host_exec_time
|
248 | 276 | print print_test_result(test_result, target_name, toolchain_name,
|
249 | 277 | test_id, test_description, elapsed_time, duration)
|
@@ -616,10 +644,15 @@ def generate_test_summary(test_summary):
|
616 | 644 | pt.align["Test Description"] = "l" # Left align
|
617 | 645 | pt.padding_width = 1 # One space between column edges and contents (default)
|
618 | 646 |
|
619 |
| - result_dict = { single_test.TEST_RESULT_OK : 0, |
620 |
| - single_test.TEST_RESULT_FAIL : 0, |
621 |
| - single_test.TEST_RESULT_ERROR : 0, |
622 |
| - single_test.TEST_RESULT_UNDEF : 0 } |
| 647 | + result_dict = {single_test.TEST_RESULT_OK : 0, |
| 648 | + single_test.TEST_RESULT_FAIL : 0, |
| 649 | + single_test.TEST_RESULT_ERROR : 0, |
| 650 | + single_test.TEST_RESULT_UNDEF : 0, |
| 651 | + single_test.TEST_RESULT_UNDEF : 0, |
| 652 | + single_test.TEST_RESULT_UNDEF : 0, |
| 653 | + single_test.TEST_RESULT_IOERR_COPY : 0, |
| 654 | + single_test.TEST_RESULT_IOERR_DISK : 0, |
| 655 | + single_test.TEST_RESULT_TIMEOUT : 0 } |
623 | 656 |
|
624 | 657 | for test in test_summary:
|
625 | 658 | if test[0] in result_dict:
|
@@ -794,6 +827,10 @@ def generate_test_summary(test_summary):
|
794 | 827 | for toolchain in toolchains:
|
795 | 828 | # print '=== %s::%s ===' % (target, toolchain)
|
796 | 829 | # Let's build our test
|
| 830 | + if target not in TARGET_MAP: |
| 831 | + print 'Skipped tests for %s target. Target platform not found' % (target) |
| 832 | + continue |
| 833 | + |
797 | 834 | T = TARGET_MAP[target]
|
798 | 835 | build_mbed_libs_options = ["analyze"] if opts.goanna_for_mbed_sdk else None
|
799 | 836 | build_mbed_libs_result = build_mbed_libs(T, toolchain, options=build_mbed_libs_options)
|
@@ -827,6 +864,7 @@ def generate_test_summary(test_summary):
|
827 | 864 | print "TargetTest::%s::TestSkipped(%s)" % (target, ",".join(test_peripherals))
|
828 | 865 | continue
|
829 | 866 |
|
| 867 | + # This is basic structure storing test results |
830 | 868 | test_result = {
|
831 | 869 | 'target': target,
|
832 | 870 | 'toolchain': toolchain,
|
|
0 commit comments