pmbootstrap-meow/test/test_parse_deviceinfo.py
Caleb Connolly 34dd9d42ba
WIP: start ripping out args (MR 2252)
Cease merging pmbootstrap.cfg into args, implement a Context type to let
us pull globals out of thin air (as an intermediate workaround) and rip
args out of a lot of the codebase.

This is just a first pass, after this we can split all the state that
leaked over into Context into types with narrower scopes (like a
BuildContext(), etc).

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:38 +02:00

39 lines
1.1 KiB
Python

# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
from pmb.types import PmbArgs
import pytest
import sys
import pmb_test.const
import pmb.parse
@pytest.fixture
def args(tmpdir, request):
import pmb.parse
sys.argv = ["pmbootstrap.py", "init"]
args = pmb.parse.arguments()
args.log = get_context().config.work / "log_testsuite.txt"
pmb.helpers.logging.init(args)
request.addfinalizer(pmb.helpers.logging.logfd.close)
return args
def test_kernel_suffix(args: PmbArgs):
args.aports = pmb_test.const.testdata + "/deviceinfo/aports"
device = "multiple-kernels"
kernel = "mainline"
deviceinfo = pmb.parse.deviceinfo(device, kernel)
assert deviceinfo["append_dtb"] == "yes"
assert deviceinfo["dtb"] == "mainline-dtb"
kernel = "mainline-modem"
deviceinfo = pmb.parse.deviceinfo(device, kernel)
assert deviceinfo["append_dtb"] == "yes"
assert deviceinfo["dtb"] == "mainline-modem-dtb"
kernel = "downstream"
deviceinfo = pmb.parse.deviceinfo(device, kernel)
assert deviceinfo["append_dtb"] == "yes"
assert deviceinfo["dtb"] == "downstream-dtb"