Introduce EndsWithBye log analysis check
It was initially foreseen to just check the program exit code, but most executables don't return with 0 (so the CI would always fail). Add a separate check that will check for the Bye., only going through the last X lines instead of the entire file.
This commit is contained in:
@@ -53,6 +53,19 @@ class LastLineContains:
|
||||
log = "" if success else f"could not find '{string}' in last line"
|
||||
return success, log
|
||||
|
||||
class EndsWithBye:
|
||||
def run(file, option):
|
||||
# no option: we ignore any
|
||||
with open(file, "r") as f:
|
||||
n = 0
|
||||
for line in reversed(f.readlines()):
|
||||
if re.search(r'^Bye.\n', line, re.MULTILINE) is not None:
|
||||
return True, ""
|
||||
n = n + 1
|
||||
if n > 50: # if not found in last 50 lines, assume it does not exist
|
||||
break
|
||||
return False, "No Bye. message found, did not stop properly"
|
||||
|
||||
class RetxCheck():
|
||||
def _parseList(s):
|
||||
if not s:
|
||||
|
||||
@@ -110,5 +110,22 @@ UE 257a: ulsch_rounds 41777/2863/10/0, ulsch_errors 0, ulsch_DTX 17, BLER 0.1145
|
||||
self.assertTrue(result)
|
||||
self.assertEqual(log, expected)
|
||||
|
||||
def test_ends_no_bye(self):
|
||||
f = "tests/log-analysis/arbitrary.log"
|
||||
opt = None
|
||||
result, log = cls_loganalysis.EndsWithBye.run(f, opt)
|
||||
expected = "No Bye. message found, did not stop properly"
|
||||
self.assertFalse(result)
|
||||
self.assertEqual(log, expected)
|
||||
|
||||
def test_ends_with_bye(self):
|
||||
f = "tests/log-analysis/with-bye.log"
|
||||
opt = None
|
||||
result, log = cls_loganalysis.EndsWithBye.run(f, opt)
|
||||
expected = ""
|
||||
self.assertTrue(result)
|
||||
self.assertEqual(log, expected)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Some other logs
|
||||
Bye.
|
||||
process exited.
|
||||
Reference in New Issue
Block a user