Skip to content

Commit

Permalink
Saving gcov .gcda files with relative path.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad Azim Khan committed Mar 3, 2016
1 parent c5cad93 commit 885e003
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
9 changes: 7 additions & 2 deletions mbed_greentea/mbed_coverage_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,20 @@ def coverage_pack_hex_payload(payload):
bin_payload = bytearray([int(s, 16) for s in hex_pairs])
return bin_payload

def coverage_dump_file(path, payload):

def coverage_dump_file(yotta_target, path, payload):
"""! Creates file and dumps payload to it on specified path (even if path doesn't exist)
@param path Path to file
@param payload Binary data to store in a file
@return True if operation was completed
"""
result = True
try:
d = os.path.dirname(path)
d, filename = os.path.split(path)
if not os.path.isabs(d) and not os.path.exists(d):
# For a relative path that do not exist. Try adding ./build/<yotta target> prefix
d = os.path.join('build', yotta_target, d)
path = os.path.join(d, filename)
if not os.path.exists(d):
os.makedirs(d)
with open(path, "wb") as f:
Expand Down
8 changes: 5 additions & 3 deletions mbed_greentea/mbed_greentea_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,10 @@ def main_cli(opts, args, gt_instance_uuid=None):
# Capture alternative test console inputs, used e.g. in 'yotta test command'
if opts.digest_source:
enum_host_tests_path = get_local_host_tests_dir(opts.enum_host_tests)
host_test_result = run_host_test(image_path=None,
disk=None,
port=None,
host_test_result = run_host_test(None,
None,
None,
None,
hooks=greentea_hooks,
digest_source=opts.digest_source,
enum_host_tests_path=enum_host_tests_path,
Expand Down Expand Up @@ -755,6 +756,7 @@ def main_cli(opts, args, gt_instance_uuid=None):
host_test_result = run_host_test(opts.run_app,
disk,
port,
yotta_target_name,
micro=micro,
copy_method=copy_method,
program_cycle_s=program_cycle_s,
Expand Down
7 changes: 4 additions & 3 deletions mbed_greentea/mbed_test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def get_test_result(output):
def run_host_test(image_path,
disk,
port,
yotta_target,
duration=10,
micro=None,
reset=None,
Expand Down Expand Up @@ -190,7 +191,7 @@ def run_command(cmd):
result = get_test_result(htrun_output)
result_test_cases = get_testcase_result(htrun_output)
test_cases_summary = get_testcase_summary(htrun_output)
get_coverage_data(htrun_output)
get_coverage_data(yotta_target, htrun_output)

if verbose:
gt_logger.gt_log("mbed-host-test-runner: stopped")
Expand Down Expand Up @@ -237,7 +238,7 @@ def get_testcase_utest(output, test_case_name):

return tc_log_lines

def get_coverage_data(output):
def get_coverage_data(yotta_target, output):
# Example GCOV output
# [1456840876.73][CONN][RXD] {{__coverage_start;c:\Work\core-util/source/PoolAllocator.cpp.gcda;6164636772393034c2733f32...a33e...b9}}
gt_logger.gt_log("checking for GCOV data...")
Expand All @@ -248,7 +249,7 @@ def get_coverage_data(output):
timestamp, _, gcov_path, gcov_payload = m.groups()
try:
bin_gcov_payload = coverage_pack_hex_payload(gcov_payload)
coverage_dump_file(gcov_path, bin_gcov_payload)
coverage_dump_file(yotta_target, gcov_path, bin_gcov_payload)
except Exception as e:
gt_logger.gt_log_err("error while handling GCOV data: " + str(e))
gt_logger.gt_log_tab("storing %d bytes in '%s'"% (len(bin_gcov_payload), gcov_path))
Expand Down

0 comments on commit 885e003

Please sign in to comment.