Skip to content

Commit b78617d

Browse files
committed
Test loops feature part 1: added --loops and --global-loops switches, added test_loops paramater for test handler
1 parent a1c9c94 commit b78617d

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

workspace_tools/singletest.py

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,9 @@ def delete_file(file_path):
214214
result = False
215215
return result, resutl_msg
216216

217-
def handle(self, test_spec, target_name, toolchain_name):
218-
"""
219-
Function determines MUT's mbed disk/port and copies binary to
220-
target. Test is being invoked afterwards.
221-
"""
217+
def handle(self, test_spec, target_name, toolchain_name, test_loops=1):
218+
""" Function determines MUT's mbed disk/port and copies binary to
219+
target. Test is being invoked afterwards. """
222220
data = json.loads(test_spec)
223221
# Get test information, image and test timeout
224222
test_id = data['test_id']
@@ -257,29 +255,33 @@ def handle(self, test_spec, target_name, toolchain_name):
257255
if not disk.endswith('/') and not disk.endswith('\\'):
258256
disk += '/'
259257

260-
# Choose one method of copy files to mbed virtual drive
261-
_copy_res, _err_msg, _copy_method = self.file_copy_method_selector(image_path, disk, opts.copy_method)
258+
# Tests can be looped so test results must be stored for the same test
259+
test_all_result = []
260+
for test_index in range(test_loops):
261+
# Choose one method of copy files to mbed virtual drive
262+
_copy_res, _err_msg, _copy_method = self.file_copy_method_selector(image_path, disk, opts.copy_method)
262263

263-
# Host test execution
264-
start_host_exec_time = time()
265-
266-
if not _copy_res: # Serial port copy error
267-
test_result = "IOERR_COPY"
268-
print "Error: Copy method '%s'. %s"% (_copy_method, _err_msg)
269-
else:
270-
# Copy Extra Files
271-
if not target_by_mcu.is_disk_virtual and test.extra_files:
272-
for f in test.extra_files:
273-
copy(f, disk)
274-
275-
sleep(target_by_mcu.program_cycle_s())
276264
# Host test execution
277265
start_host_exec_time = time()
278-
test_result = self.run_host_test(test.host_test, disk, port, duration, opts.verbose)
279266

280-
elapsed_time = time() - start_host_exec_time
281-
print print_test_result(test_result, target_name, toolchain_name,
282-
test_id, test_description, elapsed_time, duration)
267+
if not _copy_res: # Serial port copy error
268+
test_result = "IOERR_COPY"
269+
print "Error: Copy method '%s'. %s"% (_copy_method, _err_msg)
270+
else:
271+
# Copy Extra Files
272+
if not target_by_mcu.is_disk_virtual and test.extra_files:
273+
for f in test.extra_files:
274+
copy(f, disk)
275+
276+
sleep(target_by_mcu.program_cycle_s())
277+
# Host test execution
278+
start_host_exec_time = time()
279+
test_result = self.run_host_test(test.host_test, disk, port, duration, opts.verbose)
280+
test_all_result.append(test_result)
281+
282+
elapsed_time = time() - start_host_exec_time
283+
print print_test_result(test_result, target_name, toolchain_name,
284+
test_id, test_description, elapsed_time, duration)
283285
return (test_result, target_name, toolchain_name,
284286
test_id, test_description, round(elapsed_time, 2), duration)
285287

@@ -759,6 +761,14 @@ def generate_test_summary(test_summary):
759761
action="store_true",
760762
help='Displays full test specification and MUTs configration and exits')
761763

764+
parser.add_option('', '--loops',
765+
dest='test_loops_list',
766+
help='Set no. of loops per test. Format: TEST_1=1,TEST_2=2,TEST_3=3')
767+
768+
parser.add_option('', '--global-loops',
769+
dest='test_global_loops_value',
770+
help='Set global number of test loops per test. Default value is set 1')
771+
762772
parser.add_option('-v', '--verbose',
763773
dest='verbose',
764774
default=False,

0 commit comments

Comments
 (0)