test: add basic dracut test

Add a new basic test for the dracut stage. It uses a osbuild
pipeline to build an initrd and inspects it via the initrd.py
module. The content is compared to a reference located in the
same directory as the pipeline (test/data/stages/dracut/).
This commit is contained in:
Christian Kellner 2020-04-01 18:27:17 +02:00 committed by Tom Gundersen
parent 0fdbfa3c93
commit 47c15e5b41
4 changed files with 1397 additions and 0 deletions

View file

@ -13,6 +13,7 @@ import unittest
from typing import Dict
from osbuild.util import selinux
from .. import initrd
from .. import test
@ -187,6 +188,33 @@ class TestStages(test.TestBase):
with self.subTest(stage=test_name):
self.run_stage_diff_test(test_path)
def test_dracut(self):
datadir = self.locate_test_data()
base = os.path.join(datadir, "stages/dracut")
with open(f"{base}/vanilla.json", "r") as f:
refs = json.load(f)
with self.osbuild as osb:
with open(f"{base}/template.json", "r") as f:
manifest = f.read()
tree = osb.treeid_from_manifest(manifest)
osb.compile(manifest, checkpoints=[tree])
with osb.map_object(tree) as tree:
for name, want in refs.items():
image = initrd.Initrd(f"{tree}/boot/{name}")
have = image.as_dict()
for key in ["modules", "kmods"]:
a = set(have[key])
b = set(want[key])
self.assertEqual(a, b, msg=key)
# cache the downloaded data for the files source
osb.copy_source_data(self.store, "org.osbuild.files")
def test_selinux(self):
datadir = self.locate_test_data()
testdir = os.path.join(datadir, "stages", "selinux")