tests: Add simple test for org.osuild.grub2.inst stage
Tests that grub2-mkimage ran without errors, and that the image file actually has something written to it.
This commit is contained in:
parent
67f344fa52
commit
41c0550a1f
1 changed files with 33 additions and 0 deletions
33
stages/test/test_grub2_inst.py
Normal file
33
stages/test/test_grub2_inst.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/python3
|
||||
import os
|
||||
|
||||
STAGE_NAME = "org.osbuild.grub2.inst"
|
||||
|
||||
def test_grub2_partition(tmp_path, stage_module):
|
||||
treedir = tmp_path / "tree"
|
||||
os.makedirs(treedir, exist_ok=True)
|
||||
with open(treedir / "disk.img", "wb") as f:
|
||||
f.write(b"Just testing")
|
||||
|
||||
options = {
|
||||
"filename": "disk.img",
|
||||
"platform": "i386-pc",
|
||||
"location": 0,
|
||||
"core": {
|
||||
"type": "mkimage",
|
||||
"partlabel": "gpt",
|
||||
"filesystem": "ext4",
|
||||
},
|
||||
"prefix": {
|
||||
"type": "partition",
|
||||
"partlabel": "gpt",
|
||||
"number": 0,
|
||||
"path": "/boot/",
|
||||
},
|
||||
}
|
||||
stage_module.main(treedir, options)
|
||||
|
||||
# Make sure the test string is overwritten
|
||||
with open(treedir / "disk.img", "rb") as f:
|
||||
msg = f.read(12)
|
||||
assert msg != b"Just testing"
|
||||
Loading…
Add table
Add a link
Reference in a new issue