Merge pull request #29378 from mrc0mmand/more-test-tweaks

test: a couple of TEST-82-SOFTREBOOT tweaks
This commit is contained in:
Frantisek Sumsal 2023-09-30 07:35:35 +00:00 committed by GitHub
commit e11fd4df14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View file

@ -7,7 +7,7 @@ set -o pipefail
. "$(dirname "$0")"/util.sh
get_first_boot_id() {
journalctl -b "${1:?}" -o json | jq -sr '.[0]._BOOT_ID'
journalctl -b "${1:?}" -o json -n +1 | jq -r '._BOOT_ID'
}
get_last_boot_id() {
@ -15,7 +15,7 @@ get_last_boot_id() {
}
get_first_timestamp() {
journalctl -b "${1:?}" -o json | jq -sr '.[0].__REALTIME_TIMESTAMP'
journalctl -b "${1:?}" -o json -n +1 | jq -r '.__REALTIME_TIMESTAMP'
}
get_last_timestamp() {

View file

@ -3,6 +3,19 @@
set -ex
set -o pipefail
at_exit() {
# Since the soft-reboot drops the enqueued end.service, we won't shutdown
# the test VM if the test fails and have to wait for the watchdog to kill
# us (which may take quite a long time). Let's just forcibly kill the machine
# instead to save CI resources.
if [[ $? -ne 0 ]]; then
echo >&2 "Test failed, shutting down the machine..."
systemctl poweroff -ff
fi
}
trap at_exit EXIT
systemd-analyze log-level debug
export SYSTEMD_LOG_LEVEL=debug
@ -84,7 +97,8 @@ elif [ -f /run/testsuite82.touch ]; then
test "$x" = "wuffwuff"
# Check that we got a PrepareForShutdownWithMetadata signal with the right type
test "$(jq .payload.data[1].type.data </run/testsuite82.signal)" = "\"soft-reboot\""
cat /run/testsuite82.signal
test "$(jq -r '.payload.data[1].type.data' </run/testsuite82.signal)" = "soft-reboot"
# Upload another entry
T="/dev/shm/fdstore.$RANDOM"
@ -181,9 +195,9 @@ EOF
# Check that we can set up an inhibitor, and that busctl monitor sees the
# PrepareForShutdownWithMetadata signal and that it says 'soft-reboot'.
systemd-run --unit busctl.service --property StandardOutput=file:/run/testsuite82.signal \
systemd-run --unit busctl.service -p Type=exec --property StandardOutput=file:/run/testsuite82.signal \
busctl monitor --json=pretty --match 'sender=org.freedesktop.login1,path=/org/freedesktop/login1,interface=org.freedesktop.login1.Manager,member=PrepareForShutdownWithMetadata,type=signal'
systemd-run --unit inhibit.service \
systemd-run --unit inhibit.service -p Type=exec \
systemd-inhibit --what=shutdown --who=test --why=test --mode=delay \
sleep infinity