diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-twister-remove-python3-tabulate-dependence.patch b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-twister-remove-python3-tabulate-dependence.patch new file mode 100644 index 0000000000000000000000000000000000000000..d5fa07a671310116e8a0c9eb702422d22752926d --- /dev/null +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0001-twister-remove-python3-tabulate-dependence.patch @@ -0,0 +1,52 @@ +From 7d675296e8dab18299ff853afb29e20808115085 Mon Sep 17 00:00:00 2001 +From: Chase Qi <chase.qi@linaro.org> +Date: Mon, 9 May 2022 18:27:17 +0800 +Subject: [PATCH 1/2] twister: remove python3-tabulate dependence + +tabulate module is need by --device-testing option, but not needed by +--build-only option. Remove the dependence as there is no provider for +python3-tabulate-native yet. + +Upstream status: inappropriate [OE specific] + +Signed-off-by: Chase Qi <chase.qi@linaro.org> +--- + scripts/pylib/twister/twisterlib.py | 5 ----- + scripts/twister | 5 ----- + 2 files changed, 10 deletions(-) + +diff --git a/scripts/pylib/twister/twisterlib.py b/scripts/pylib/twister/twisterlib.py +index 7754532411..e8c342df91 100755 +--- a/scripts/pylib/twister/twisterlib.py ++++ b/scripts/pylib/twister/twisterlib.py +@@ -47,11 +47,6 @@ try: + except ImportError: + print("Install pyserial python module with pip to use --device-testing option.") + +-try: +- from tabulate import tabulate +-except ImportError: +- print("Install tabulate python module with pip to use --device-testing option.") +- + try: + import psutil + except ImportError: +diff --git a/scripts/twister b/scripts/twister +index 9e041f1f76..f54f67b86c 100755 +--- a/scripts/twister ++++ b/scripts/twister +@@ -199,11 +199,6 @@ try: + except ImportError: + print("Install the anytree module to use the --test-tree option") + +-try: +- from tabulate import tabulate +-except ImportError: +- print("Install tabulate python module with pip to use --device-testing option.") +- + sys.path.insert(0, os.path.join(ZEPHYR_BASE, "scripts/pylib/twister")) + + from twisterlib import HardwareMap, TestSuite, SizeCalculator, CoverageTool, ExecutionCounter +-- +2.25.1 + diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0002-twister-set-toolchain-to-ZEPHYR_GCC_VARIANT.patch b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0002-twister-set-toolchain-to-ZEPHYR_GCC_VARIANT.patch new file mode 100644 index 0000000000000000000000000000000000000000..2273204cd26d731f374b8d4512edf331bffe2656 --- /dev/null +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/files/0002-twister-set-toolchain-to-ZEPHYR_GCC_VARIANT.patch @@ -0,0 +1,30 @@ +From 4f48eac03ac25a66af25d72e7b88f04d3ddd770d Mon Sep 17 00:00:00 2001 +From: Chase Qi <chase.qi@linaro.org> +Date: Mon, 9 May 2022 18:31:19 +0800 +Subject: [PATCH 2/2] twister: set toolchain to ZEPHYR_GCC_VARIANT + +Set toolchain to ZEPHYR_GCC_VARIANT. Defaults to 'yocto'. + +Upstream status: inappropriate [OE specific] + +Signed-off-by: Chase Qi <chase.qi@linaro.org> +--- + scripts/pylib/twister/twisterlib.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/scripts/pylib/twister/twisterlib.py b/scripts/pylib/twister/twisterlib.py +index e8c342df91..d54d13fdc0 100755 +--- a/scripts/pylib/twister/twisterlib.py ++++ b/scripts/pylib/twister/twisterlib.py +@@ -3042,6 +3042,8 @@ class TestSuite(DisablePyTestCollectionMixin): + + @staticmethod + def get_toolchain(): ++ return os.getenv("ZEPHYR_GCC_VARIANT", "yocto") ++ + toolchain_script = Path(ZEPHYR_BASE) / Path('cmake/verify-toolchain.cmake') + result = CMake.run_cmake_script([toolchain_script, "FORMAT=json"]) + +-- +2.25.1 + diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-test-twister.bb b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-test-twister.bb new file mode 100644 index 0000000000000000000000000000000000000000..f0e10fc90fe8833a6ddc7633153dd14e35e3ecc2 --- /dev/null +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-test-twister.bb @@ -0,0 +1,95 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" +SRC_URI:append = " \ + file://0001-twister-remove-python3-tabulate-dependence.patch \ + file://0002-twister-set-toolchain-to-ZEPHYR_GCC_VARIANT.patch \ +" + +ZEPHYR_INHERIT_CLASSES += "zephyr cmake" +inherit ${ZEPHYR_INHERIT_CLASSES} + +require zephyr-kernel-test.inc +require zephyr-sample.inc + +ZEPHYR_SRC_DIR = "${S}/tests/kernel/pending/" +OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}" + +DEPENDS += "\ + python3-pyserial-native \ + python3-psutil-native \ + python3-anytree-native \ + python3-ply-native \ +" + +do_compile() { + if test -n "${ZEPHYRTESTS}"; then + tc_root_options="${@' '.join(['-T tests/kernel/' + i + ' ' for i in d.getVar('ZEPHYRTESTS').split()])}" + bbnote "Test case root options: ${tc_root_options}" + bbnote "Generating twister-out ..." + cd ${S} + rm -rf twister-out + # Twister runs both 'cmake' and 'cmake --build' itself to configure and + # compile test images respectively. All the flags using in cmake.bbclass + # should be passed to twister so that tests are configured properly. + # References: + # Standard target filesystem paths: http://cgit.openembedded.org/openembedded-core/tree/meta/conf/bitbake.conf + # cmake.bbclass: http://cgit.openembedded.org/openembedded-core/tree/meta/classes/cmake.bbclass + ./scripts/twister \ + -x=CMAKE_INSTALL_PREFIX:PATH=${prefix} \ + -x=CMAKE_INSTALL_BINDIR:PATH=${@os.path.relpath(d.getVar('bindir'), d.getVar('prefix') + '/')} \ + -x=CMAKE_INSTALL_SBINDIR:PATH=${@os.path.relpath(d.getVar('sbindir'), d.getVar('prefix') + '/')} \ + -x=CMAKE_INSTALL_LIBEXECDIR:PATH=${@os.path.relpath(d.getVar('libexecdir'), d.getVar('prefix') + '/')} \ + -x=CMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir} \ + -x=CMAKE_INSTALL_SHAREDSTATEDIR:PATH=${@os.path.relpath(d.getVar('sharedstatedir'), d.getVar('prefix') + '/')} \ + -x=CMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir} \ + -x=CMAKE_INSTALL_LIBDIR:PATH=${@os.path.relpath(d.getVar('libdir'), d.getVar('prefix') + '/')} \ + -x=CMAKE_INSTALL_INCLUDEDIR:PATH=${@os.path.relpath(d.getVar('includedir'), d.getVar('prefix') + '/')} \ + -x=CMAKE_INSTALL_DATAROOTDIR:PATH=${@os.path.relpath(d.getVar('datadir'), d.getVar('prefix') + '/')} \ + -x=PYTHON_EXECUTABLE:PATH=${PYTHON} \ + -x=Python_EXECUTABLE:PATH=${PYTHON} \ + -x=Python3_EXECUTABLE:PATH=${PYTHON} \ + -x=LIB_SUFFIX=${@d.getVar('baselib').replace('lib', '')} \ + -x=CMAKE_INSTALL_SO_NO_EXE=0 \ + -x=CMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \ + -x=CMAKE_NO_SYSTEM_FROM_IMPORTED=1 \ + -x=CMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON \ + -x=FETCHCONTENT_FULLY_DISCONNECTED=ON \ + -x=ZEPHYR_BASE=${S} \ + -x=ZEPHYR_GCC_VARIANT=${ZEPHYR_GCC_VARIANT} \ + -x=BOARD=${BOARD} \ + -x=ARCH=${ARCH} \ + -x=CROSS_COMPILE=${CROSS_COMPILE} \ + -x=ZEPHYR_SYSROOT=${ZEPHYR_SYSROOT} \ + -x=ZEPHYR_TOOLCHAIN_VARIANT=${ZEPHYR_GCC_VARIANT} \ + -x=EXTRA_CPPFLAGS=${CPPFLAGS} \ + -x=ZEPHYR_MODULES=${ZEPHYR_MODULES} \ + --force-toolchain \ + -p ${@d.getVar('MACHINE').replace("-", "_")} \ + --build-only \ + ${tc_root_options} \ + -vvv + else + bbnote "Do nothing as ZEPHYRTESTS is empty." + fi +} + +do_deploy () { + if test -n "${ZEPHYRTESTS}"; then + # Twister '--test-only' option only needs the below files. Directory + # structure must be kept as it is. + # - zephyr.elf + # - twister.csv + twister_out="${S}/twister-out" + find ${twister_out}/ \( -type f -o -type l \) -a ! \( -name "zephyr.elf" -o -name "twister.csv" \) -print -delete + find ${twister_out}/ -empty -type d -delete + + image_name="twister-out-${MACHINE}.tar.bz2" + tar -jcvf ${image_name} -C ${S} twister-out + install -D ${image_name} ${DEPLOYDIR}/ + else + bbnote "Do nothing as ZEPHYRTESTS is empty." + fi +}