test: parse: add test_deviceinfo (MR 2453)

Write some basic parser tests for deviceinfo. The parser is quite basic
so there isn't much to test yet. Expecting this to gain features as we
look at e.g. making the parser the "source of truth" for the deviceinfo
format.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-10-24 00:17:00 +02:00
parent 511d490015
commit b9354d3ccd
No known key found for this signature in database
GPG key ID: 0583312B195F64B6
3 changed files with 217 additions and 0 deletions

View file

@ -35,6 +35,13 @@ def _parse_kernel_suffix(info, device, kernel):
"b": "second",
"b_downstream": "third"}
"""
# We don't support parsing the kernel variants in tests yet, since this code
# depends on pmaports being available and calls into a whole lot of other code.
if os.environ.get("PYTEST_CURRENT_TEST", "").startswith("pmb/parse/test_deviceinfo.py"):
# If you hit this, you're probably trying to add a test for kernel variants.
# You'll need to figure out how to mock the APKBUILD parsing below.
assert kernel is None
return info
# Do nothing if the configured kernel isn't available in the kernel (e.g.
# after switching from device with multiple kernels to device with only one
# kernel)