test: introduce TEST-09-REBOOT

To test stuff involving state preserved across (multiple) reboots, like
journal boot IDs.
This commit is contained in:
Frantisek Sumsal
2023-09-27 14:50:19 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent bb83c7c633
commit c1b129f4ad
7 changed files with 143 additions and 1 deletions
+23 -1
View File
@@ -3,6 +3,9 @@
# Utility functions for shell tests
# shellcheck disable=SC2034
[[ -e /var/tmp/.systemd_reboot_count ]] && REBOOT_COUNT="$(</var/tmp/.systemd_reboot_count)" || REBOOT_COUNT=0
assert_true() {(
set +ex
@@ -16,7 +19,6 @@ assert_true() {(
fi
)}
assert_eq() {(
set +ex
@@ -57,6 +59,11 @@ assert_rc() {(
assert_eq "$rc" "$exp"
)}
assert_not_reached() {
echo >&2 "Code should not be reached at ${BASH_SOURCE[1]}:${BASH_LINENO[1]}, function ${FUNCNAME[1]}()"
exit 1
}
run_and_grep() {(
set +ex
@@ -149,3 +156,18 @@ create_dummy_container() {
cp -a /testsuite-13-container-template/* "$root"
coverage_create_nspawn_dropin "$root"
}
# Bump the reboot counter and call systemctl with the given arguments
systemctl_final() {
local counter
if [[ $# -eq 0 ]]; then
echo >&2 "Missing arguments"
exit 1
fi
[[ -e /var/tmp/.systemd_reboot_count ]] && counter="$(</var/tmp/.systemd_reboot_count)" || counter=0
echo "$((counter + 1))" >/var/tmp/.systemd_reboot_count
systemctl "$@"
}