Skip to content

Commit 618df02

Browse files
committed
add tests for the mask system
Signed-off-by: Zen <[email protected]>
1 parent 7e15719 commit 618df02

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_ugrd.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
from zenlib.logging import loggify
55

66

7+
def bad_function(self):
8+
"""A function that should not be called."""
9+
return "exit 1"
10+
11+
712
@loggify
813
class TestUGRD(TestCase):
914
def test_fullauto(self):
@@ -16,6 +21,20 @@ def test_bad_config(self):
1621
with self.assertRaises(ValueError):
1722
InitramfsGenerator(logger=self.logger, config="tests/bad_config.toml")
1823

24+
def test_bad_mask(self):
25+
"""Test that masking a critical function raises an error."""
26+
generator = InitramfsGenerator(logger=self.logger, config="tests/fullauto.toml")
27+
generator["masks"] = {"init_final": "do_switch_root"}
28+
with self.assertRaises(RuntimeError):
29+
generator.build()
30+
31+
def test_good_mask(self):
32+
""" Tests that masking a broken function resolves a boot issue. """
33+
generator = InitramfsGenerator(logger=self.logger, config="tests/fullauto.toml")
34+
generator["imports"]["init_main"] += bad_function
35+
generator["masks"] = {"init_main": "bad_function"}
36+
generator.build()
37+
1938
def test_no_root(self):
2039
"""Test without a rootfs which can be found, should cause the initramfs to restart."""
2140
generator = InitramfsGenerator(

0 commit comments

Comments
 (0)