From 735058f5c4b0f8af7883de77e010c081bd57c181 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 19 Feb 2026 11:28:54 +0100 Subject: [PATCH] New log-analysis checker LastLineContains --- ci-scripts/cls_loganalysis.py | 9 +++++++++ ci-scripts/tests/log-analysis.py | 16 ++++++++++++++++ ci-scripts/tests/log-analysis/arbitrary.log | 9 +++++++++ 3 files changed, 34 insertions(+) create mode 100644 ci-scripts/tests/log-analysis/arbitrary.log diff --git a/ci-scripts/cls_loganalysis.py b/ci-scripts/cls_loganalysis.py index f4de1258b8..38c36202bd 100644 --- a/ci-scripts/cls_loganalysis.py +++ b/ci-scripts/cls_loganalysis.py @@ -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: diff --git a/ci-scripts/tests/log-analysis.py b/ci-scripts/tests/log-analysis.py index 6d5f6c5bd7..a4416305a8 100644 --- a/ci-scripts/tests/log-analysis.py +++ b/ci-scripts/tests/log-analysis.py @@ -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() diff --git a/ci-scripts/tests/log-analysis/arbitrary.log b/ci-scripts/tests/log-analysis/arbitrary.log new file mode 100644 index 0000000000..095690aeb3 --- /dev/null +++ b/ci-scripts/tests/log-analysis/arbitrary.log @@ -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 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)