diff --git a/test/mod/test_util_chroot.py b/test/mod/test_util_chroot.py index 46d23e75..4b6812c9 100644 --- a/test/mod/test_util_chroot.py +++ b/test/mod/test_util_chroot.py @@ -5,6 +5,7 @@ import os from unittest.mock import call, patch +from osbuild.testutil import mock_command from osbuild.util.chroot import Chroot @@ -41,3 +42,15 @@ def test_chroot_context(mocked_run, tmp_path): call(["umount", "--lazy", os.fspath(tmp_path / "dev")], check=False), call(["umount", "--lazy", os.fspath(tmp_path / "sys")], check=False), ] + + +def test_chroot_integration(tmp_path): + # drop the first two arguments ("chroot", "target-dir") from our fake + # chroot + fake_chroot = r'exec "${@:2}"' + with mock_command("mount", ""), mock_command("umount", ""), mock_command("chroot", fake_chroot): + with Chroot(os.fspath(tmp_path)) as chroot: + ret = chroot.run(["/bin/true"], check=True) + assert ret.returncode == 0 + ret = chroot.run(["/bin/false"], check=False) + assert ret.returncode == 1