autotest: add support for multi-line log formats

This commit is contained in:
Peter Barker 2022-02-23 23:22:07 +11:00 committed by Andrew Tridgell
parent 13fa1e30ad
commit 7bb13e934d

View File

@ -2100,6 +2100,7 @@ class AutoTest(ABC):
return ret
def all_log_format_ids(self):
'''parse C++ code to extract definitions of log messages'''
structure_files = self.find_LogStructureFiles()
structure_lines = []
for f in structure_files:
@ -2155,7 +2156,16 @@ class AutoTest(ABC):
if linestate == linestate_within:
m = re.match("(.*)}", line)
if m is None:
raise NotAchievedException("Bad closing line (%s)" % line)
line = line.rstrip()
newline = re.sub(r"\\$", "", line)
if newline == line:
raise NotAchievedException("Expected backslash at end of line")
line = newline
line = line.rstrip()
# cpp-style string concatenation:
line = re.sub(r'"\s*"', '', line)
partial_line += line
continue
message_infos.append(partial_line + m.group(1))
linestate = linestate_none
continue
@ -2214,7 +2224,16 @@ class AutoTest(ABC):
if linestate == linestate_within:
m = re.match("(.*)}", line)
if m is None:
raise NotAchievedException("Bad closing line (%s)" % line)
line = line.rstrip()
newline = re.sub(r"\\$", "", line)
if newline == line:
raise NotAchievedException("Expected backslash at end of line")
line = newline
line = line.rstrip()
# cpp-style string concatenation:
line = re.sub(r'"\s*"', '', line)
partial_line += line
continue
message_infos.append(partial_line + m.group(1))
linestate = linestate_none
continue