Skip to content
Snippets Groups Projects
Commit d80e8d39 authored by Zygmunt Krynicki's avatar Zygmunt Krynicki
Browse files

boot: add integration test for reboot delay


Both the grub and piboot tests are modified to exercise the delayed
reboot quirk.

Signed-off-by: default avatarZygmunt Krynicki <zygmunt.krynicki@huawei.com>
parent dae1914f
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,9 @@ summary: play-through of "rauc install" with GRUB backend ...@@ -6,6 +6,9 @@ summary: play-through of "rauc install" with GRUB backend
# sandbox blocking that. It would only work if RAUC would be able to detect # sandbox blocking that. It would only work if RAUC would be able to detect
# and handle that situation and switch to FUSE. This test works fine in qemu. # and handle that situation and switch to FUSE. This test works fine in qemu.
backends: [-lxd] backends: [-lxd]
environment:
REBOOT_DELAY/quirk: 10
REBOOT_DELAY/none: 0
prepare: | prepare: |
mkdir bundle-dir mkdir bundle-dir
mkdir system-dir mkdir system-dir
...@@ -50,6 +53,16 @@ prepare: | ...@@ -50,6 +53,16 @@ prepare: |
truncate --size=0 /var/{backend,pre-install,post-install}.log truncate --size=0 /var/{backend,pre-install,post-install}.log
echo 0 >/tmp/backend.state echo 0 >/tmp/backend.state
# Stop sysotad for the modification.
systemctl stop sysotad.service
# Add runtime override to set up reboot quirk.
cat <<SYSOTAD_CONF >/run/sysota/sysotad.conf
# Configure the reboot delay quirk.
[Quirks]
RebootDelay=$REBOOT_DELAY
SYSOTAD_CONF
execute: | execute: |
# Slot A is active, other variables are unset. # Slot A is active, other variables are unset.
grub-editenv "$SYSOTA_BOOT_DIR"/grubenv list | grep -E ^SYSOTA_ | MATCH '^SYSOTA_BOOT_ACTIVE=A$' grub-editenv "$SYSOTA_BOOT_DIR"/grubenv list | grep -E ^SYSOTA_ | MATCH '^SYSOTA_BOOT_ACTIVE=A$'
...@@ -63,7 +76,13 @@ execute: | ...@@ -63,7 +76,13 @@ execute: |
grub-editenv "$SYSOTA_BOOT_DIR"/grubenv list | grep -E ^SYSOTA_ | MATCH '^SYSOTA_BOOT_TRY=B$' grub-editenv "$SYSOTA_BOOT_DIR"/grubenv list | grep -E ^SYSOTA_ | MATCH '^SYSOTA_BOOT_TRY=B$'
grub-editenv "$SYSOTA_BOOT_DIR"/grubenv list | grep -E ^SYSOTA_ | NOMATCH '^SYSOTA_BOOT_TRIED=.*' grub-editenv "$SYSOTA_BOOT_DIR"/grubenv list | grep -E ^SYSOTA_ | NOMATCH '^SYSOTA_BOOT_TRIED=.*'
# The system attempted to reboot. # The system did not reboot immediately.
if [ "$REBOOT_DELAY" -ne 0 ]; then
test ! -f "$MOCK_REBOOT_LOG"
sleep "$REBOOT_DELAY"
fi
# With sufficient time, the system did reboot.
test -f "$MOCK_REBOOT_LOG" test -f "$MOCK_REBOOT_LOG"
MATCH '^/usr/sbin/reboot$' "$MOCK_REBOOT_LOG" MATCH '^/usr/sbin/reboot$' "$MOCK_REBOOT_LOG"
...@@ -74,6 +93,7 @@ restore: | ...@@ -74,6 +93,7 @@ restore: |
rm -f *.img rm -f *.img
rm -f cursor rm -f cursor
rm -f cmdline{,.orig} rm -f cmdline{,.orig}
rm -f /run/sysota/sysotad.conf
debug: | debug: |
cat /proc/cmdline cat /proc/cmdline
......
...@@ -6,6 +6,9 @@ summary: play-through of "rauc install" ...@@ -6,6 +6,9 @@ summary: play-through of "rauc install"
# sandbox blocking that. It would only work if RAUC would be able to detect # sandbox blocking that. It would only work if RAUC would be able to detect
# and handle that situation and switch to FUSE. This test works fine in qemu. # and handle that situation and switch to FUSE. This test works fine in qemu.
backends: [-lxd] backends: [-lxd]
environment:
REBOOT_DELAY/quirk: 10
REBOOT_DELAY/none: 0
prepare: | prepare: |
mkdir bundle-dir mkdir bundle-dir
mkdir system-dir mkdir system-dir
...@@ -66,6 +69,16 @@ prepare: | ...@@ -66,6 +69,16 @@ prepare: |
truncate --size=0 /var/{backend,pre-install,post-install}.log truncate --size=0 /var/{backend,pre-install,post-install}.log
echo 0 >/tmp/backend.state echo 0 >/tmp/backend.state
# Stop sysotad for the modification.
systemctl stop sysotad.service
# Add runtime override to set up reboot quirk.
cat <<SYSOTAD_CONF >/run/sysota/sysotad.conf
# Configure the reboot delay quirk.
[Quirks]
RebootDelay=$REBOOT_DELAY
SYSOTAD_CONF
execute: | execute: |
rauc install bundle.img rauc install bundle.img
...@@ -73,6 +86,13 @@ execute: | ...@@ -73,6 +86,13 @@ execute: |
MATCH "kernel=new-kernel.img" "$SYSOTA_BOOT_DIR/tryboot.txt" MATCH "kernel=new-kernel.img" "$SYSOTA_BOOT_DIR/tryboot.txt"
MATCH "new-cmdline-text root=/var/tmp/rauc-fake-system/slot-b rauc.slot=B" "$SYSOTA_BOOT_DIR/slot-b/cmdline.txt" MATCH "new-cmdline-text root=/var/tmp/rauc-fake-system/slot-b rauc.slot=B" "$SYSOTA_BOOT_DIR/slot-b/cmdline.txt"
# The system did not reboot immediately.
if [ "$REBOOT_DELAY" -ne 0 ]; then
test ! -f "$MOCK_REBOOT_LOG"
sleep "$REBOOT_DELAY"
fi
# With sufficient time, the system did reboot.
test -f "$MOCK_REBOOT_LOG" test -f "$MOCK_REBOOT_LOG"
MATCH '^/usr/sbin/reboot 0\\ tryboot$' "$MOCK_REBOOT_LOG" MATCH '^/usr/sbin/reboot 0\\ tryboot$' "$MOCK_REBOOT_LOG"
...@@ -83,6 +103,7 @@ restore: | ...@@ -83,6 +103,7 @@ restore: |
rm -f *.img rm -f *.img
rm -f cursor rm -f cursor
rm -f cmdline{,.orig} rm -f cmdline{,.orig}
rm -f /run/sysota/sysotad.conf
debug: | debug: |
cat /proc/cmdline cat /proc/cmdline
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment