]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: check the numa-test.service status directly
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 8 Sep 2022 10:27:46 +0000 (12:27 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 8 Sep 2022 15:00:26 +0000 (15:00 +0000)
In a couple of recent CI runs I noticed TEST-36 failing due to a missed
service exit notification and a subsequent fail of the `grep` command:

```
[  257.112153] H systemd[1]: Started numa-test.service.
[  257.114343] H systemd[899]: numa-test.service: Failed to set NUMA memory policy: Invalid argument
[  257.118270] H systemd[899]: numa-test.service: Failed at step NUMA_POLICY spawning /bin/sleep: Invalid argument
[  257.126170] H systemd[1]: Bus private-bus-connection: changing state RUNNING → CLOSING
[  257.130290] H systemd[1]: numa-test.service: Failed to send unit change signal for numa-test.service: Connection reset by peer
[  257.131567] H systemd[1]: Received SIGCHLD from PID 899 ((sleep)).
[  257.132870] H systemd[1]: Got disconnect on private connection.
[  257.134299] H systemd[1]: systemd-journald.service: Got notification message from PID 498 (FDSTORE=1)
[  257.135611] H systemd[1]: systemd-journald.service: Added fd 38 (n/a) to fd store.
[  257.136999] H systemd[1]: systemd-journald.service: Received EPOLLHUP on stored fd 38 (stored), closing.
[  257.366996] H testsuite-36.sh[536]: + stopJournalctl
[  257.366996] H testsuite-36.sh[536]: + local unit=init.scope
[  257.366996] H testsuite-36.sh[536]: + echo 'Force journald to write all queued messages'
[  257.366996] H testsuite-36.sh[536]: Force journald to write all queued messages
[  257.366996] H testsuite-36.sh[536]: + journalctl --sync
[  257.488642] H systemd-journald[498]: Received client request to rotate journal.
[  257.520821] H testsuite-36.sh[536]: + journalctl -u init.scope --cursor-file=jounalCursorFile
[  257.981399] H testsuite-36.sh[536]: + pid1StopUnit numa-test.service
[  257.984533] H testsuite-36.sh[536]: + systemctl stop numa-test.service
[  258.173656] H systemd[1]: Bus private-bus-connection: changing state AUTHENTICATING → RUNNING
[  258.180710] H systemd[1]: numa-test.service: Trying to enqueue job numa-test.service/stop/replace
[  258.182424] H systemd[1]: Added job numa-test.service/stop to transaction.
[  258.185234] H systemd[1]: numa-test.service: Installed new job numa-test.service/stop as 738
[  258.187017] H systemd[1]: numa-test.service: Enqueued job numa-test.service/stop as 738
[  258.239930] H testsuite-36.sh[536]: + grep 'numa-test.service: Main process exited, code=exited, status=242/NUMA' journal.log
```

Let's mitigate this by checking the test service exit status directly
instead of relying on the notification.

test/units/testsuite-36.sh

index 6827a7665d33ebc0f3fa5863b4ec3869f9d3d47b..9705f2db86f7606c9605f9cc0ef2318a546bdfd4 100755 (executable)
@@ -243,7 +243,7 @@ else
     writeTestUnitNUMAPolicy "bind"
     pid1StartUnitWithJournal "$testUnit"
     pid1StopUnit "$testUnit"
-    grep "numa-test.service: Main process exited, code=exited, status=242/NUMA" "$journalLog"
+    [[ $(systemctl show "$testUnit" -P ExecMainStatus) == "242" ]]
 
     echo "Unit file NUMAPolicy support - Bind policy w/ mask"
     writeTestUnitNUMAPolicy "bind" "0"
@@ -256,7 +256,7 @@ else
     writeTestUnitNUMAPolicy "interleave"
     pid1StartUnitWithStrace "$testUnit"
     pid1StopUnit "$testUnit"
-    grep "numa-test.service: Main process exited, code=exited, status=242/NUMA" "$journalLog"
+    [[ $(systemctl show "$testUnit" -P ExecMainStatus) == "242" ]]
 
     echo "Unit file NUMAPolicy support - Interleave policy w/ mask"
     writeTestUnitNUMAPolicy "interleave" "0"
@@ -270,7 +270,7 @@ else
     pid1StartUnitWithJournal "$testUnit"
     systemctlCheckNUMAProperties "$testUnit" "preferred"
     pid1StopUnit "$testUnit"
-    grep "numa-test.service: Main process exited, code=exited, status=242/NUMA" "$journalLog" && { echo >&2 "unexpected pass"; exit 1; }
+    [[ $(systemctl show "$testUnit" -P ExecMainStatus) == "242" ]] && { echo >&2 "unexpected pass"; exit 1; }
 
     echo "Unit file NUMAPolicy support - Preferred policy w/ mask"
     writeTestUnitNUMAPolicy "preferred" "0"