From 1b4c38a01dd7f0e6acb54a35610ef9d1e4fcdee6 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 10 Nov 2024 17:19:40 +0100 Subject: [PATCH] Revert "test: parse: add tests for bootimg parsing (MR 2477)" (MR 2482) This caused a regression in CI tests. This reverts commit ae35603197c21699122c23fb0b614c503568633b. Related: issue 2497 --- .gitlab-ci.yml | 2 +- pmb/parse/test_bootimg.py | 104 -------------------------------------- 2 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 pmb/parse/test_bootimg.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 265e4836..595cab58 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,7 +33,7 @@ codespell: pytest: stage: test script: - - "apk -q add git android-tools" + - "apk -q add git" - "su build -c 'git config --global user.email ci@ci'" - "su build -c 'git config --global user.name CI'" - "echo 'build ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers" diff --git a/pmb/parse/test_bootimg.py b/pmb/parse/test_bootimg.py deleted file mode 100644 index 82cebc1b..00000000 --- a/pmb/parse/test_bootimg.py +++ /dev/null @@ -1,104 +0,0 @@ -from pathlib import Path -from collections.abc import Callable -import pytest -import shutil -import subprocess - -from pmb.types import Bootimg - -from .bootimg import bootimg as parse_bootimg - - -# This is the result of compiling a totally empty devicetree file -empty_dtb = b"\xd0\r\xfe\xed\x00\x00\x00H\x00\x00\x008\x00\x00\x00H\x00\x00\x00(\x00\x00\x00\x11\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\t" - - -@pytest.fixture -def progs() -> dict[str, str]: - progs: dict[str, str] = { - # We expect the modern python version of mkbootimg from android-tools - "mkbootimg": "", - } - for k in progs.keys(): - v = shutil.which(k) - if v is None: - pytest.skip(f"{k} not found") - else: - progs[k] = v - - return progs - - -@pytest.fixture -def bootimg(progs: dict[str, str], tmp_path: Path) -> Callable: - path: Path = tmp_path / "boot.img" - cmd = [ - progs["mkbootimg"], - "--kernel", - "/dev/null", - "--ramdisk", - "/dev/null", - "--output", - str(path), - ] - - def with_args(**kwargs): - # Header version 2 requires a dtb file, be helpful and add one if it's missing - if kwargs.get("header_version", 0) == 2 and "dtb" not in kwargs: - with open(path.with_suffix(".dtb"), "wb") as f: - f.write(empty_dtb) - cmd.extend(["--dtb", str(path.with_suffix(".dtb"))]) - for key, value in kwargs.items(): - cmd.extend([f"--{key}", str(value)]) - subprocess.run(cmd, check=True) - return tmp_path / "boot.img" - - return with_args - - -# Due to limitations in the test infrastructure (somehow we have to clone -# all of pmaports for this!!) we stuff all the tests into one -def test_bootimg(bootimg, pmb_args, pmaports): - bootimg_path = bootimg(base=0x80000000) - - # Header v0 - img: Bootimg = parse_bootimg(bootimg_path) - print(f"Header v0: {img}") - assert img["header_version"] == "0", "header v0 expected header version 0" - assert img["cmdline"] == "", "header v0 expected empty cmdline" - assert img["qcdt"] == "false", "header v0 expected qcdt false" - assert img["base"] == "0x80000000", "header v0 expected base 0x80000000" - assert int(img["kernel_offset"], 16) == 0x8000, "header v0 expected kernel offset 0x8000" - assert int(img["tags_offset"], 16) == 0x100, "header v0 expected tags offset 0x100" - - # Header v2 - bootimg_path = bootimg(base=0x80000000, header_version=2) - - img = parse_bootimg(bootimg_path) - print(f"Header v2: {img}") - assert img["header_version"] == "2", "header v2 expected header version 2" - assert img["cmdline"] == "", "header v2 expected empty cmdline" - assert img["qcdt"] == "false", "header v2 expected qcdt false" - assert img["base"] == "0x80000000", "header v2 expected base 0x80000000" - assert int(img["kernel_offset"], 16) == 0x8000, "header v2 expected kernel offset 0x8000" - assert int(img["tags_offset"], 16) == 0x100, "header v2 expected tags offset 0x100" - assert img["dtb_offset"] is not None, "header v2 expected dtb offset" - assert int(img["dtb_offset"], 16) == 0x101F00000, "header v2 expected dtb offset 0x101f00000" - assert img["dtb_second"] == "", "header v2 expected dtb second empty" - assert img["pagesize"] == "2048", "header v2 expected pagesize 2048" - - # Header v3, plus cmdline for fun - bootimg_path = bootimg(header_version=3, cmdline="bleep boop console=ttyMSM0,115200n8") - - img = parse_bootimg(bootimg_path) - print(f"Header v3: {img}") - assert img["header_version"] == "3", "header v3 expected header version 3" - assert img["cmdline"] == "bleep boop console=ttyMSM0,115200n8", "header v3 expected cmdline" - assert img["kernel_offset"] == "", "header v3 expected empty kernel offset" - assert img["pagesize"] == "4096", "header v3 expected pagesize 4096" - assert img["ramdisk_offset"] == "", "header v3 expected empty ramdisk offset" - - -def test_bootimg_deviceinfo(): - # Test the deviceinfo file - pass