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 <mikko.gronoff@qt.io>
This commit is contained in:
Samuli Piippo 2021-04-29 15:33:21 +03:00
parent 5ce04254ae
commit 7ec2742246
9 changed files with 74 additions and 5 deletions

View File

@ -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]

View File

@ -0,0 +1,5 @@
#!/bin/sh
for test in $(cat tst_list); do
( cd $(dirname ${test}) && ./$(basename ${test}) )
done

View File

@ -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"

View File

@ -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"

View File

@ -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,"

View File

@ -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} \
"

View File

@ -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)}"

View File

@ -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"

View File

@ -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"