in cbmc_viewer/coveraget.py [0:0]
def load_cbmc_json(json_file, root):
"""Load json file produced by cbmc --cover location --json-ui."""
json_data = parse.parse_json_file(json_file, fail=True)
if not json_data:
logging.info("Expected coverage data in json file %s, found none",
json_file)
return None
goal_list = [entry for entry in json_data if 'goals' in entry]
if len(goal_list) != 1:
logging.info("Expected 1 block of goal data in json file %s, found %s",
json_file, len(goal_list))
return None
goals = goal_list[0]
coverage = {}
for goal in goals["goals"]:
description = goal["description"]
status = goal["status"]
location = goal["sourceLocation"]
wkdir = srcloct.json_srcloc_wkdir(location)
coverage = add_coverage_data(coverage, description, status, wkdir, root)
try:
RAW_COVERAGE_DATA(coverage)
except voluptuous.Error as error:
raise UserWarning(
"Error loading cbmc json coverage data: {}: {}".format(json_file, error)
) from error
return coverage