All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] classes/kernel: add QA to check required or forbidden kernel configs
@ 2025-03-06 15:03 Louis Rannou
  2025-03-06 15:36 ` [OE-core] " Bruce Ashfield
  0 siblings, 1 reply; 6+ messages in thread
From: Louis Rannou @ 2025-03-06 15:03 UTC (permalink / raw)
  To: openembedded-core; +Cc: pascal.eberhard, bruce.ashfield, Louis Rannou

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>



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-10 18:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-06 15:03 [PATCH] classes/kernel: add QA to check required or forbidden kernel configs Louis Rannou
2025-03-06 15:36 ` [OE-core] " 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.