test: add minimal test for container based building of images

This commit adds a smoke test that builds the ibcli container
and runs a fedora-41 raw-minimal build to double check that
the container based building actually works.

Thanks to Ondrej for suggesting this.
This commit is contained in:
Michael Vogt 2024-12-18 09:41:31 +01:00
parent fad02336b3
commit e7d8a39fcf
6 changed files with 62 additions and 10 deletions

27
test/test_container.py Normal file
View file

@ -0,0 +1,27 @@
import os
import subprocess
import pytest
from containerbuild import build_container_fixture
@pytest.mark.skipif(os.getuid() != 0, reason="needs root")
def test_container_builds_image(tmp_path, build_container):
output_dir = tmp_path / "output"
output_dir.mkdir()
subprocess.check_call([
"podman", "run",
"--privileged",
"-v", f"{output_dir}:/output",
build_container,
"build",
"minimal-raw",
"--distro", "fedora-41"
])
arch = "x86_64"
assert (output_dir / f"fedora-41-minimal-raw-{arch}/xz/disk.raw.xz").exists()
# XXX: ensure no other leftover dirs
dents = os.listdir(output_dir)
assert len(dents) == 1, f"too many dentries in output dir: {dents}"