diff options
-rwxr-xr-x | initramfs-init.in | 6 | ||||
-rwxr-xr-x | tests/initramfs-init.test | 21 |
2 files changed, 23 insertions, 4 deletions
diff --git a/initramfs-init.in b/initramfs-init.in index 4608646..297bac6 100755 --- a/initramfs-init.in +++ b/initramfs-init.in @@ -651,14 +651,14 @@ if [ -n "$KOPT_root" ]; then if [ -n "$KOPT_resume" ]; then echo "Resume from disk" - if [ -e /sys/power/resume ]; then + if [ -e $ROOT/sys/power/resume ]; then case "$KOPT_resume" in UUID*|LABEL*) resume_dev=$(findfs "$KOPT_resume");; *) resume_dev="$KOPT_resume";; esac - printf "%d:%d" $(stat -Lc "0x%t 0x%T" "$resume_dev") >/sys/power/resume + printf "%d:%d" $(stat -Lc "0x%t 0x%T" "$resume_dev") > $ROOT/sys/power/resume if [ -n "$KOPT_resume_offset" ]; then - echo "$KOPT_resume_offset" > /sys/power/resume_offset + echo "$KOPT_resume_offset" > $ROOT/sys/power/resume_offset fi else echo "resume: no hibernation support found" diff --git a/tests/initramfs-init.test b/tests/initramfs-init.test index ab873ae..92e370b 100755 --- a/tests/initramfs-init.test +++ b/tests/initramfs-init.test @@ -23,7 +23,8 @@ init_tests \ initramfs_init_tmpfs_root_ip_dhcp_first_up \ initramfs_init_tmpfs_root_ip_dhcp_BOOTIF \ initramfs_init_aoe \ - initramfs_init_wireguard + initramfs_init_wireguard \ + initramfs_init_resume_offset fake_cmdline() { mkdir -p proc @@ -419,3 +420,21 @@ initramfs_init_wireguard_body() { -o match:'modprobe.*wireguard' \ initramfs-init } + +initramfs_init_resume_offset_body() { + fake_cmdline "root=fake_dev resume=fake_dev resume_offset=3549184" + fake_sysroot_init + fake_switch_root + + mkdir -p sys/power + touch sys/power/resume + touch fake_dev + + atf_check \ + -o ignore \ + initramfs-init + atf_check \ + -o match:'3549184' \ + cat sys/power/resume_offset +} + |