|
3 | 3 | from zenlib.util import contains |
4 | 4 |
|
5 | 5 |
|
| 6 | +@contains("test_resume") |
| 7 | +def setup_resume_tests(self) -> None: |
| 8 | + if "ugrd.base.test" in self["modules"]: |
| 9 | + from uuid import uuid4 |
| 10 | + |
| 11 | + # Create a uuid for the swap partition in the test image |
| 12 | + if not self["test_swap_uuid"]: |
| 13 | + self["test_swap_uuid"] = uuid4() |
| 14 | + |
| 15 | + # pull in the hibernation/resume testing module |
| 16 | + self["test_modules"] = "ugrd.fs.test_resume" |
| 17 | + |
| 18 | + # append resume partition to QEMU kernel cmdline |
| 19 | + self["test_cmdline"] = f"resume=UUID={self['test_swap_uuid']}" |
| 20 | + |
| 21 | + |
6 | 22 | def resume(self) -> str: |
7 | 23 | """Returns a shell script handling resume from hibernation. |
8 | 24 | Checks that /sys/power/resume is writable, resume= is set, and noresume is not set, if so, |
@@ -30,8 +46,7 @@ def resume(self) -> str: |
30 | 46 |
|
31 | 47 | [ -b "$1" ] || (ewarn "\'$1\' is not a valid block device!" ; return 1) |
32 | 48 | einfo "Attempting resume from: $1" |
33 | | - # TODO: This could maybe be printf? |
34 | | - echo -n "$1" > /sys/power/resume |
| 49 | + printf "%s" "$1" > /sys/power/resume |
35 | 50 | einfo "No image on: $resume" |
36 | 51 | return 0 |
37 | 52 | """ |
@@ -70,17 +85,3 @@ def handle_late_resume(self) -> None: |
70 | 85 |
|
71 | 86 | # At the moment it's the same code but delayed, will change when more features are added |
72 | 87 | return handle_early_resume(self) |
73 | | - |
74 | | -@contains("test_resume") |
75 | | -def test_resume_setup(self) -> None: |
76 | | - if "ugrd.base.test" in self["modules"]: |
77 | | - # Add resume to the list of test modules |
78 | | - self["test_modules"] = "ugrd.fs.test_resume" |
79 | | - |
80 | | - # Create a uuid for the swap partition in the test image |
81 | | - from uuid import uuid4 |
82 | | - if not self["test_swap_uuid"]: |
83 | | - self["test_swap_uuid"] = swap_uuid = uuid4() |
84 | | - |
85 | | - # append to QEMU kernel cmdline |
86 | | - self["test_cmdline"] = f"{self.get('test_cmdline')} resume=UUID={swap_uuid}" |
|
0 commit comments