[v2,09/27] kselftest: Migrate to a bbclass

Message ID 0f33ba5ce2fdfb9499c2b7785750ed591d2e6f15.1762759360.git.jan.kiszka@siemens.com
State Under Review
Headers show
Series Use more classes! | expand

Commit Message

Jan Kiszka Nov. 10, 2025, 7:22 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

"inherit kselftest" is shorter and a more common pattern compared to
OE/yocto. Keep the original .inc file as transitional helper, issuing a
warning when it's used with a migration suggestion.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../kselftest.bbclass}                        |  5 +-
 meta/recipes-kernel/kselftest/kselftest.inc   | 52 +++----------------
 2 files changed, 9 insertions(+), 48 deletions(-)
 copy meta/{recipes-kernel/kselftest/kselftest.inc => classes-recipe/kselftest.bbclass} (93%)

Comments

Anton Mikanovich Nov. 11, 2025, 3:45 p.m. UTC | #1
10/11/2025 09:22, 'Jan Kiszka' via isar-users wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> "inherit kselftest" is shorter and a more common pattern compared to
'linux-kselftest' maybe? Just to make all the classes named in the same 
way and
stay nearby in the folder.
> OE/yocto. Keep the original .inc file as transitional helper, issuing a
> warning when it's used with a migration suggestion.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>   .../kselftest.bbclass}                        |  5 +-
>   meta/recipes-kernel/kselftest/kselftest.inc   | 52 +++----------------
>   2 files changed, 9 insertions(+), 48 deletions(-)
>   copy meta/{recipes-kernel/kselftest/kselftest.inc => classes-recipe/kselftest.bbclass} (93%)
>
> diff --git a/meta/recipes-kernel/kselftest/kselftest.inc b/meta/classes-recipe/kselftest.bbclass
> similarity index 93%
> copy from meta/recipes-kernel/kselftest/kselftest.inc
> copy to meta/classes-recipe/kselftest.bbclass
> index 95dece10..ec2d267e 100644
> --- a/meta/recipes-kernel/kselftest/kselftest.inc
> +++ b/meta/classes-recipe/kselftest.bbclass
> @@ -2,13 +2,12 @@
>   #
>   # This software is a part of ISAR.
>   # Copyright (c) Mentor Graphics, a Siemens Business, 2020
> +# Copyright (c) Siemens, 2025
>   #
>   # SPDX-License-Identifier: MIT
>   
>   inherit dpkg
>   
> -FILESPATH:append := ":${THISDIR}/files"
> -
>   # Some test-cases like memfd compilation failed in cross-compilation.
>   # Force native compilation for now to have consistent output across
>   # ISAR native/cross compilation setups.
> @@ -33,7 +32,9 @@ DEBIAN_BUILD_DEPENDS ?= " \
>       llvm:native, \
>   "
>   
> +FILESPATH:append = ":${LAYERDIR_core}/recipes-kernel/kselftest/files"
>   SRC_URI += "file://rules.tmpl"
> +
>   S = "${WORKDIR}/linux-${PV}"
>   
>   TEMPLATE_FILES = "rules.tmpl"
> diff --git a/meta/recipes-kernel/kselftest/kselftest.inc b/meta/recipes-kernel/kselftest/kselftest.inc
> index 95dece10..a81e2550 100644
> --- a/meta/recipes-kernel/kselftest/kselftest.inc
> +++ b/meta/recipes-kernel/kselftest/kselftest.inc
> @@ -1,53 +1,13 @@
> -# Kselftest package for Linux
> +# Transitional include for kselftest.bbclass
>   #
>   # This software is a part of ISAR.
> -# Copyright (c) Mentor Graphics, a Siemens Business, 2020
> +# Copyright (c) Siemens AG, 2025
>   #
>   # SPDX-License-Identifier: MIT
>   
> -inherit dpkg
> +inherit kselftest
>   
> -FILESPATH:append := ":${THISDIR}/files"
> -
> -# Some test-cases like memfd compilation failed in cross-compilation.
> -# Force native compilation for now to have consistent output across
> -# ISAR native/cross compilation setups.
> -ISAR_CROSS_COMPILE = "0"
> -
> -DESCRIPTION ?= "Kernel selftests from Linux kernel ${PV}"
> -
> -DEBIAN_BUILD_DEPENDS ?= " \
> -    rsync, \
> -    flex,  \
> -    bison, \
> -    ${@ 'fuse' if d.getVar('BASE_DISTRO_CODENAME') in ['bullseye', 'buster'] else 'fuse3'}, \
> -    libelf-dev:native, \
> -    libcap-ng-dev:native, \
> -    libpopt-dev:native, \
> -    libcap-dev:native, \
> -    libmount-dev:native, \
> -    libfuse-dev:native, \
> -    libmnl-dev:native, \
> -    pkg-config, \
> -    clang:native, \
> -    llvm:native, \
> -"
> -
> -SRC_URI += "file://rules.tmpl"
> -S = "${WORKDIR}/linux-${PV}"
> -
> -TEMPLATE_FILES = "rules.tmpl"
> -TEMPLATE_VARS += "KSELFTEST_ARGS"
> -
> -KSELFTEST_TARGETS ?= ""
> -KSELFTEST_SKIP_TARGETS ?= ""
> -KSELFTEST_FORCE_TARGETS ?= "0"
> -
> -KSELFTEST_ARGS = "${@ "TARGETS=\"${KSELFTEST_TARGETS}\"" if d.getVar('KSELFTEST_TARGETS') else ''}"
> -KSELFTEST_ARGS .= "${@ " FORCE_TARGETS=1" if bb.utils.to_boolean(d.getVar('KSELFTEST_FORCE_TARGETS')) else ''}"
> -KSELFTEST_ARGS .= "${@ " SKIP_TARGETS=\"${KSELFTEST_SKIP_TARGETS}\"" if d.getVar('KSELFTEST_SKIP_TARGETS') else ''}"
> -
> -do_prepare_build[cleandirs] += "${S}/debian"
> -do_prepare_build() {
> -    deb_debianize
> +do_warn_custom_inc() {
> +    bbwarn "Please migrate from \"require recipes-kernel/kselftest/kselftest.inc\" to \"inherit kselftest\""
>   }
> +addtask warn_custom_inc before do_unpack
Jan Kiszka Nov. 11, 2025, 3:48 p.m. UTC | #2
On 11.11.25 16:45, Anton Mikanovich wrote:
> 10/11/2025 09:22, 'Jan Kiszka' via isar-users wrote:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> "inherit kselftest" is shorter and a more common pattern compared to
> 'linux-kselftest' maybe? Just to make all the classes named in the same
> way and
> stay nearby in the folder.

Can do - OTOH, kselftest is already a brand of its own.

Jan

Patch

diff --git a/meta/recipes-kernel/kselftest/kselftest.inc b/meta/classes-recipe/kselftest.bbclass
similarity index 93%
copy from meta/recipes-kernel/kselftest/kselftest.inc
copy to meta/classes-recipe/kselftest.bbclass
index 95dece10..ec2d267e 100644
--- a/meta/recipes-kernel/kselftest/kselftest.inc
+++ b/meta/classes-recipe/kselftest.bbclass
@@ -2,13 +2,12 @@ 
 #
 # This software is a part of ISAR.
 # Copyright (c) Mentor Graphics, a Siemens Business, 2020
+# Copyright (c) Siemens, 2025
 #
 # SPDX-License-Identifier: MIT
 
 inherit dpkg
 
-FILESPATH:append := ":${THISDIR}/files"
-
 # Some test-cases like memfd compilation failed in cross-compilation.
 # Force native compilation for now to have consistent output across
 # ISAR native/cross compilation setups.
@@ -33,7 +32,9 @@  DEBIAN_BUILD_DEPENDS ?= " \
     llvm:native, \
 "
 
+FILESPATH:append = ":${LAYERDIR_core}/recipes-kernel/kselftest/files"
 SRC_URI += "file://rules.tmpl"
+
 S = "${WORKDIR}/linux-${PV}"
 
 TEMPLATE_FILES = "rules.tmpl"
diff --git a/meta/recipes-kernel/kselftest/kselftest.inc b/meta/recipes-kernel/kselftest/kselftest.inc
index 95dece10..a81e2550 100644
--- a/meta/recipes-kernel/kselftest/kselftest.inc
+++ b/meta/recipes-kernel/kselftest/kselftest.inc
@@ -1,53 +1,13 @@ 
-# Kselftest package for Linux
+# Transitional include for kselftest.bbclass
 #
 # This software is a part of ISAR.
-# Copyright (c) Mentor Graphics, a Siemens Business, 2020
+# Copyright (c) Siemens AG, 2025
 #
 # SPDX-License-Identifier: MIT
 
-inherit dpkg
+inherit kselftest
 
-FILESPATH:append := ":${THISDIR}/files"
-
-# Some test-cases like memfd compilation failed in cross-compilation.
-# Force native compilation for now to have consistent output across
-# ISAR native/cross compilation setups.
-ISAR_CROSS_COMPILE = "0"
-
-DESCRIPTION ?= "Kernel selftests from Linux kernel ${PV}"
-
-DEBIAN_BUILD_DEPENDS ?= " \
-    rsync, \
-    flex,  \
-    bison, \
-    ${@ 'fuse' if d.getVar('BASE_DISTRO_CODENAME') in ['bullseye', 'buster'] else 'fuse3'}, \
-    libelf-dev:native, \
-    libcap-ng-dev:native, \
-    libpopt-dev:native, \
-    libcap-dev:native, \
-    libmount-dev:native, \
-    libfuse-dev:native, \
-    libmnl-dev:native, \
-    pkg-config, \
-    clang:native, \
-    llvm:native, \
-"
-
-SRC_URI += "file://rules.tmpl"
-S = "${WORKDIR}/linux-${PV}"
-
-TEMPLATE_FILES = "rules.tmpl"
-TEMPLATE_VARS += "KSELFTEST_ARGS"
-
-KSELFTEST_TARGETS ?= ""
-KSELFTEST_SKIP_TARGETS ?= ""
-KSELFTEST_FORCE_TARGETS ?= "0"
-
-KSELFTEST_ARGS = "${@ "TARGETS=\"${KSELFTEST_TARGETS}\"" if d.getVar('KSELFTEST_TARGETS') else ''}"
-KSELFTEST_ARGS .= "${@ " FORCE_TARGETS=1" if bb.utils.to_boolean(d.getVar('KSELFTEST_FORCE_TARGETS')) else ''}"
-KSELFTEST_ARGS .= "${@ " SKIP_TARGETS=\"${KSELFTEST_SKIP_TARGETS}\"" if d.getVar('KSELFTEST_SKIP_TARGETS') else ''}"
-
-do_prepare_build[cleandirs] += "${S}/debian"
-do_prepare_build() {
-    deb_debianize
+do_warn_custom_inc() {
+    bbwarn "Please migrate from \"require recipes-kernel/kselftest/kselftest.inc\" to \"inherit kselftest\""
 }
+addtask warn_custom_inc before do_unpack