1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-14 11:59:47 +03:00
pmbootstrap/test/test_kconfig_check.py
Clayton Craft 6afd35eb11
kconfig check: add support for checking zram options (MR 2075)
Device kernels that enable zram support can use `pmb:kconfigcheck-zram`
to protect against kconfig regressions that disable support for zram.
2021-06-23 21:17:41 -07:00

56 lines
2.2 KiB
Python

# Copyright 2021 Antoine Fontaine
# Copyright 2021 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
import pytest
import sys
import pmb_test
import pmb_test.const
import pmb.parse.kconfig
@pytest.fixture
def args(tmpdir, request):
import pmb.parse
sys.argv = ["pmbootstrap.py", "kconfig", "check"]
args = pmb.parse.arguments()
args.log = args.work + "/log_testsuite.txt"
pmb.helpers.logging.init(args)
request.addfinalizer(args.logfd.close)
return args
def test_kconfig_check(args):
# basic checks, from easiers to hard-ish
dir = f"{pmb_test.const.testdata}/kconfig_check/"
assert not pmb.parse.kconfig.check_file(args, dir +
"bad-missing-required-option")
assert pmb.parse.kconfig.check_file(args, dir + "good")
assert not pmb.parse.kconfig.check_file(args, dir + "bad-wrong-option-set")
assert pmb.parse.kconfig.check_file(args, dir + "good-anbox",
anbox=True)
assert not pmb.parse.kconfig.check_file(args, dir +
"bad-array-missing-some-options",
anbox=True)
assert pmb.parse.kconfig.check_file(args, dir + "good-nftables",
nftables=True)
assert not pmb.parse.kconfig.check_file(args, dir + "bad-nftables",
nftables=True)
assert pmb.parse.kconfig.check_file(args, dir + "good-zram",
zram=True)
# tests on real devices
# it's a postmarketOS device, it will have the required options, and
# supports nftables (with pmb:kconfigcheck-nftables)
assert pmb.parse.kconfig.check(args, "nokia-n900")
# supports Anbox (with pmb:kconfigcheck-anbox)
assert pmb.parse.kconfig.check(args, "postmarketos-allwinner")
# testing the force param: nokia-n900 will never have anbox support
assert not pmb.parse.kconfig.check(args, "nokia-n900",
force_anbox_check=True)
# supports zram (with pmb:kconfigcheck-zram), nftables
assert pmb.parse.kconfig.check(args, "linux-purism-librem5")