diff --git a/.ci/pytest.sh b/.ci/pytest.sh index 39eb3b53..d3080a68 100755 --- a/.ci/pytest.sh +++ b/.ci/pytest.sh @@ -10,6 +10,9 @@ if [ "$(id -u)" = 0 ]; then openssl \ py3-pytest \ py3-pytest-cov \ + kpartx \ + losetup \ + android-tools \ sudo exec su "${TESTUSER:-build}" -c "sh -e $0" fi diff --git a/test/chroot/test_apk.py b/test/chroot/test_apk.py index 3df02691..529bc65c 100644 --- a/test/chroot/test_apk.py +++ b/test/chroot/test_apk.py @@ -78,7 +78,7 @@ def apk_mocks(monkeypatch) -> dict | None: def create_apk(pkgname: str, arch: Arch) -> Path: - apk_file = get_context().config.work / "packages" / "edge" / arch / f"{pkgname}-5.5-r0.apk" + apk_file = get_context().config.cache / "packages" / "edge" / arch / f"{pkgname}-5.5-r0.apk" apk_file.parent.mkdir(parents=True, exist_ok=True) apk_file.touch() return apk_file diff --git a/test/config/test_config_serde.py b/test/config/test_config_serde.py index e829f473..6bb65939 100644 --- a/test/config/test_config_serde.py +++ b/test/config/test_config_serde.py @@ -24,4 +24,4 @@ def test_load(config_file): assert config.ui == "gnome" assert config.providers == {} assert config.mirrors["pmaports"] is not None - assert ".pytest_tmp" in config.work.parts + assert ".pytest_tmp" in config.cache.parts diff --git a/test/conftest.py b/test/conftest.py index e27fb39e..bc19d8cd 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -148,10 +148,10 @@ def pmb_args(config_file, mock_context, logfile): init_args(args) - print(f"WORK: {get_context().config.work}") + print(f"WORK: {get_context().config.cache}") # Sanity check - assert ".pytest_tmp" in get_context().config.work.parts + assert ".pytest_tmp" in get_context().config.cache.parts @pytest.fixture diff --git a/test/core/test_chroot.py b/test/core/test_chroot.py index db9cd02d..5f4e5d01 100644 --- a/test/core/test_chroot.py +++ b/test/core/test_chroot.py @@ -8,26 +8,26 @@ from pmb.core.context import get_context from pmb.core.chroot import Chroot, ChrootType -def test_valid_chroots(pmb_args, mock_devices_find_path): +def test_valid_chroots(pmb_args, mock_devices_find_path, foreign_arch): """Test that Chroot objects work as expected""" - work = get_context().config.work + localdir = get_context().config.work chroot = Chroot.native() assert chroot.type == ChrootType.NATIVE assert chroot.name == "" assert chroot.arch in Arch.supported() assert not chroot.exists() # Shouldn't be created - assert chroot.path == work / "chroot_native" + assert chroot.path == localdir / "chroot_native" assert str(chroot) == "native" - chroot = Chroot.buildroot(Arch.aarch64) + chroot = Chroot.buildroot(foreign_arch) assert chroot.type == ChrootType.BUILDROOT - assert chroot.name == "aarch64" - assert chroot.arch == Arch.aarch64 + assert chroot.name == f"{foreign_arch}" + assert chroot.arch == foreign_arch assert not chroot.exists() # Shouldn't be created - assert chroot.path == work / "chroot_buildroot_aarch64" - assert str(chroot) == "buildroot_aarch64" + assert chroot.path == localdir / f"chroot_buildroot_{foreign_arch}" + assert str(chroot) == f"buildroot_{foreign_arch}" # FIXME: implicily assumes that we're mocking the qemu-amd64 deviceinfo chroot = Chroot(ChrootType.ROOTFS, "qemu-amd64") @@ -35,7 +35,7 @@ def test_valid_chroots(pmb_args, mock_devices_find_path): assert chroot.name == "qemu-amd64" assert chroot.arch == Arch.x86_64 assert not chroot.exists() # Shouldn't be created - assert chroot.path == work / "chroot_rootfs_qemu-amd64" + assert chroot.path == localdir / "chroot_rootfs_qemu-amd64" assert str(chroot) == "rootfs_qemu-amd64" diff --git a/test/core/test_pkgrepo.py b/test/core/test_pkgrepo.py index d1db6223..fecc6aba 100644 --- a/test/core/test_pkgrepo.py +++ b/test/core/test_pkgrepo.py @@ -22,7 +22,7 @@ def test_pkgrepo_pmaports(pmaports, monkeypatch): pkgrepo_paths.cache_disable() pkgrepo_default_path.cache_disable() - paths = pkgrepo_paths() + paths = pkgrepo_paths(with_extra_repos="disabled") print(f"[master] pkgrepo_paths: {paths}") assert len(paths) == 1 assert "pmaports" in paths[0].name @@ -32,9 +32,6 @@ def test_pkgrepo_pmaports(pmaports, monkeypatch): assert default_path.name == "pmaports" # Test extra-repos - paths = pkgrepo_paths(with_extra_repos="disabled") - assert len(paths) == 1 - paths = pkgrepo_paths(with_extra_repos="enabled") assert len(paths) == 2 diff --git a/test/data/tests/pmbootstrap_v3.cfg b/test/data/tests/pmbootstrap_v3.cfg index 074ad34f..657d4e70 100644 --- a/test/data/tests/pmbootstrap_v3.cfg +++ b/test/data/tests/pmbootstrap_v3.cfg @@ -15,6 +15,7 @@ systemd = always timezone = Europe/Berlin ui = gnome work = {0} +cache = {0}/cache [providers] diff --git a/test/parse/test_bootimg.py b/test/parse/test_bootimg.py index 6fbc0f43..b8f4755e 100644 --- a/test/parse/test_bootimg.py +++ b/test/parse/test_bootimg.py @@ -44,6 +44,9 @@ def progs() -> dict[str, str]: @pytest.fixture def bootimg(progs: dict[str, str], tmp_path: Path) -> Callable: + if Path("/in-pmbootstrap").exists(): + pytest.skip("Nested chroot unsupported") + path: Path = tmp_path / "boot.img" cmd = [ progs["mkbootimg"], diff --git a/test/parse/test_deviceinfo.py b/test/parse/test_deviceinfo.py index 84c32d56..3db5aec8 100644 --- a/test/parse/test_deviceinfo.py +++ b/test/parse/test_deviceinfo.py @@ -175,6 +175,12 @@ def random_valid_deviceinfo(tmp_path): info["codename"] = tmp_path.name[7:] info["chassis"] = random.choice(deviceinfo_chassis_types) info["arch"] = random.choice(["armhf", "aarch64", "x86_64"]) + # FIXME: we can't keep adding properties here manually as we make more of them + # discrete types.. + if "rootfs_image_sector_size" in info: + info["rootfs_image_sector_size"] = random.choice([512, 2048, 4096]) + if "boot_part_start" in info: + info["boot_part_start"] = random.choice([0, 2048, 4096]) # Now write it all out to a file with open(path, "w") as f: