From: Daan De Meyer Date: Sun, 10 Dec 2023 09:54:31 +0000 (+0100) Subject: tests: Use temporary mount point X-Git-Tag: v20~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=745fd33af708e32a27dac6bc7bea80f290c31293;p=thirdparty%2Fmkosi.git tests: Use temporary mount point Instead of creating a directory owned by root in the cwd, let's just use a temporary directory that we remove again afterwards. --- diff --git a/tests/test_initrd.py b/tests/test_initrd.py index 095409c1e..428edc36a 100644 --- a/tests/test_initrd.py +++ b/tests/test_initrd.py @@ -97,10 +97,10 @@ def test_initrd_lvm(initrd: Image) -> None: run(["udevadm", "wait", "/dev/vg_mkosi/lv0"]) run([f"mkfs.{image.distribution.filesystem()}", "-L", "root", "/dev/vg_mkosi/lv0"]) - with mount(Path("/dev/vg_mkosi/lv0"), Path("mnt")) as mnt: + with tempfile.TemporaryDirectory() as mnt, mount(Path("/dev/vg_mkosi/lv0"), Path(mnt)): # The image might have been built unprivileged so we need to fix the file ownership. Making all the # files owned by root isn't completely correct but good enough for the purposes of the test. - copy_tree(Path(image.output_dir.name) / "image", mnt, preserve_owner=False) + copy_tree(Path(image.output_dir.name) / "image", Path(mnt), preserve_owner=False) stack.close() @@ -214,10 +214,10 @@ def test_initrd_luks_lvm(initrd: Image, passphrase: Path) -> None: run(["udevadm", "wait", "/dev/vg_mkosi/lv0"]) run([f"mkfs.{image.distribution.filesystem()}", "-L", "root", "/dev/vg_mkosi/lv0"]) - with mount(Path("/dev/vg_mkosi/lv0"), Path("mnt")) as mnt: + with tempfile.TemporaryDirectory() as mnt, mount(Path("/dev/vg_mkosi/lv0"), Path(mnt)): # The image might have been built unprivileged so we need to fix the file ownership. Making all the # files owned by root isn't completely correct but good enough for the purposes of the test. - copy_tree(Path(image.output_dir.name) / "image", mnt, preserve_owner=False) + copy_tree(Path(image.output_dir.name) / "image", Path(mnt), preserve_owner=False) stack.close()