teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0334-test-replace-tail-f-with-journal-cursor-which-should.patch

c2dfb7
From b93a2617d49d9636801130d974995cabe6335b71 Mon Sep 17 00:00:00 2001
c2dfb7
From: Frantisek Sumsal <frantisek@sumsal.cz>
c2dfb7
Date: Mon, 1 Jul 2019 09:27:59 +0200
c2dfb7
Subject: [PATCH] test: replace `tail -f` with journal cursor which should
c2dfb7
 be...
c2dfb7
c2dfb7
more reliable
c2dfb7
c2dfb7
(cherry picked from commit d0b2178f3e79f302702bd7140766eee03643f734)
c2dfb7
c2dfb7
Related: #1808940
c2dfb7
---
c2dfb7
 test/TEST-36-NUMAPOLICY/testsuite.sh | 13 +++++++------
c2dfb7
 1 file changed, 7 insertions(+), 6 deletions(-)
c2dfb7
c2dfb7
diff --git a/test/TEST-36-NUMAPOLICY/testsuite.sh b/test/TEST-36-NUMAPOLICY/testsuite.sh
c2dfb7
index e15087b137..306a96b517 100755
c2dfb7
--- a/test/TEST-36-NUMAPOLICY/testsuite.sh
c2dfb7
+++ b/test/TEST-36-NUMAPOLICY/testsuite.sh
c2dfb7
@@ -29,6 +29,9 @@ testUnitNUMAConf="$testUnitFile.d/numa.conf"
c2dfb7
 journalSleep=5
c2dfb7
 sleepAfterStart=1
c2dfb7
 
c2dfb7
+# Journal cursor for easier navigation
c2dfb7
+journalCursorFile="jounalCursorFile"
c2dfb7
+
c2dfb7
 startStrace() {
c2dfb7
     coproc strace -qq -p 1 -o $straceLog -e set_mempolicy -s 1024 $1
c2dfb7
 }
c2dfb7
@@ -38,18 +41,16 @@ stopStrace() {
c2dfb7
 }
c2dfb7
 
c2dfb7
 startJournalctl() {
c2dfb7
-    coproc journalctl -u init.scope -f > $journalLog
c2dfb7
+    # Save journal's cursor for later navigation
c2dfb7
+    journalctl --no-pager --cursor-file="$journalCursorFile" -n0 -ocat
c2dfb7
 }
c2dfb7
 
c2dfb7
 stopJournalctl() {
c2dfb7
-    # Wait a few seconds until the messages get properly queued...
c2dfb7
-    sleep $journalSleep
c2dfb7
-    # ...and then force journald to write them to the backing storage
c2dfb7
-    # Also, using journalctl --sync should be better than using SIGRTMIN+1, as
c2dfb7
+    # Using journalctl --sync should be better than using SIGRTMIN+1, as
c2dfb7
     # the --sync wait until the synchronization is complete
c2dfb7
     echo "Force journald to write all queued messages"
c2dfb7
     journalctl --sync
c2dfb7
-    kill -s TERM $COPROC_PID
c2dfb7
+    journalctl -u init.scope --cursor-file="$journalCursorFile" > "$journalLog"
c2dfb7
 }
c2dfb7
 
c2dfb7
 checkNUMA() {