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.
This commit is contained in:
Clayton Craft 2021-06-23 19:07:46 -07:00
parent 687807fa73
commit 6afd35eb11
No known key found for this signature in database
GPG key ID: 7A3461CA187CEA54
7 changed files with 87 additions and 3 deletions

View file

@ -154,4 +154,5 @@ def menuconfig(args, pkgname):
pmb.parse.kconfig.check(args, apkbuild["_flavor"], force_anbox_check=False, pmb.parse.kconfig.check(args, apkbuild["_flavor"], force_anbox_check=False,
force_nftables_check=False, force_nftables_check=False,
force_containers_check=False, force_containers_check=False,
force_zram_check=False,
details=True) details=True)

View file

@ -434,6 +434,17 @@ necessary_kconfig_options_containers = {
}, },
} }
necessary_kconfig_options_zram = {
">=3.14.0": { # zram support introduced here
"all": { # all arches
"ZSMALLOC_STAT": True,
"ZRAM_MEMORY_TRACKING": True,
"CRYPTO_LZ4": True,
"LZ4_COMPRESS": True,
}
},
}
# #
# PARSE # PARSE
# #

View file

@ -377,6 +377,7 @@ def kconfig(args):
anbox=args.anbox, anbox=args.anbox,
nftables=args.nftables, nftables=args.nftables,
containers=args.containers, containers=args.containers,
zram=args.zram,
details=True): details=True):
logging.info("kconfig check succeeded!") logging.info("kconfig check succeeded!")
return return
@ -409,6 +410,7 @@ def kconfig(args):
force_anbox_check=args.anbox, force_anbox_check=args.anbox,
force_nftables_check=args.nftables, force_nftables_check=args.nftables,
force_containers_check=args.containers, force_containers_check=args.containers,
force_zram_check=args.zram,
details=True): details=True):
error = True error = True

View file

@ -441,6 +441,8 @@ def arguments_kconfig(subparser):
" options needed for nftables too") " options needed for nftables too")
check.add_argument("--containers", action="store_true", check.add_argument("--containers", action="store_true",
help="check options needed for containers too") help="check options needed for containers too")
check.add_argument("--zram", action="store_true", help="check"
" options needed for zram support too")
check_package = check.add_argument("package", default="", nargs='?') check_package = check.add_argument("package", default="", nargs='?')
if argcomplete: if argcomplete:
check_package.completer = kernel_completer check_package.completer = kernel_completer

View file

@ -65,7 +65,8 @@ def check_option(component, details, config, config_path_pretty, option,
def check_config(config_path, config_path_pretty, config_arch, pkgver, def check_config(config_path, config_path_pretty, config_arch, pkgver,
anbox=False, nftables=False, containers=False, details=False): anbox=False, nftables=False, containers=False, zram=False,
details=False):
logging.debug(f"Check kconfig: {config_path}") logging.debug(f"Check kconfig: {config_path}")
with open(config_path) as handle: with open(config_path) as handle:
config = handle.read() config = handle.read()
@ -78,6 +79,8 @@ def check_config(config_path, config_path_pretty, config_arch, pkgver,
if containers: if containers:
components["containers"] = \ components["containers"] = \
pmb.config.necessary_kconfig_options_containers pmb.config.necessary_kconfig_options_containers
if zram:
components["zram"] = pmb.config.necessary_kconfig_options_zram
results = [check_config_options_set(config, config_path_pretty, results = [check_config_options_set(config, config_path_pretty,
config_arch, options, component, config_arch, options, component,
@ -121,7 +124,7 @@ def check_config_options_set(config, config_path_pretty, config_arch, options,
def check(args, pkgname, force_anbox_check=False, force_nftables_check=False, def check(args, pkgname, force_anbox_check=False, force_nftables_check=False,
force_containers_check=False, details=False): force_containers_check=False, force_zram_check=False, details=False):
""" """
Check for necessary kernel config options in a package. Check for necessary kernel config options in a package.
@ -146,6 +149,8 @@ def check(args, pkgname, force_anbox_check=False, force_nftables_check=False,
"pmb:kconfigcheck-nftables" in apkbuild["options"]) "pmb:kconfigcheck-nftables" in apkbuild["options"])
check_containers = force_containers_check or ( check_containers = force_containers_check or (
"pmb:kconfigcheck-containers" in apkbuild["options"]) "pmb:kconfigcheck-containers" in apkbuild["options"])
check_zram = force_zram_check or (
"pmb:kconfigcheck-zram" in apkbuild["options"])
for config_path in glob.glob(aport + "/config-*"): for config_path in glob.glob(aport + "/config-*"):
# The architecture of the config is in the name, so it just needs to be # The architecture of the config is in the name, so it just needs to be
# extracted # extracted
@ -156,6 +161,7 @@ def check(args, pkgname, force_anbox_check=False, force_nftables_check=False,
anbox=check_anbox, anbox=check_anbox,
nftables=check_nftables, nftables=check_nftables,
containers=check_containers, containers=check_containers,
zram=check_zram,
details=details) details=details)
return ret return ret
@ -193,7 +199,7 @@ def extract_version(config_file):
def check_file(args, config_file, anbox=False, nftables=False, def check_file(args, config_file, anbox=False, nftables=False,
containers=False, details=False): containers=False, zram=False, details=False):
""" """
Check for necessary kernel config options in a kconfig file. Check for necessary kernel config options in a kconfig file.
@ -207,4 +213,5 @@ def check_file(args, config_file, anbox=False, nftables=False,
anbox=anbox, anbox=anbox,
nftables=nftables, nftables=nftables,
containers=containers, containers=containers,
zram=zram,
details=details) details=details)

View file

@ -36,6 +36,8 @@ def test_kconfig_check(args):
nftables=True) nftables=True)
assert not pmb.parse.kconfig.check_file(args, dir + "bad-nftables", assert not pmb.parse.kconfig.check_file(args, dir + "bad-nftables",
nftables=True) nftables=True)
assert pmb.parse.kconfig.check_file(args, dir + "good-zram",
zram=True)
# tests on real devices # tests on real devices
@ -49,3 +51,6 @@ def test_kconfig_check(args):
# testing the force param: nokia-n900 will never have anbox support # testing the force param: nokia-n900 will never have anbox support
assert not pmb.parse.kconfig.check(args, "nokia-n900", assert not pmb.parse.kconfig.check(args, "nokia-n900",
force_anbox_check=True) force_anbox_check=True)
# supports zram (with pmb:kconfigcheck-zram), nftables
assert pmb.parse.kconfig.check(args, "linux-purism-librem5")

56
test/testdata/kconfig_check/good-zram vendored Normal file
View file

@ -0,0 +1,56 @@
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 5.12.2 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="aarch64-alpine-linux-musl-gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=100301
CONFIG_CLANG_VERSION=0
CONFIG_LD_IS_BFD=y
CONFIG_LD_VERSION=23502
CONFIG_LLD_VERSION=0
CONFIG_CC_HAS_ASM_GOTO=y
CONFIG_CC_HAS_ASM_INLINE=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_TABLE_SORT=y
CONFIG_THREAD_INFO_IN_TASK=y
#
# General setup
#
CONFIG_LOCALVERSION="-zram-good"
CONFIG_BUILD_SALT=""
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_KERNEL_GZIP=y
# CONFIG_KERNEL_LZMA is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
CONFIG_SWAP=y
# needed for bubblewrap
CONFIG_USER_NS=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_CGROUPS=y
CONFIG_DEVTMPFS=y
CONFIG_DM_CRYPT=y
CONFIG_SYSVIPC=y
CONFIG_VT=y
CONFIG_UEVENT_HELPER=y
CONFIG_LBDAF=y
CONFIG_CRYPTO_XTS=y
CONFIG_TMPFS_POSIX_ACL=y
### here's one explicitely disabled:
# ANDROID_PARANOID_NETWORK is not set
### here's one set to module:
CONFIG_EXT4_FS=m
### here's a line set to no:
CONFIG_KINETO_GAN=n
# the required options
#
CONFIG_ZSMALLOC=y
CONFIG_ZSMALLOC_STAT=y
CONFIG_ZRAM=m
CONFIG_ZRAM_WRITEBACK=y
CONFIG_ZRAM_MEMORY_TRACKING=y
CONFIG_CRYPTO_LZ4=y
CONFIG_LZ4_COMPRESS=y