New log-analysis checker LastLineContains
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
import re
|
||||
import os
|
||||
import logging
|
||||
from collections import deque
|
||||
|
||||
class Default:
|
||||
def run(file, opt=None):
|
||||
@@ -44,6 +45,14 @@ class ContainsString:
|
||||
return True, ""
|
||||
return False, f"could not find '{needle}' in logs"
|
||||
|
||||
class LastLineContains:
|
||||
def run(file, string):
|
||||
with open(file, "r") as f:
|
||||
last_line = deque(f, maxlen=1).pop()
|
||||
success = string in last_line
|
||||
log = "" if success else f"could not find '{string}' in last line"
|
||||
return success, log
|
||||
|
||||
class RetxCheck():
|
||||
def _parseList(s):
|
||||
if not s:
|
||||
|
||||
@@ -94,5 +94,21 @@ UE 257a: ulsch_rounds 41777/2863/10/0, ulsch_errors 0, ulsch_DTX 17, BLER 0.1145
|
||||
self.assertFalse(result)
|
||||
self.assertEqual(log, expected)
|
||||
|
||||
def test_last_line_contains_false(self):
|
||||
f = "tests/log-analysis/arbitrary.log"
|
||||
opt = "Bye."
|
||||
result, log = cls_loganalysis.LastLineContains.run(f, opt)
|
||||
expected = f"could not find '{opt}' in last line"
|
||||
self.assertFalse(result)
|
||||
self.assertEqual(log, expected)
|
||||
|
||||
def test_last_line_contains_false(self):
|
||||
f = "tests/log-analysis/arbitrary.log"
|
||||
opt = "got sync"
|
||||
result, log = cls_loganalysis.LastLineContains.run(f, opt)
|
||||
expected = ""
|
||||
self.assertTrue(result)
|
||||
self.assertEqual(log, expected)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[UTIL] threadCreate() for L1_rx_thread: creating thread (no affinity, default priority)
|
||||
[UTIL] threadCreate() for L1_tx_thread: creating thread (no affinity, default priority)
|
||||
[UTIL] threadCreate() for L1_stats: creating thread (no affinity, default priority)
|
||||
TYPE <CTRL-C> TO TERMINATE
|
||||
[PHY] got sync (ru_thread)
|
||||
[PHY] RU 0 rf device ready
|
||||
[PHY] RU 0 RF started cpu_meas_enabled 0
|
||||
[HW] No connected device, generating void samples...
|
||||
[PHY] got sync (L1_stats_thread)
|
||||
Reference in New Issue
Block a user