From: Louis Rannou <louis.rannou@syslinbit.com>
To: openembedded-core@lists.openembedded.org
Cc: pascal.eberhard@se.com, bruce.ashfield@gmail.com,
Louis Rannou <louis.rannou@non.se.com>
Subject: [PATCH] classes/kernel: add QA to check required or forbidden kernel configs
Date: Thu, 06 Mar 2025 16:03:40 +0100 [thread overview]
Message-ID: <20250306-qa_kernel-v1-1-e83431c29799@syslinbit.com> (raw)
From: Louis Rannou <louis.rannou@non.se.com>
Add a QARECIPETEST kernel-config to the kernel to check the kernel config has
set (or unset) config listed in variables QA_KERNEL_CONFIGS_REQUIRED (or
QA_KERNEL_CONFIGS_FORBIDDEN).
Signed-off-by: Louis Rannou <louis.rannou@non.se.com>
---
meta/classes-recipe/kernel.bbclass | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index 64a685a964dab942db05b8d9e08cc22a3bbb152e..4a82b84d479667bf4a6e64ad3e99d934c6868b98 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -867,3 +867,41 @@ EXPORT_FUNCTIONS do_deploy
# Add using Device Tree support
inherit kernel-devicetree
+
+
+# Add QA test to check some required/forbidden kernel configs are set or not.
+QA_KERNEL_CONFIGS_REQUIRED ??= ""
+QA_KERNEL_CONFIGS_FORBIDDEN ??= ""
+
+WARN_QA:append = " kernel-config"
+
+QARECIPETEST[kernel-config] = "package_qa_check_kernel_config"
+def package_qa_check_kernel_config(pn, d):
+ from pathlib import Path
+ import re
+
+ config_path = Path(d.getVar("B"), ".config")
+ if not config_path.exists():
+ oe.qa.handle_error("kernel-config",
+ "Kernel configs have not been checked "\
+ "as the kernel .config is not found: "\
+ "%s." % config_path)
+ return
+
+ config_list = {}
+ with config_path.open('r') as f_config:
+ for line in f_config.read().splitlines():
+ configset = re.match(r'# (\w+) is not set|(\w+)=([ymn])', line)
+ if configset is not None:
+ if configset.group(1) is not None:
+ config_list[configset.group(1)] = "n"
+ else:
+ config_list[configset.group(2)] = configset.group(3)
+
+ for conf in d.getVar("QA_KERNEL_CONFIGS_REQUIRED").split():
+ if conf not in config_list or config_list[conf] == "n":
+ oe.qa.handle_error("kernel-config", "Kernel config is required: %s" % conf, d)
+
+ for conf in d.getVar("QA_KERNEL_CONFIGS_FORBIDDEN").split():
+ if conf in config_list and config_list[conf] in "ym":
+ oe.qa.handle_error("kernel-config", "Kernel config is forbidden: %s" % conf, d)
---
base-commit: b72823fc09674f78ad452250f453f6e47d9444de
change-id: 20250306-qa_kernel-061a37e316c4
Best regards,
--
Louis Rannou <louis.rannou@syslinbit.com>
next reply other threads:[~2025-03-06 15:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 15:03 Louis Rannou [this message]
2025-03-06 15:36 ` [OE-core] [PATCH] classes/kernel: add QA to check required or forbidden kernel configs Bruce Ashfield
2025-03-07 7:45 ` Louis Rannou
2025-03-07 13:54 ` Bruce Ashfield
2025-03-10 16:38 ` Louis Rannou
2025-03-10 18:09 ` Bruce Ashfield
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250306-qa_kernel-v1-1-e83431c29799@syslinbit.com \
--to=louis.rannou@syslinbit.com \
--cc=bruce.ashfield@gmail.com \
--cc=louis.rannou@non.se.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=pascal.eberhard@se.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox