From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6828154244872273920 Date: Tue, 13 Oct 2020 23:18:56 -0700 (PDT) From: "vijaikumar....@gmail.com" To: isar-users Message-Id: <9d062695-7b6b-4f96-9b5b-606188687b5cn@googlegroups.com> In-Reply-To: References: <20200529101515.6454-1-Vijaikumar_Kanagarajan@mentor.com> Subject: Re: [PATCH v3] Add recipe for linux kselftest MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_1080_738194587.1602656336211" X-TUID: 4vghWsMY3GLP ------=_Part_1080_738194587.1602656336211 Content-Type: multipart/alternative; boundary="----=_Part_1081_2099907819.1602656336211" ------=_Part_1081_2099907819.1602656336211 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Tuesday, October 13, 2020 at 3:33:35 PM UTC+5:30 Jan Kiszka wrote: > On 29.05.20 12:15, Vijai Kumar K wrote: > > Kselftest is a set of unit and regression tests under the > > tools/testing/selftests/ directory of the Linux kernel. These are used > > for testing individual code paths in the kernel. > > > > Kselftest is not debianized and is not available as part of the official > > Debian repository. > > > > This patch provides a recipe to build kselftest from the linux source of > > your choice. > > > > Sometimes developers/testers tend to use the latest version of selftests > > from Linux upstream stable releases for testing and hence the need for a > > separate recipe instead of being part of the linux recipe of ISAR. > > > > Some kselftest test cases build are known to break in certain linux > > versions, this has to be addressed upstream. Right now kselftest build > > succeeds even if atleast one of the testcase case build succeeds. > > > > You can change that by setting KSELFTEST_FORCE_TARGETS=1. > > > > TARGETS, TARGETS_SKIP, FORCE_TARGETS can be set using the appropriate > > KSELFTEST_* recipe variable. > > > > Signed-off-by: Vijai Kumar K > > --- > > Changes since v2: > > - Use deb_debianize instead of individual calls for changelog, compat & > control. > > - Add package to isar-image-debug > > > > Changes since v1: > > - Addressed review comments in v1 > > - Used debianize APIs for control, compat and changelog. > > - Moved Depends & S definitions to include file. > > - Added cross compilation bits in rules. > > - Change clang, llvm to clang:native & llvm:native > > .../recipes-core/images/isar-image-debug.bb | 2 + > > .../kselftest/kselftest_5.6.13.bb | 11 ++++ > > meta/recipes-kernel/kselftest/files/rules | 41 +++++++++++++ > > meta/recipes-kernel/kselftest/kselftest.inc | 59 +++++++++++++++++++ > > 4 files changed, 113 insertions(+) > > create mode 100644 meta-isar/recipes-kernel/kselftest/ > kselftest_5.6.13.bb > > create mode 100755 meta/recipes-kernel/kselftest/files/rules > > create mode 100644 meta/recipes-kernel/kselftest/kselftest.inc > > > > diff --git a/meta-isar/recipes-core/images/isar-image-debug.bb > b/meta-isar/recipes-core/images/isar-image-debug.bb > > index 791d623..d0fe331 100644 > > --- a/meta-isar/recipes-core/images/isar-image-debug.bb > > +++ b/meta-isar/recipes-core/images/isar-image-debug.bb > > @@ -7,3 +7,5 @@ require recipes-core/images/isar-image-base.bb > > > > IMAGE_PREINSTALL += "gdb \ > > strace" > > + > > +IMAGE_INSTALL += "kselftest" > > diff --git a/meta-isar/recipes-kernel/kselftest/kselftest_5.6.13.bb > b/meta-isar/recipes-kernel/kselftest/kselftest_5.6.13.bb > > new file mode 100644 > > index 0000000..0c9818a > > --- /dev/null > > +++ b/meta-isar/recipes-kernel/kselftest/kselftest_5.6.13.bb > > @@ -0,0 +1,11 @@ > > +# Kselftest package > > +# > > +# This software is a part of ISAR. > > +# Copyright (c) Mentor Graphics, a Siemens business, 2020 > > +# > > +# SPDX-License-Identifier: MIT > > + > > +require recipes-kernel/kselftest/kselftest.inc > > + > > +SRC_URI += " > https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-${PV}.tar.xz" > > +SRC_URI[sha256sum] = > "f125d79c8f6974213638787adcad6b575bbd35a05851802fd83f622ec18ff987" > > diff --git a/meta/recipes-kernel/kselftest/files/rules > b/meta/recipes-kernel/kselftest/files/rules > > new file mode 100755 > > index 0000000..776d341 > > --- /dev/null > > +++ b/meta/recipes-kernel/kselftest/files/rules > > @@ -0,0 +1,41 @@ > > +#!/usr/bin/make -f > > + > > +# Debian rules for Kselftest build > > +# > > +# This software is a part of ISAR. > > +# Copyright (c) Mentor, A Siemens Business > > +# > > +# SPDX-License-Identifier: MIT > > + > > +deb_top_dir:=$(CURDIR)/debian > > +kselftest_install_dir :=$(deb_top_dir)/kselftest/usr/libexec/kselftest > > +export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- > > + > > +ifeq ($(DEB_HOST_GNU_CPU), arm) > > +export ARCH=arm > > +endif > > +ifeq ($(DEB_HOST_GNU_CPU), aarch64) > > +export ARCH=arm64 > > +endif > > +ifeq ($(DEB_HOST_GNU_CPU), riscv64) > > +export ARCH=riscv > > +endif > > +ifneq (,$(findstring 86,$(DEB_HOST_GNU_CPU))) > > +export ARCH=x86 > > +endif > > + > > +PARALLEL_BUILD=-j $(shell echo $$(($$(nproc) * 2))) > > + > > +override_dh_auto_build: > > + $(MAKE) defconfig > > + $(MAKE) $(PARALLEL_BUILD) -C tools/testing/selftests/ > ${KSELFTEST_ARGS} > > + > > +override_dh_auto_install: > > + mkdir -p ${kselftest_install_dir} > > + cd tools/testing/selftests/ && > KSFT_INSTALL_PATH=${kselftest_install_dir} $(MAKE) $(PARALLEL_BUILD) > install ${KSELFTEST_ARGS} > > + > > +override_dh_auto_clean: > > + rm -rf ${deb_top_dir}/kselftest/ > > + > > +%: > > + CFLAGS= LDFLAGS= dh $@ --parallel > > diff --git a/meta/recipes-kernel/kselftest/kselftest.inc > b/meta/recipes-kernel/kselftest/kselftest.inc > > new file mode 100644 > > index 0000000..ca9b882 > > --- /dev/null > > +++ b/meta/recipes-kernel/kselftest/kselftest.inc > > @@ -0,0 +1,59 @@ > > +# Kselftest package for Linux > > +# > > +# This software is a part of ISAR. > > +# Copyright (c) Mentor Graphics, a Siemens Business, 2020 > > +# > > +# SPDX-License-Identifier: MIT > > + > > +inherit dpkg > > + > > +FILESEXTRAPATHS_prepend := "${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, \ > > + libelf-dev:native, \ > > + libcap-ng-dev:native, \ > > + libpopt-dev:native, \ > > + libcap-dev:native, \ > > + libmount-dev:native, \ > > + libnuma-dev:native, \ > > + libfuse-dev:native, \ > > + libmnl-dev:native, \ > > + pkg-config, \ > > + clang:native, \ > > + llvm:native, \ > > +" > > + > > +SRC_URI += "file://rules" > > +S = "${WORKDIR}/linux-${PV}" > > + > > +KSELFTEST_TARGETS ?= "" > > +KSELFTEST_SKIP_TARGETS ?= "" > > +KSELFTEST_FORCE_TARGETS ?= "0" > > + > > +do_prepare_build[cleandirs] += "${S}/debian" > > +do_prepare_build() { > > + deb_debianize > > +} > > + > > +dpkg_runbuild_prepend() { > > + if [ -n "${KSELFTEST_TARGETS}" ];then > > + export KSELFTEST_ARGS="TARGETS=\"${KSELFTEST_TARGETS}\"" > > + fi > > + if [ ${KSELFTEST_FORCE_TARGETS} -eq 1 ];then > > + export KSELFTEST_ARGS="${KSELFTEST_ARGS} FORCE_TARGETS=1" > > + fi > > + if [ -n "${KSELFTEST_SKIP_TARGETS}" ];then > > + export KSELFTEST_ARGS="${KSELFTEST_ARGS} > SKIP_TARGETS=\"${KSELFTEST_SKIP_TARGETS}\"" > > + fi > > +} > > > > Unless I'm missing something right now, this still lacks a test case. > Yes. Somehow I never sent that version of patch. Will send it. > > Jan > > -- > Siemens AG, T RDA IOT > Corporate Competence Center Embedded Linux > ------=_Part_1081_2099907819.1602656336211 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

On Tuesday, October 13, 2020 at 3:33:35 PM UTC+5:30 Jan Kiszka wrote:
On 29.05.20 12:15, Vijai Kumar K wrote:
> Kselftest is a set of unit and regression tests under the
> tools/testing/selftests/ directory of the Linux kernel. These are used
> for testing individual code paths in the kernel.
>
> Kselftest is not debianized and is not available as part of the official
> Debian repository.
>
> This patch provides a recipe to build kselftest from the linux source of
> your choice.
>
> Sometimes developers/testers tend to use the latest version of selftests
> from Linux upstream stable releases for testing and hence the need for a
> separate recipe instead of being part of the linux recipe of ISAR.
>
> Some kselftest test cases build are known to break in certain linux
> versions, this has to be addressed upstream. Right now kselftest build
> succeeds even if atleast one of the testcase case build succeeds.
>
> You can change that by setting KSELFTEST_FORCE_TARGETS=1.
>
> TARGETS, TARGETS_SKIP, FORCE_TARGETS can be set using the appropriate
> KSELFTEST_* recipe variable.
>
> Signed-off-by: Vijai Kumar K <Vijaikumar_...@mentor.com>
> ---
> Changes since v2:
> - Use deb_debianize instead of individual calls for changelog, compat & control.
> - Add package to isar-image-debug
>
> Changes since v1:
> - Addressed review comments in v1
> - Used debianize APIs for control, compat and changelog.
> - Moved Depends & S definitions to include file.
> - Added cross compilation bits in rules.
> - Change clang, llvm to clang:native & llvm:native
> .../recipes-core/images/isar-image-debug.bb | 2 +
> .../kselftest/kselftest_5.6.13.bb | 11 ++++
> meta/recipes-kernel/kselftest/files/rules | 41 +++++++++++++
> meta/recipes-kernel/kselftest/kselftest.inc | 59 +++++++++++++++++++
> 4 files changed, 113 insertions(+)
> create mode 100644 meta-isar/recipes-kernel/kselftest/kselftest_5.6.13.bb
> create mode 100755 meta/recipes-kernel/kselftest/files/rules
> create mode 100644 meta/recipes-kernel/kselftest/kselftest.inc
>
> diff --git a/meta-isar/recipes-core/images/isar-image-debug.bb b/meta-isar/recipes-core/images/isar-image-debug.bb
> index 791d623..d0fe331 100644
> --- a/meta-isar/recipes-core/images/isar-image-debug.bb
> +++ b/meta-isar/recipes-core/images/isar-image-debug.bb
> @@ -7,3 +7,5 @@ require recipes-core/images/isar-image-base.bb
>
> IMAGE_PREINSTALL += "gdb \
> strace"
> +
> +IMAGE_INSTALL += "kselftest"
> diff --git a/meta-isar/recipes-kernel/kselftest/kselftest_5.6.13.bb b/meta-isar/recipes-kernel/kselftest/kselftest_5.6.13.bb
> new file mode 100644
> index 0000000..0c9818a
> --- /dev/null
> +++ b/meta-isar/recipes-kernel/kselftest/kselftest_5.6.13.bb
> @@ -0,0 +1,11 @@
> +# Kselftest package
> +#
> +# This software is a part of ISAR.
> +# Copyright (c) Mentor Graphics, a Siemens business, 2020
> +#
> +# SPDX-License-Identifier: MIT
> +
> +require recipes-kernel/kselftest/kselftest.inc
> +
> +SRC_URI += "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-${PV}.tar.xz"
> +SRC_URI[sha256sum] = "f125d79c8f6974213638787adcad6b575bbd35a05851802fd83f622ec18ff987"
> diff --git a/meta/recipes-kernel/kselftest/files/rules b/meta/recipes-kernel/kselftest/files/rules
> new file mode 100755
> index 0000000..776d341
> --- /dev/null
> +++ b/meta/recipes-kernel/kselftest/files/rules
> @@ -0,0 +1,41 @@
> +#!/usr/bin/make -f
> +
> +# Debian rules for Kselftest build
> +#
> +# This software is a part of ISAR.
> +# Copyright (c) Mentor, A Siemens Business
> +#
> +# SPDX-License-Identifier: MIT
> +
> +deb_top_dir:=$(CURDIR)/debian
> +kselftest_install_dir :=$(deb_top_dir)/kselftest/usr/libexec/kselftest
> +export CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
> +
> +ifeq ($(DEB_HOST_GNU_CPU), arm)
> +export ARCH=arm
> +endif
> +ifeq ($(DEB_HOST_GNU_CPU), aarch64)
> +export ARCH=arm64
> +endif
> +ifeq ($(DEB_HOST_GNU_CPU), riscv64)
> +export ARCH=riscv
> +endif
> +ifneq (,$(findstring 86,$(DEB_HOST_GNU_CPU)))
> +export ARCH=x86
> +endif
> +
> +PARALLEL_BUILD=-j $(shell echo $$(($$(nproc) * 2)))
> +
> +override_dh_auto_build:
> + $(MAKE) defconfig
> + $(MAKE) $(PARALLEL_BUILD) -C tools/testing/selftests/ ${KSELFTEST_ARGS}
> +
> +override_dh_auto_install:
> + mkdir -p ${kselftest_install_dir}
> + cd tools/testing/selftests/ && KSFT_INSTALL_PATH=${kselftest_install_dir} $(MAKE) $(PARALLEL_BUILD) install ${KSELFTEST_ARGS}
> +
> +override_dh_auto_clean:
> + rm -rf ${deb_top_dir}/kselftest/
> +
> +%:
> + CFLAGS= LDFLAGS= dh $@ --parallel
> diff --git a/meta/recipes-kernel/kselftest/kselftest.inc b/meta/recipes-kernel/kselftest/kselftest.inc
> new file mode 100644
> index 0000000..ca9b882
> --- /dev/null
> +++ b/meta/recipes-kernel/kselftest/kselftest.inc
> @@ -0,0 +1,59 @@
> +# Kselftest package for Linux
> +#
> +# This software is a part of ISAR.
> +# Copyright (c) Mentor Graphics, a Siemens Business, 2020
> +#
> +# SPDX-License-Identifier: MIT
> +
> +inherit dpkg
> +
> +FILESEXTRAPATHS_prepend := "${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, \
> + libelf-dev:native, \
> + libcap-ng-dev:native, \
> + libpopt-dev:native, \
> + libcap-dev:native, \
> + libmount-dev:native, \
> + libnuma-dev:native, \
> + libfuse-dev:native, \
> + libmnl-dev:native, \
> + pkg-config, \
> + clang:native, \
> + llvm:native, \
> +"
> +
> +SRC_URI += "file://rules"
> +S = "${WORKDIR}/linux-${PV}"
> +
> +KSELFTEST_TARGETS ?= ""
> +KSELFTEST_SKIP_TARGETS ?= ""
> +KSELFTEST_FORCE_TARGETS ?= "0"
> +
> +do_prepare_build[cleandirs] += "${S}/debian"
> +do_prepare_build() {
> + deb_debianize
> +}
> +
> +dpkg_runbuild_prepend() {
> + if [ -n "${KSELFTEST_TARGETS}" ];then
> + export KSELFTEST_ARGS="TARGETS=\"${KSELFTEST_TARGETS}\""
> + fi
> + if [ ${KSELFTEST_FORCE_TARGETS} -eq 1 ];then
> + export KSELFTEST_ARGS="${KSELFTEST_ARGS} FORCE_TARGETS=1"
> + fi
> + if [ -n "${KSELFTEST_SKIP_TARGETS}" ];then
> + export KSELFTEST_ARGS="${KSELFTEST_ARGS} SKIP_TARGETS=\"${KSELFTEST_SKIP_TARGETS}\""
> + fi
> +}
>

Unless I'm missing something right now, this still lacks a test case.

Yes. Somehow I never sent that version of patch. Will send it.
 

Jan

--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
------=_Part_1081_2099907819.1602656336211-- ------=_Part_1080_738194587.1602656336211--