summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2023-11-27 14:50:59 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-11-27 15:26:53 +0100
commit15f04b0d3c63eaf86594e8aa36ce8da8d35aabac (patch)
tree5ebf278030cde5b0b58504bf88635e067b6ec883
parenttestoutputparser: Simplify (diff)
downloadrtems-central-15f04b0d3c63eaf86594e8aa36ce8da8d35aabac.tar.bz2
testoutputparser: Support gcov info hash
-rw-r--r--rtemsspec/testoutputparser.py32
-rw-r--r--rtemsspec/tests/test_testoutputparser.py7
2 files changed, 33 insertions, 6 deletions
diff --git a/rtemsspec/testoutputparser.py b/rtemsspec/testoutputparser.py
index aca35505..c18fa9c8 100644
--- a/rtemsspec/testoutputparser.py
+++ b/rtemsspec/testoutputparser.py
@@ -71,6 +71,7 @@ _M_D = re.compile(r"M:D:(.+)")
_GCOV_BEGIN = "*** BEGIN OF GCOV INFO BASE64 ***"
_GCOV_END = "*** END OF GCOV INFO BASE64 ***"
+_GCOV_HASH = re.compile(r"\*\*\* GCOV INFO SHA256 (.*) \*\*\*")
_RECORDS_BEGIN = "*** BEGIN OF RECORDS BASE64 ***"
_RECORDS_END = "*** END OF RECORDS BASE64 ***"
@@ -117,6 +118,16 @@ class TestOutputParser:
def _hash_sha256(self, line: str) -> None:
self._hash_state.update(f"{line}\n".encode("ascii"))
+ def _hash_sha256_skip_one(self, line: str) -> None:
+ # pylint: disable=unused-argument
+ self.hash_line = self._hash_sha256
+
+ def _hash_finalize(self) -> str:
+ self.hash_line = self._hash_none
+ digest = base64.urlsafe_b64encode(
+ self._hash_state.digest()).decode("ascii")
+ return digest
+
def _test_begin(self, index: int, line: str) -> bool:
mobj = _TEST_BEGIN.match(line)
if mobj:
@@ -201,6 +212,7 @@ class TestOutputParser:
"test-cases": []
}
self.consume = self._test_suite_platform
+ self._hash_state = hashlib.sha256()
self.hash_line = self._hash_sha256
return True
return self._extra(index, line)
@@ -503,14 +515,11 @@ class TestOutputParser:
def _report_hash(self, index: int, line: str) -> bool:
mobj = _TS_REPORT_HASH.match(line)
if mobj:
- digest = base64.urlsafe_b64encode(
- self._hash_state.digest()).decode("ascii")
- self._hash_state = hashlib.sha256()
- self.data["test-suite"]["report-hash-calculated"] = digest
+ self.data["test-suite"][
+ "report-hash-calculated"] = self._hash_finalize()
self.data["test-suite"]["report-hash"] = mobj.group(1)
self.data["test-suite"]["line-report-hash"] = index
self.consume = self._test_body
- self.hash_line = self._hash_none
return True
return self._extra(index, line)
@@ -519,12 +528,15 @@ class TestOutputParser:
self.level += 1
self.data["line-gcov-info-base64-begin"] = index
self.consume = self._gcov_end
+ self._hash_state = hashlib.sha256()
+ self.hash_line = self._hash_sha256_skip_one
return True
return False
def _gcov_end(self, index: int, line: str) -> bool:
if line in _GCOV_END:
self.level -= 1
+ self.data["gcov-info-hash-calculated"] = self._hash_finalize()
self.data["line-gcov-info-base64-end"] = index
self.data["data-ranges"].append(
(self.data["line-gcov-info-base64-begin"] + 1, index))
@@ -532,6 +544,14 @@ class TestOutputParser:
return True
return False
+ def _gcov_hash(self, index: int, line: str) -> bool:
+ mobj = _GCOV_HASH.match(line)
+ if mobj:
+ self.data["gcov-info-hash"] = mobj.group(1)
+ self.data["line-gcov-info-hash"] = index
+ return True
+ return False
+
def _records_begin(self, index: int, line: str) -> bool:
if line in _RECORDS_BEGIN:
self.level += 1
@@ -571,6 +591,8 @@ class TestOutputParser:
def _extra(self, index: int, line: str) -> bool:
if self._gcov_begin(index, line):
return True
+ if self._gcov_hash(index, line):
+ return True
if self._records_begin(index, line):
return True
if self._records_zlib_begin(index, line):
diff --git a/rtemsspec/tests/test_testoutputparser.py b/rtemsspec/tests/test_testoutputparser.py
index 0ac7ea85..d867c61a 100644
--- a/rtemsspec/tests/test_testoutputparser.py
+++ b/rtemsspec/tests/test_testoutputparser.py
@@ -59,7 +59,8 @@ _OUTPUT = [
"", "*** BEGIN OF RECORDS BASE64 ZLIB ***",
"bmZjZ1I0MEKUAAAAL29wdC9ydGVtcy9ydGVtcy02LXNhZmVzdC0xL2J1aWxkL2JzcC1xdWFsLW9u",
"AAAAOi+8CuS72SFYlu6BAAChAcD///8AAAAA",
- "*** END OF RECORDS BASE64 ZLIB ***"
+ "*** END OF RECORDS BASE64 ZLIB ***", "",
+ "*** GCOV INFO SHA256 y-0n6RjPnOwLUxXEKlPzx_g92tNGWHSzta_WYyGe5-g= ***"
]
_INCOMPLETE_TEST_SUITE = {
@@ -294,9 +295,13 @@ def _report(t_begin: int = 0,
error: int = -1) -> None:
report = {
"data-ranges": _data_ranges(data_begin + 1),
+ "gcov-info-hash": "y-0n6RjPnOwLUxXEKlPzx_g92tNGWHSzta_WYyGe5-g=",
+ "gcov-info-hash-calculated":
+ "y-0n6RjPnOwLUxXEKlPzx_g92tNGWHSzta_WYyGe5-g=",
"info": _info(t_begin, t_end),
"line-gcov-info-base64-begin": data_begin,
"line-gcov-info-base64-end": data_begin + 3,
+ "line-gcov-info-hash": data_begin + 13,
"line-records-base64-begin": data_begin + 4,
"line-records-base64-end": data_begin + 7,
"line-records-base64-zlib-begin": data_begin + 8,