From 1bb4c3c95e548bd57f733f2936e370cd40e81765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cotty?= Date: Wed, 16 Dec 2020 15:18:07 +0100 Subject: Add qt4 docker image for basic testing Change-Id: Ied6d9eac49fcb20de72499ab7c39e83a90a98b75 Reviewed-by: Ivan Komissarov --- .github/workflows/main.yml | 7 +++ docker-compose.yml | 8 +++ docker/focal/test-qt4.Dockerfile | 40 +++++++++++++++ scripts/test-qt4.sh | 58 ++++++++++++++++++++++ .../blackbox/testdata-qt/dbus-adaptors/car.cpp | 5 ++ .../blackbox/testdata-qt/dbus-adaptors/main.cpp | 6 +++ .../testdata-qt/dbus-interfaces/controller.cpp | 5 ++ .../blackbox/testdata-qt/dbus-interfaces/main.cpp | 5 ++ .../blackbox/testdata-qt/forced-moc/forced-moc.qbs | 6 +++ .../included-moc-cpp/included-moc-cpp.qbs | 8 +++ .../plugin-meta-data/plugin-meta-data.qbs | 7 +++ .../testdata-qt/plugin-support/plugin-support.qbs | 10 ++++ tests/auto/blackbox/testdata-qt/qrc/i.qbs | 6 +++ .../testdata-qt/quick-compiler/quick-compiler.qbs | 6 ++- tests/auto/blackbox/tst_blackboxqt.cpp | 26 ++++++++-- 15 files changed, 198 insertions(+), 5 deletions(-) create mode 100644 docker/focal/test-qt4.Dockerfile create mode 100755 scripts/test-qt4.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c155ad26e..a2714380f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -257,6 +257,13 @@ jobs: profile: '', script: './scripts/test-qt-for-android.sh', } + - { + name: 'Run Linux tests (Qt 4.8.7)', + image: 'focal-qt4', + profile: '', + script: './scripts/test-qt4.sh', + } + env: QBS_TEST_SOURCE_ROOT: 'tests' QBS_AUTOTEST_PROFILE: ${{ matrix.config.profile }} diff --git a/docker-compose.yml b/docker-compose.yml index ef53a0fb0..4a2851e8e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -77,6 +77,14 @@ services: dockerfile: docker/focal/test-baremetal.Dockerfile context: . + focal-qt4: + << : *linux + hostname: focal-qt4 + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-qt4-0 + build: + dockerfile: docker/focal/test-qt4.Dockerfile + context: . + windows: image: ${DOCKER_USER:-qbsbuild}/qbsdev:windowsservercore-5.15.0_1.16.0-0 build: diff --git a/docker/focal/test-qt4.Dockerfile b/docker/focal/test-qt4.Dockerfile new file mode 100644 index 000000000..c23a664d2 --- /dev/null +++ b/docker/focal/test-qt4.Dockerfile @@ -0,0 +1,40 @@ +# +# Testing Qbs with qt4 +# +FROM ubuntu:focal +LABEL Description="Ubuntu qt4 test environment for Qbs" + +# Allow colored output on command line. +ENV TERM=xterm-color + +# +# Make it possible to change UID/GID in the entrypoint script. The docker +# container usually runs as root user on Linux hosts. When the Docker container +# mounts a folder on the host and creates files there, those files would be +# owned by root instead of the current user. Thus we create a user here who's +# UID will be changed in the entrypoint script to match the UID of the current +# host user. +# +ARG USER_UID=1000 +ARG USER_NAME=devel +RUN apt-get update -qq && \ + apt-get install -qq -y \ + ca-certificates \ + gosu \ + software-properties-common \ + sudo && \ + groupadd -g ${USER_UID} ${USER_NAME} && \ + useradd -s /bin/bash -u ${USER_UID} -g ${USER_NAME} -o -c "" -m ${USER_NAME} && \ + usermod -a -G sudo ${USER_NAME} && \ + echo "%devel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +COPY docker/focal/entrypoint.sh /sbin/entrypoint.sh +ENTRYPOINT ["/sbin/entrypoint.sh"] + +# Install baremetal toolchains and Qbs runtime dependencies. +RUN sudo add-apt-repository ppa:gezakovacs/ppa -y && \ + apt-get update -qq && \ + apt-get install -qq -y \ + build-essential \ + libqt4-dev + diff --git a/scripts/test-qt4.sh b/scripts/test-qt4.sh new file mode 100755 index 000000000..b4b0078e4 --- /dev/null +++ b/scripts/test-qt4.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +set -eu + +############################################################################# +## +## Copyright (C) 2020 Raphael Cotty. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +export PATH="$1:$PATH" + +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + +# Creating the qt4 profile + +qbs-setup-toolchains /usr/bin/g++ gcc +qbs-setup-qt /usr/lib/x86_64-linux-gnu/qt4/bin/qmake qt4 +# To avoid warnings due to qt4 include files +qbs config profiles.gcc.cpp.cxxFlags "-Wno-deprecated-copy" +qbs config profiles.qt4.baseProfile gcc +qbs config --list + +export QBS_AUTOTEST_PROFILE=qt4 + +tst_blackbox-qt diff --git a/tests/auto/blackbox/testdata-qt/dbus-adaptors/car.cpp b/tests/auto/blackbox/testdata-qt/dbus-adaptors/car.cpp index 5e4f348d2..f67e4c193 100644 --- a/tests/auto/blackbox/testdata-qt/dbus-adaptors/car.cpp +++ b/tests/auto/blackbox/testdata-qt/dbus-adaptors/car.cpp @@ -49,7 +49,12 @@ ****************************************************************************/ #include "car.h" + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include +#else +#include +#endif #include static const double Pi = 3.14159265358979323846264338327950288419717; diff --git a/tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp b/tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp index 0491719d7..197005215 100644 --- a/tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp +++ b/tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp @@ -50,9 +50,15 @@ #include "car.h" #include "car_adaptor.h" +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include #include #include +#else +#include +#include +#include +#endif #include int main(int argc, char *argv[]) diff --git a/tests/auto/blackbox/testdata-qt/dbus-interfaces/controller.cpp b/tests/auto/blackbox/testdata-qt/dbus-interfaces/controller.cpp index eaff5c775..f6680676a 100644 --- a/tests/auto/blackbox/testdata-qt/dbus-interfaces/controller.cpp +++ b/tests/auto/blackbox/testdata-qt/dbus-interfaces/controller.cpp @@ -48,7 +48,12 @@ ** ****************************************************************************/ +#include +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include +#else +#include +#endif #include "controller.h" #include "car_interface.h" diff --git a/tests/auto/blackbox/testdata-qt/dbus-interfaces/main.cpp b/tests/auto/blackbox/testdata-qt/dbus-interfaces/main.cpp index fdd9fc590..5ceba5a9f 100644 --- a/tests/auto/blackbox/testdata-qt/dbus-interfaces/main.cpp +++ b/tests/auto/blackbox/testdata-qt/dbus-interfaces/main.cpp @@ -48,7 +48,12 @@ ** ****************************************************************************/ +#include +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include +#else +#include +#endif #include #include "controller.h" diff --git a/tests/auto/blackbox/testdata-qt/forced-moc/forced-moc.qbs b/tests/auto/blackbox/testdata-qt/forced-moc/forced-moc.qbs index 736f40347..aab7ed220 100644 --- a/tests/auto/blackbox/testdata-qt/forced-moc/forced-moc.qbs +++ b/tests/auto/blackbox/testdata-qt/forced-moc/forced-moc.qbs @@ -1,5 +1,11 @@ +import qbs.Utilities + QtApplication { condition: { + if (Utilities.versionCompare(Qt.core.version, "5.0") < 0) { + console.info("using qt4"); + return false; + } var result = qbs.targetPlatform === qbs.hostPlatform; if (!result) console.info("targetPlatform differs from hostPlatform"); diff --git a/tests/auto/blackbox/testdata-qt/included-moc-cpp/included-moc-cpp.qbs b/tests/auto/blackbox/testdata-qt/included-moc-cpp/included-moc-cpp.qbs index 1ed85ccdd..218d5c150 100644 --- a/tests/auto/blackbox/testdata-qt/included-moc-cpp/included-moc-cpp.qbs +++ b/tests/auto/blackbox/testdata-qt/included-moc-cpp/included-moc-cpp.qbs @@ -1,6 +1,14 @@ import qbs +import qbs.Utilities QtApplication { + condition: { + if (Utilities.versionCompare(Qt.core.version, "5.0") < 0) { + console.info("using qt4"); + return false; + } + return true; + } files: [ "main.cpp", "myobject.cpp", diff --git a/tests/auto/blackbox/testdata-qt/plugin-meta-data/plugin-meta-data.qbs b/tests/auto/blackbox/testdata-qt/plugin-meta-data/plugin-meta-data.qbs index 7fb477575..7e5f98340 100644 --- a/tests/auto/blackbox/testdata-qt/plugin-meta-data/plugin-meta-data.qbs +++ b/tests/auto/blackbox/testdata-qt/plugin-meta-data/plugin-meta-data.qbs @@ -1,6 +1,13 @@ +import qbs.Utilities + Project { QtApplication { condition: { + if (Utilities.versionCompare(Qt.core.version, "5.0") < 0) { + // qt4 moc can't be used with pluginMetaData + console.info("using qt4"); + return false; + } var result = qbs.targetPlatform === qbs.hostPlatform; if (!result) console.info("targetPlatform differs from hostPlatform"); diff --git a/tests/auto/blackbox/testdata-qt/plugin-support/plugin-support.qbs b/tests/auto/blackbox/testdata-qt/plugin-support/plugin-support.qbs index c554a7dc2..8e0923e94 100644 --- a/tests/auto/blackbox/testdata-qt/plugin-support/plugin-support.qbs +++ b/tests/auto/blackbox/testdata-qt/plugin-support/plugin-support.qbs @@ -1,4 +1,14 @@ +import qbs.Utilities + QtGuiApplication { + condition: { + // pluginTypes empty for Qt4 + if (Utilities.versionCompare(Qt.core.version, "5.0") < 0) { + console.info("using qt4"); + return false; + } + return true; + } Probe { id: staticProbe property bool isStaticQt: Qt.gui.isStaticLibrary diff --git a/tests/auto/blackbox/testdata-qt/qrc/i.qbs b/tests/auto/blackbox/testdata-qt/qrc/i.qbs index 604652a8e..e98c069b5 100644 --- a/tests/auto/blackbox/testdata-qt/qrc/i.qbs +++ b/tests/auto/blackbox/testdata-qt/qrc/i.qbs @@ -1,6 +1,12 @@ +import qbs.Utilities + Project { Product { condition: { + if (Utilities.versionCompare(Qt.core.version, "5.0") < 0) { + console.info("using qt4"); + return false; + } var result = qbs.targetPlatform === qbs.hostPlatform; if (!result) console.info("targetPlatform differs from hostPlatform"); diff --git a/tests/auto/blackbox/testdata-qt/quick-compiler/quick-compiler.qbs b/tests/auto/blackbox/testdata-qt/quick-compiler/quick-compiler.qbs index b141c8672..793d261e9 100644 --- a/tests/auto/blackbox/testdata-qt/quick-compiler/quick-compiler.qbs +++ b/tests/auto/blackbox/testdata-qt/quick-compiler/quick-compiler.qbs @@ -1,5 +1,9 @@ CppApplication { - Depends { name: "Qt.quick" } + Depends { + name: "Qt.quick" + // Must fail when using Qt4 + versionAtLeast: "5" + } Qt.quick.useCompiler: Qt.quick.compilerAvailable cpp.cxxLanguageVersion: "c++11" diff --git a/tests/auto/blackbox/tst_blackboxqt.cpp b/tests/auto/blackbox/tst_blackboxqt.cpp index 4fc038923..53fadc490 100644 --- a/tests/auto/blackbox/tst_blackboxqt.cpp +++ b/tests/auto/blackbox/tst_blackboxqt.cpp @@ -70,7 +70,9 @@ void TestBlackboxQt::autoQrc() void TestBlackboxQt::cachedQml() { QDir::setCurrent(testDataDir + "/cached-qml"); - QCOMPARE(runQbs(), 0); + if ((runQbs() != 0) && m_qbsStderr.contains("Dependency 'Qt.qml' not found for product 'app'")) + QSKIP("Qt version too old"); + QString dataDir = relativeBuildDir() + "/install-root/data"; QVERIFY2(m_qbsStdout.contains("qmlcachegen must work: true") || m_qbsStdout.contains("qmlcachegen must work: false"), @@ -133,6 +135,8 @@ void TestBlackboxQt::forcedMoc() { QDir::setCurrent(testDataDir + "/forced-moc"); QCOMPARE(runQbs(QbsRunParameters("resolve")), 0); + if (m_qbsStdout.contains("using qt4")) + QSKIP("Qt version too old"); if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) QSKIP("Cannot run binaries in cross-compiled build"); QCOMPARE(runQbs(QbsRunParameters("run")), 0); @@ -143,6 +147,8 @@ void TestBlackboxQt::includedMocCpp() { QDir::setCurrent(testDataDir + "/included-moc-cpp"); QCOMPARE(runQbs(), 0); + if (m_qbsStdout.contains("using qt4")) + QSKIP("Qt version too old"); QVERIFY2(!m_qbsStdout.contains("compiling moc_myobject.cpp"), m_qbsStdout.constData()); WAIT_FOR_NEW_TIMESTAMP(); REPLACE_IN_FILE("myobject.cpp", "#include