scripts: pylib: twister: twisterlib: prevent empty gcda files

In case of problem with parsing hex data from coverage dump,
do not create empty gcda file.
Such empty file will break gcovr parsing.

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
This commit is contained in:
Piotr Kosycarz 2024-03-15 15:02:42 +01:00 committed by Carles Cufí
parent 033cbbac67
commit ca770dbeb7

View File

@ -122,8 +122,9 @@ class CoverageTool:
try:
hexdump_val = self.merge_hexdumps(hexdumps)
hex_bytes = bytes.fromhex(hexdump_val)
with open(filename, 'wb') as fp:
fp.write(bytes.fromhex(hexdump_val))
fp.write(hex_bytes)
except ValueError:
logger.exception("Unable to convert hex data for file: {}".format(filename))
gcda_created = False