Skip to content

Commit 977e660

Browse files
truffle0desultory
authored andcommitted
Added basic, incomplete tests for hibernate/resume
builds successfully, but still need to figure out why qemu fails
1 parent e4cc3fa commit 977e660

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

src/ugrd/base/test.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ test_rootfs_name = 'ugrd-test-rootfs'
22
test_rootfs_build_dir = 'initramfs_test_rootfs'
33
test_image_size = 16
44

5-
test_copy_config = ["_mounts", "mounts", "out_dir", "tmpdir", "clean", "test_image_size", "test_flag", "cryptsetup"]
5+
test_copy_config = ["mounts", "out_dir", "tmpdir", "clean", "test_image_size", "test_flag", "cryptsetup"]
6+
kmod_init = ["ata_piix", "sd_mod"]
67

78
test_memory = '256M'
89
test_cpu = 'host'
910
test_arch = 'x86_64'
1011
test_timeout = 15
1112
test_cmdline = 'console=ttyS0,115200 panic=1'
12-
qemu_bool_args = ['nographic', 'no-reboot', 'enable-kvm']
13+
#qemu_bool_args = ['nographic', 'no-reboot', 'enable-kvm']
14+
qemu_bool_args = ['nographic', 'enable-kvm' ]
1315

1416
[imports.build_pre]
1517
"ugrd.base.test" = [ "init_test_vars" ]

src/ugrd/fs/resume.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,13 @@ def handle_early_resume(self) -> None:
6262
def handle_late_resume(self) -> None:
6363
self.logger.warning("[late_resume] enabled, this can result in data loss if filesystems are modified before resuming. Read the docs for more info.")
6464
return handle_early_resume(self) # At the moment it's the same code but delayed, will change when more features are added
65+
66+
@contains("test_resume")
67+
def test_init_swap_uuid(self):
68+
if "test_cpu" in self:
69+
from uuid import uuid4
70+
self["test_swap_uuid"] = swap_uuid = uuid4()
71+
72+
# append to test kernel cmdline and adjust planned image size to allow enough space
73+
self["test_cmdline"] = f'{self.get("test_cmdline")} resume=UUID={swap_uuid}'
74+
self["test_image_size"] = 256 + self.get("test_image_size")

src/ugrd/fs/resume.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
cmdline_strings = [ "resume" ]
22
binaries = [ 'lsblk' ]
3+
test_copy_config = [ "test_resume", "test_swap_uuid" ]
4+
5+
[imports.build_pre]
6+
"ugrd.fs.resume" = [ "test_init_swap_uuid" ]
37

48
[imports.init_main]
59
"ugrd.fs.resume" = [ "handle_early_resume" ]
@@ -12,7 +16,8 @@ binaries = [ 'lsblk' ]
1216

1317
[custom_parameters]
1418
late_resume = "bool"
19+
test_resume = "bool"
20+
test_swap_uuid = "str"
1521

1622
[import_order.before]
1723
handle_resume = "mount_fstab"
18-

src/ugrd/fs/test_image.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ _cryptsetup_root = "root"
99
[imports.build_pre]
1010
"ugrd.fs.test_image" = ["init_banner"]
1111

12+
[imports.init_main]
13+
"ugrd.fs.test_image" = ["resume_tests"]
14+
15+
[imports.init_final]
16+
"ugrd.fs.test_image" = ["complete_tests"]
17+
1218
[imports.pack]
1319
"ugrd.fs.test_image" = ["make_test_image"]
1420

@@ -20,4 +26,4 @@ cryptsetup = "dict" # Same as above
2026
_cryptsetup_root = "str" # Define the root device for cryptsetup
2127
test_image_size = "int" # Define the size of the test image in MiB
2228
test_flag = "str" # Define the success flag used to determine if the test was successful
23-
29+
test_resume = "bool" # Enable code to test the suspend/resume pathways

0 commit comments

Comments
 (0)