From a0b44c5c7246d321497eaf9c384aedfdf39025c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Wed, 14 Aug 2024 21:50:01 +0200 Subject: [PATCH] Test/stages: check dracut stage output for environment warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extend the dracut stage test case with checks for error / warning messages complaining about unsupported / incorrect runtime environment. Messages such as: ``` /dev/fd/63: No such file or directory ``` or ``` /proc/ is not mounted. This is not a supported mode of operation. Please fix your invocation environment to mount /proc/ and /sys/ properly. Proceeding anyway. Your mileage may vary. ``` The stage will be fixed in the next commit. Signed-off-by: Tomáš Hozza --- test/run/test_stages.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/run/test_stages.py b/test/run/test_stages.py index 2e9b543b..17c2db5b 100644 --- a/test/run/test_stages.py +++ b/test/run/test_stages.py @@ -9,6 +9,7 @@ import json import os import pprint import random +import re import shutil import string import subprocess @@ -261,10 +262,21 @@ class TestStages(test.TestBase): with self.osbuild as osb, tempfile.TemporaryDirectory(dir="/var/tmp") as outdir: - osb.compile_file(f"{base}/template.json", - checkpoints=["tree"], - exports=["tree"], - output_dir=outdir) + output = osb.compile_file(f"{base}/template.json", + checkpoints=["tree"], + exports=["tree"], + output_dir=outdir) + + # check that there are no complains about the runtime environment + tree_stages_log = output["log"]["tree"] + dracut_stages = [stage for stage in tree_stages_log if stage["type"] == "org.osbuild.dracut"] + assert len(dracut_stages) == 1 + dracut_stage_log = dracut_stages[0]["output"] + proc_warnings_re = re.compile(r'.*\/proc\/ is not mounted\. This is not a supported mode of operation\..*') + assert proc_warnings_re.search(dracut_stage_log, re.DOTALL) is None + dev_warnings_re = re.compile(r'.*\/dev\/fd\/63: No such file or directory.*') + assert dev_warnings_re.search(dracut_stage_log, re.DOTALL) is None + tree = os.path.join(outdir, "tree") for name, want in refs.items():