Skip to content

Commit d84654f

Browse files
Merge pull request #162 from jamesbeyond/test-spec
Add support for "compare_log" in GreenTea test_spec.json
2 parents c9af07c + 82e5489 commit d84654f

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

packages/mbed-greentea/mbed_greentea/mbed_greentea_cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ def run_test_thread(test_result_queue, test_queue, opts, mut, build, build_path,
424424
enum_host_tests_path=enum_host_tests_path,
425425
global_resource_mgr=opts.global_resource_mgr,
426426
fast_model_connection=opts.fast_model_connection,
427+
compare_log=test['compare_log'],
427428
num_sync_packtes=opts.num_sync_packtes,
428429
tags=opts.tags,
429430
retry_count=opts.retry_count,
@@ -872,10 +873,11 @@ def get_parallel_value(value):
872873

873874
for test_name in filtered_ctest_test_list_keys:
874875
image_path = filtered_ctest_test_list[test_name].get_binary(binary_type=TestBinary.BIN_TYPE_BOOTABLE).get_path()
876+
compare_log = filtered_ctest_test_list[test_name].get_binary(binary_type=TestBinary.BIN_TYPE_BOOTABLE).get_compare_log()
875877
if image_path is None:
876878
gt_logger.gt_log_err("Failed to find test binary for test %s flash method %s" % (test_name, 'usb'))
877879
else:
878-
test = {"test_bin": test_name, "image_path": image_path}
880+
test = {"test_bin": test_name, "image_path": image_path, "compare_log": compare_log}
879881
test_queue.put(test)
880882

881883
number_of_threads = 0

packages/mbed-greentea/mbed_greentea/mbed_test_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def run_host_test(image_path,
7474
enum_host_tests_path=None,
7575
global_resource_mgr=None,
7676
fast_model_connection=None,
77+
compare_log=None,
7778
num_sync_packtes=None,
7879
polling_timeout=None,
7980
retry_count=1,
@@ -212,7 +213,8 @@ def get_binary_host_tests_dir(binary_path, level=2):
212213
# Example:
213214
# $ mbedhtrun -f "tests-mbed_drivers-generic_tests.elf" -m FVP_MPS2_M3 --fm DEFAULT
214215
cmd += ['--fm', fast_model_connection]
215-
216+
if compare_log:
217+
cmd += ['--compare-log', compare_log]
216218
if program_cycle_s:
217219
cmd += ["-C", str(program_cycle_s)]
218220
if forced_reset_timeout:

src/mbed_os_tools/test/tests_spec.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ class TestBinary:
2929

3030
KW_BIN_TYPE = "binary_type"
3131
KW_BIN_PATH = "path"
32+
KW_COMP_LOG = "compare_log"
3233

3334
BIN_TYPE_BOOTABLE = "bootable"
3435
BIN_TYPE_DEFAULT = BIN_TYPE_BOOTABLE
3536
SUPPORTED_BIN_TYPES = [BIN_TYPE_BOOTABLE]
3637

37-
def __init__(self, path, binary_type):
38+
def __init__(self, path, binary_type, compare_log):
3839
"""
3940
ctor.
4041
@@ -48,6 +49,7 @@ def __init__(self, path, binary_type):
4849
)
4950
self.__path = path
5051
self.__flash_method = binary_type
52+
self.__comp_log = compare_log
5153

5254
def get_path(self):
5355
"""
@@ -56,6 +58,13 @@ def get_path(self):
5658
"""
5759
return self.__path
5860

61+
def get_compare_log(self):
62+
"""
63+
Gives compare log file.
64+
:return:
65+
"""
66+
return self.__comp_log
67+
5968

6069
class Test:
6170
"""
@@ -109,18 +118,22 @@ def parse(self, test_json):
109118
), "Binary spec should contain key [%s]" % ",".join(mandatory_keys)
110119
fm = binary.get(TestBinary.KW_BIN_TYPE, self.__default_flash_method)
111120
assert fm is not None, "Binary type not specified in build and binary spec."
112-
tb = TestBinary(binary[TestBinary.KW_BIN_PATH], fm)
121+
tb = TestBinary(binary[TestBinary.KW_BIN_PATH],
122+
fm,
123+
binary.get(TestBinary.KW_COMP_LOG))
113124
self.__binaries_by_flash_method[fm] = tb
114125

115-
def add_binary(self, path, binary_type):
126+
def add_binary(self, path, binary_type, compare_log=None):
116127
"""
117128
Add binary to the test.
118129
119130
:param path:
120131
:param binary_type:
121132
:return:
122133
"""
123-
self.__binaries_by_flash_method[binary_type] = TestBinary(path, binary_type)
134+
self.__binaries_by_flash_method[binary_type] = TestBinary(path,
135+
binary_type,
136+
compare_log)
124137

125138

126139
class TestBuild:

0 commit comments

Comments
 (0)