diff options
Diffstat (limited to 'tests/auto/blackbox')
12 files changed, 160 insertions, 11 deletions
diff --git a/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs b/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs index 1ab369c88..221105a64 100644 --- a/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs +++ b/tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs @@ -63,7 +63,7 @@ Project { outputFileTags: "tool_in" outputArtifacts: { var artifacts = []; - for (var i = 0; i < 7; ++i) + for (var i = 0; i < 5; ++i) artifacts.push({filePath: "file" + i + ".in", fileTags: "tool_in"}); return artifacts; } diff --git a/tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp b/tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp index 0a94c6393..ec9acba80 100644 --- a/tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp +++ b/tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) return 4; } } - std::this_thread::sleep_for(std::chrono::milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); fclose(lockFile); std::FILE * const output = std::fopen(argv[1], "w"); if (!output) { diff --git a/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs b/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs new file mode 100644 index 000000000..49ee35d3a --- /dev/null +++ b/tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs @@ -0,0 +1,20 @@ +Project { + CppApplication { + name: "testApp" + type: ["application", "autotest"] + Depends { name: "autotest" } + cpp.cxxLanguageVersion: "c++11" + cpp.minimumOsxVersion: "10.8" // For <chrono> + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.driverFlags: "-pthread" + } + files: "test-main.cpp" + } + AutotestRunner { + Depends { + name: "cpp" // Make sure build environment is set up properly. + condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc") + } + } +} diff --git a/tests/auto/blackbox/testdata/autotest-timeout/test-main.cpp b/tests/auto/blackbox/testdata/autotest-timeout/test-main.cpp new file mode 100644 index 000000000..4bb1ca27c --- /dev/null +++ b/tests/auto/blackbox/testdata/autotest-timeout/test-main.cpp @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Jochen Ulrich <jochenulrich@t-online.de> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <chrono> +#include <thread> + +int main() +{ + std::this_thread::sleep_for(std::chrono::seconds(5)); + return 0; +} + diff --git a/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs b/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs index 92d5ec6dd..7ae6cef73 100644 --- a/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs +++ b/tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs @@ -21,6 +21,10 @@ Project { } AutotestRunner { + Depends { + name: "cpp" // Make sure build environment is set up properly. + condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc") + } arguments: FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix, "bin") auxiliaryInputs: "test-helper" } diff --git a/tests/auto/blackbox/testdata/autotests/autotests.qbs b/tests/auto/blackbox/testdata/autotests/autotests.qbs index a2c2646dc..10334156e 100644 --- a/tests/auto/blackbox/testdata/autotests/autotests.qbs +++ b/tests/auto/blackbox/testdata/autotests/autotests.qbs @@ -1,4 +1,9 @@ Project { references: ["test1", "test2", "test3"] - AutotestRunner {} + AutotestRunner { + Depends { + name: "cpp" // Make sure build environment is set up properly. + condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("gcc") + } + } } diff --git a/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs b/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs index 61f76f4be..6cd334247 100644 --- a/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs +++ b/tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs @@ -8,6 +8,23 @@ CppApplication { cpp.cxxLanguageVersion: "c++11" cpp.minimumMacosVersion: "10.7" consoleApplication: true + Probe { + id: pathCheck + property string theDir: { + if (qbs.targetOS.contains("windows")) { + if (qbs.toolchain.contains("mingw")) + return cpp.toolchainInstallPath; + if (qbs.toolchain.contains("clang") && qbs.sysroot) + return qbs.sysroot + "/bin"; + } + } + configure: { + if (theDir) + console.info("add to PATH: " + theDir); + found = true; + } + } + files: [ "lexer.l", "parser.y", diff --git a/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs b/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs index 48bdff904..0b16d1984 100644 --- a/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs +++ b/tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs @@ -4,6 +4,15 @@ Project { type: ["application"] files: ["main.cpp"] cpp.separateDebugInformation: true + + Probe { + id: osProbe + property stringList targetOS: qbs.targetOS + configure: { + console.info("is windows: " + (targetOS.contains("windows") ? "yes" : "no")); + console.info("is darwin: " + (targetOS.contains("darwin") ? "yes" : "no")); + } + } } DynamicLibrary { Depends { name: "cpp" } diff --git a/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs b/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs index b5ac8b289..d2d47b767 100644 --- a/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs +++ b/tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs @@ -61,6 +61,16 @@ Project { bundle.isBundle: false } + // Testing shows that clang (8.0) does not find dynamic libraries via + // the -L<dir> and -l<libname> mechanism unless the name is "lib<libname>.a". + Properties { + condition: qbs.hostOS.contains("windows") && qbs.toolchain.contains("clang") + cpp.dynamicLibraryPrefix: "lib" + cpp.dynamicLibraryImportSuffix: ".a" + } + cpp.dynamicLibraryPrefix: original + cpp.dynamicLibraryImportSuffix: original + install: true installImportLib: true installDir: "lib4" @@ -91,8 +101,9 @@ Project { property string fullInstallPrefix: FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix) property string lib3FilePath: FileInfo.joinPaths(fullInstallPrefix, "lib3", - cpp.dynamicLibraryPrefix + "lib3" + (qbs.toolchain.contains("msvc") - ? ".lib" : cpp.dynamicLibrarySuffix)) + cpp.dynamicLibraryPrefix + "lib3" + (qbs.targetOS.contains("windows") + ? cpp.dynamicLibraryImportSuffix + : cpp.dynamicLibrarySuffix)) cpp.dynamicLibraries: [lib3FilePath, "lib4"] cpp.libraryPaths: FileInfo.joinPaths(fullInstallPrefix, "lib4") } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 19676d050..a2e8238c9 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich <jochenulrich@t-online.de> ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qbs. @@ -1805,14 +1806,17 @@ void TestBlackbox::separateDebugInfo() { QDir::setCurrent(testDataDir + "/separate-debug-info"); QCOMPARE(runQbs(QbsRunParameters(QStringList("qbs.debugInformation:true"))), 0); + const bool isWindows = m_qbsStdout.contains("is windows: yes"); + const bool isNotWindows = m_qbsStdout.contains("is windows: no"); + QVERIFY(isWindows != isNotWindows); + const bool isDarwin = m_qbsStdout.contains("is darwin: yes"); + const bool isNotDarwin = m_qbsStdout.contains("is darwin: no"); + QVERIFY(isDarwin != isNotDarwin); const SettingsPtr s = settings(); Profile buildProfile(profileName(), s.get()); QStringList toolchain = buildProfile.value("qbs.toolchain").toStringList(); - std::string targetPlatform = buildProfile.value("qbs.targetPlatform").toString().toStdString(); - std::vector<std::string> targetOS = HostOsInfo::canonicalOSIdentifiers(targetPlatform); - if (qbs::Internal::contains(targetOS, "darwin") - || (targetPlatform.empty() && HostOsInfo::isMacosHost())) { + if (isDarwin) { QVERIFY(directoryExists(relativeProductBuildDir("app1") + "/app1.app.dSYM")); QVERIFY(regularFileExists(relativeProductBuildDir("app1") + "/app1.app.dSYM/Contents/Info.plist")); @@ -1877,7 +1881,6 @@ void TestBlackbox::separateDebugInfo() .entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).size(), 1); QVERIFY(regularFileExists(relativeProductBuildDir("bar5") + "/bar5.bundle.dwarf")); } else if (toolchain.contains("gcc")) { - const bool isWindows = qbs::Internal::contains(targetOS, "windows"); const QString exeSuffix = isWindows ? ".exe" : ""; const QString dllPrefix = isWindows ? "" : "lib"; const QString dllSuffix = isWindows ? ".dll" : ".so"; @@ -4353,6 +4356,18 @@ void TestBlackbox::lexyacc() QCOMPARE(runQbs(), 0); const QString parserBinary = relativeExecutableFilePath("one-grammar"); QProcess p; + const QByteArray magicString = "add to PATH: "; + const int magicStringIndex = m_qbsStdout.indexOf(magicString); + if (magicStringIndex != -1) { + const int newLineIndex = m_qbsStdout.indexOf('\n', magicStringIndex); + QVERIFY(newLineIndex != -1); + const int dirIndex = magicStringIndex + magicString.length(); + const QString dir = QString::fromLocal8Bit(m_qbsStdout.mid(dirIndex, + newLineIndex - dirIndex)); + QProcessEnvironment env; + env.insert("PATH", dir); + p.setProcessEnvironment(env); + } p.start(parserBinary); QVERIFY2(p.waitForStarted(), qPrintable(p.errorString())); p.write("a && b || c && !d"); @@ -5624,6 +5639,34 @@ void TestBlackbox::autotestWithDependencies() && m_qbsStdout.contains("i am the helper"), m_qbsStdout.constData()); } +void TestBlackbox::autotestTimeout() +{ + QFETCH(QStringList, resolveParams); + QFETCH(bool, expectFailure); + QDir::setCurrent(testDataDir + "/autotest-timeout"); + QbsRunParameters resolveParameters("resolve", resolveParams); + QCOMPARE(runQbs(resolveParameters), 0); + QbsRunParameters buildParameters(QStringList({"-p", "autotest-runner"})); + buildParameters.expectFailure = expectFailure; + if (expectFailure) { + QVERIFY(runQbs(buildParameters) != 0); + QVERIFY(m_qbsStderr.contains("cancelled") && m_qbsStderr.contains("timeout")); + } + else + QVERIFY(runQbs(buildParameters) == 0); +} + +void TestBlackbox::autotestTimeout_data() +{ + QTest::addColumn<QStringList>("resolveParams"); + QTest::addColumn<bool>("expectFailure"); + QTest::newRow("no timeout") << QStringList() << false; + QTest::newRow("timeout on test") << QStringList({"products.testApp.autotest.timeout:2"}) + << true; + QTest::newRow("timeout on runner") << QStringList({"products.autotest-runner.timeout:2"}) + << true; +} + void TestBlackbox::autotests_data() { QTest::addColumn<QString>("evilPropertySpec"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 959858321..ba511ed10 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich <jochenulrich@t-online.de> ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qbs. @@ -48,6 +49,8 @@ private slots: void artifactScanning(); void assembly(); void autotestWithDependencies(); + void autotestTimeout(); + void autotestTimeout_data(); void autotests_data(); void autotests(); void auxiliaryInputsFromDependencies(); diff --git a/tests/auto/blackbox/tst_blackboxjoblimits.cpp b/tests/auto/blackbox/tst_blackboxjoblimits.cpp index 0c366759d..89b5f638e 100644 --- a/tests/auto/blackbox/tst_blackboxjoblimits.cpp +++ b/tests/auto/blackbox/tst_blackboxjoblimits.cpp @@ -165,7 +165,7 @@ void TestBlackboxJobLimits::jobLimits() else QVERIFY2(m_qbsStderr.contains("exclusive"), m_qbsStderr.constData()); if (exitCode == 0) - QCOMPARE(m_qbsStdout.count("Running tool"), 7); + QCOMPARE(m_qbsStdout.count("Running tool"), 5); } QTEST_MAIN(TestBlackboxJobLimits) |