From 7ec274224688e9e7da2b57164516ffc2f79a100a Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Thu, 29 Apr 2021 15:33:21 +0300 Subject: [PATCH] Enable ptest support for Qt modules Build tests for ptest in Qt modules. The default build using PACKAGECONFIG[tests] doesn't work as the installation of tests is not working correctly. Instead build the tests separately after the module has been built and installed. The tests have dependencies to the data and source files which need to be packaged with the test binaries. Change-Id: Ibae55a29135267ce96949aa0c15ad7e236ef2512 Reviewed-by: Mikko Gronoff --- classes/qt6-paths.bbclass | 2 +- recipes-qt/qt6/ptest/run-ptest | 5 +++ recipes-qt/qt6/qt5compat_git.bb | 2 +- recipes-qt/qt6/qt6-ptest.inc | 51 ++++++++++++++++++++++++++++ recipes-qt/qt6/qt6.inc | 2 ++ recipes-qt/qt6/qtbase_git.bb | 9 ++++- recipes-qt/qt6/qtconnectivity_git.bb | 3 ++ recipes-qt/qt6/qtmultimedia_git.bb | 2 ++ recipes-qt/qt6/qtscxml_git.bb | 3 +- 9 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 recipes-qt/qt6/ptest/run-ptest create mode 100644 recipes-qt/qt6/qt6-ptest.inc diff --git a/classes/qt6-paths.bbclass b/classes/qt6-paths.bbclass index 7e0b514..3f25b0d 100644 --- a/classes/qt6-paths.bbclass +++ b/classes/qt6-paths.bbclass @@ -26,7 +26,7 @@ QT6_INSTALL_SYSCONFDIR ?= "${sysconfdir}/xdg" # Examples [PREFIX/examples] QT6_INSTALL_EXAMPLESDIR ?= "${datadir}/examples" # Tests [PREFIX/tests] -QT6_INSTALL_TESTSDIR ?= "${datadir}/tests" +QT6_INSTALL_TESTSDIR ?= "${prefix}/tests" # Module description files directory [DATADIR/modules] QT6_INSTALL_DESCRIPTIONSDIR ?= "${datadir}/modules" # Mkspecs files [PREFIX/mkspecs] diff --git a/recipes-qt/qt6/ptest/run-ptest b/recipes-qt/qt6/ptest/run-ptest new file mode 100644 index 0000000..3933bae --- /dev/null +++ b/recipes-qt/qt6/ptest/run-ptest @@ -0,0 +1,5 @@ +#!/bin/sh + +for test in $(cat tst_list); do + ( cd $(dirname ${test}) && ./$(basename ${test}) ) +done diff --git a/recipes-qt/qt6/qt5compat_git.bb b/recipes-qt/qt6/qt5compat_git.bb index f38080a..03c116f 100644 --- a/recipes-qt/qt6/qt5compat_git.bb +++ b/recipes-qt/qt6/qt5compat_git.bb @@ -10,8 +10,8 @@ LIC_FILES_CHKSUM = " \ inherit qt6-cmake -include recipes-qt/qt6/qt6.inc include recipes-qt/qt6/qt6-git.inc +include recipes-qt/qt6/qt6.inc DEPENDS += "qtbase" diff --git a/recipes-qt/qt6/qt6-ptest.inc b/recipes-qt/qt6/qt6-ptest.inc new file mode 100644 index 0000000..3b7d17f --- /dev/null +++ b/recipes-qt/qt6/qt6-ptest.inc @@ -0,0 +1,51 @@ +FILESEXTRAPATHS_append := ":${THISDIR}/ptest" +SRC_URI += "file://run-ptest" + +inherit ptest + +fakeroot do_install_ptest() { + if [ -n "${OE_QMAKE_QMAKE}" ]; then + # qmake project + B_PTEST=${B} + mkdir -p ${B_PTEST}/tests + cd ${B_PTEST}/tests + ${OE_QMAKE_QMAKE} -o Makefile ${S}/tests + oe_runmake + else + # cmake project + B_PTEST=${WORKDIR}/build-ptest + mkdir -p ${B_PTEST} + cd ${B_PTEST} + cmake \ + ${OECMAKE_GENERATOR_ARGS} \ + -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \ + ${EXTRA_OECMAKE} \ + -DQT_BUILD_STANDALONE_TESTS=ON \ + -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=${D}${QT6_INSTALL_LIBDIR}/cmake \ + -DCMAKE_STAGING_PREFIX=${D}${prefix} \ + ${S} \ + -Wno-dev + ${CMAKE_VERBOSE} cmake --build ${B_PTEST} --target all + fi + + # if any auto tests were build + if [ -e "${B_PTEST}/tests/auto" ]; then + install -d ${D}${PTEST_PATH}/tests + cp -r ${B_PTEST}/tests/auto ${D}${PTEST_PATH}/tests + + # remove build files + find ${D}${PTEST_PATH}/tests \ + \( -wholename "*/.*" -o -wholename "*autogen*" -o -iwholename "*cmake*" -o -name Makefile \) \ + -delete + + for f in $(find ${D}${PTEST_PATH} -name tst_* -executable); do + test=${f##${D}${PTEST_PATH}/} + testdir=$(dirname ${test}) + # tests may depend on files from sources + cp -r ${S}/${testdir}/* ${D}${PTEST_PATH}/${testdir} + echo ${test} >> ${D}${PTEST_PATH}/tst_list + done + fi +} + +INSANE_SKIP_${PN}-ptest += "file-rdeps" diff --git a/recipes-qt/qt6/qt6.inc b/recipes-qt/qt6/qt6.inc index 64cf6a4..4d9354d 100644 --- a/recipes-qt/qt6/qt6.inc +++ b/recipes-qt/qt6/qt6.inc @@ -1,5 +1,7 @@ inherit srcrev-update +include recipes-qt/qt6/qt6-ptest.inc + PACKAGECONFIG[examples] = "-DQT_BUILD_EXAMPLES=ON,-DQT_BUILD_EXAMPLES=OFF," PACKAGECONFIG[tests] = "-DQT_BUILD_TESTS=ON,-DQT_BUILD_TESTS=OFF," diff --git a/recipes-qt/qt6/qtbase_git.bb b/recipes-qt/qt6/qtbase_git.bb index 5c43781..af2b8e5 100644 --- a/recipes-qt/qt6/qtbase_git.bb +++ b/recipes-qt/qt6/qtbase_git.bb @@ -10,8 +10,8 @@ LIC_FILES_CHKSUM = " \ inherit qt6-cmake -include recipes-qt/qt6/qt6.inc include recipes-qt/qt6/qt6-git.inc +include recipes-qt/qt6/qt6.inc SRC_URI += "\ file://0001-Add-linux-oe-g-platform.patch \ @@ -147,6 +147,13 @@ set(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING "TRUE" CACHE BOOL "") EOF } +INSANE_SKIP_${PN}-ptest += "arch" +INHIBIT_PACKAGE_STRIP_FILES = "\ + ${PKGD}${PTEST_PATH}/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt2.elf64.so \ + ${PKGD}${PTEST_PATH}/tests/auto/corelib/plugin/qpluginloader/elftest/corrupt3.elf64.so \ + ${PKGD}${PTEST_PATH}/tests/auto/corelib/plugin/qpluginloader/elftest/debugobj.so \ +" + FILES_${PN}-tools += "\ ${QT6_INSTALL_LIBEXECDIR} \ " diff --git a/recipes-qt/qt6/qtconnectivity_git.bb b/recipes-qt/qt6/qtconnectivity_git.bb index 2baca3d..9893148 100644 --- a/recipes-qt/qt6/qtconnectivity_git.bb +++ b/recipes-qt/qt6/qtconnectivity_git.bb @@ -12,6 +12,9 @@ inherit qt6-cmake include recipes-qt/qt6/qt6-git.inc include recipes-qt/qt6/qt6.inc +# QTBUG-93565 +PTEST_ENABLED = "0" + DEPENDS += "qtbase qtdeclarative" PACKAGECONFIG ?= "${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)}" diff --git a/recipes-qt/qt6/qtmultimedia_git.bb b/recipes-qt/qt6/qtmultimedia_git.bb index e5a9954..af856cf 100644 --- a/recipes-qt/qt6/qtmultimedia_git.bb +++ b/recipes-qt/qt6/qtmultimedia_git.bb @@ -14,6 +14,8 @@ include recipes-qt/qt6/qt6.inc QT_MODULE_BRANCH = "wip/qt6" +PTEST_ENABLED = "0" + DEPENDS += "qtbase qtshadertools qtshadertools-native" PACKAGECONFIG ?= "gstreamer qml" diff --git a/recipes-qt/qt6/qtscxml_git.bb b/recipes-qt/qt6/qtscxml_git.bb index 753e856..aca2947 100644 --- a/recipes-qt/qt6/qtscxml_git.bb +++ b/recipes-qt/qt6/qtscxml_git.bb @@ -10,10 +10,9 @@ inherit qt6-cmake include recipes-qt/qt6/qt6-git.inc include recipes-qt/qt6/qt6.inc -DEPENDS += "qtbase" +DEPENDS += "qtbase qtscxml-native" PACKAGECONFIG ?= "qml" -PACKAGECONFIG[examples] = "-DQT_BUILD_EXAMPLES=ON,-DQT_BUILD_EXAMPLES=OFF,qtscxml-native" PACKAGECONFIG[qml] = ",,qtdeclarative qtdeclarative-native" BBCLASSEXTEND = "native nativesdk"