Test loops feature part 1: added --loops and --global-loops switches, added test_loops paramater for test handler

pull/399/head
Przemek Wirkus 2014-07-10 15:58:17 +01:00
parent a1c9c941b5
commit b78617df93
1 changed files with 34 additions and 24 deletions

View File

@ -214,11 +214,9 @@ class SingleTestRunner(object):
result = False result = False
return result, resutl_msg return result, resutl_msg
def handle(self, test_spec, target_name, toolchain_name): def handle(self, test_spec, target_name, toolchain_name, test_loops=1):
""" """ Function determines MUT's mbed disk/port and copies binary to
Function determines MUT's mbed disk/port and copies binary to target. Test is being invoked afterwards. """
target. Test is being invoked afterwards.
"""
data = json.loads(test_spec) data = json.loads(test_spec)
# Get test information, image and test timeout # Get test information, image and test timeout
test_id = data['test_id'] test_id = data['test_id']
@ -257,6 +255,9 @@ class SingleTestRunner(object):
if not disk.endswith('/') and not disk.endswith('\\'): if not disk.endswith('/') and not disk.endswith('\\'):
disk += '/' disk += '/'
# Tests can be looped so test results must be stored for the same test
test_all_result = []
for test_index in range(test_loops):
# Choose one method of copy files to mbed virtual drive # Choose one method of copy files to mbed virtual drive
_copy_res, _err_msg, _copy_method = self.file_copy_method_selector(image_path, disk, opts.copy_method) _copy_res, _err_msg, _copy_method = self.file_copy_method_selector(image_path, disk, opts.copy_method)
@ -276,6 +277,7 @@ class SingleTestRunner(object):
# Host test execution # Host test execution
start_host_exec_time = time() start_host_exec_time = time()
test_result = self.run_host_test(test.host_test, disk, port, duration, opts.verbose) test_result = self.run_host_test(test.host_test, disk, port, duration, opts.verbose)
test_all_result.append(test_result)
elapsed_time = time() - start_host_exec_time elapsed_time = time() - start_host_exec_time
print print_test_result(test_result, target_name, toolchain_name, print print_test_result(test_result, target_name, toolchain_name,
@ -759,6 +761,14 @@ if __name__ == '__main__':
action="store_true", action="store_true",
help='Displays full test specification and MUTs configration and exits') help='Displays full test specification and MUTs configration and exits')
parser.add_option('', '--loops',
dest='test_loops_list',
help='Set no. of loops per test. Format: TEST_1=1,TEST_2=2,TEST_3=3')
parser.add_option('', '--global-loops',
dest='test_global_loops_value',
help='Set global number of test loops per test. Default value is set 1')
parser.add_option('-v', '--verbose', parser.add_option('-v', '--verbose',
dest='verbose', dest='verbose',
default=False, default=False,