diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2020-01-12 14:09:29 +0100 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2020-08-07 11:11:28 +0000 |
commit | e3fe3e19cb1d06ae9a0a37bc6fdac25d57bdfe4a (patch) | |
tree | 0c168437e6bb17f56bffcb9cd0f21313b58ffefd /tests/auto/blackbox/tst_blackboxapple.cpp | |
parent | c6400e94e01c8170740c52c916d171072d2c1f2c (diff) |
Make TestBlackboxApple::aggregateDependencyLinking smarter
Now it covers old macs, ios and new arm64 macs
Task-number: QBS-1456
Change-Id: Icc7d7ca040266a85947c29f3b5d8f191c07cfffe
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/auto/blackbox/tst_blackboxapple.cpp')
-rw-r--r-- | tests/auto/blackbox/tst_blackboxapple.cpp | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/tests/auto/blackbox/tst_blackboxapple.cpp b/tests/auto/blackbox/tst_blackboxapple.cpp index 786dba432..d76aaf897 100644 --- a/tests/auto/blackbox/tst_blackboxapple.cpp +++ b/tests/auto/blackbox/tst_blackboxapple.cpp @@ -33,6 +33,7 @@ #include <tools/profile.h> #include <tools/qttools.h> +#include <QtCore/qdiriterator.h> #include <QtCore/qjsondocument.h> #include <QtCore/qjsonobject.h> #include <QtXml/qdom.h> @@ -120,6 +121,25 @@ static bool testVariantListType(const QVariant &variant, QMetaType::Type type) return true; } +static QString findFatLibrary(const QString &dir, const QString &libraryName) +{ + QDirIterator it(dir, {}, QDir::AllEntries, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + if (it.fileInfo().fileName() == libraryName) { + QProcess lipo; + lipo.start("lipo", { QStringLiteral("-info"), it.filePath() }); + if (!lipo.waitForStarted() || !lipo.waitForFinished() || lipo.exitCode() != 0) + return {}; + auto output = lipo.readAllStandardOutput(); + if (output.contains(QByteArrayLiteral("Architectures in the fat file"))) + return QDir::cleanPath(it.filePath()); + } + } + + return {}; +} + TestBlackboxApple::TestBlackboxApple() : TestBlackboxBase (SRCDIR "/testdata-apple", "blackbox-apple") { @@ -250,19 +270,26 @@ void TestBlackboxApple::appleMultiConfig() void TestBlackboxApple::aggregateDependencyLinking() { - // XCode 11 produces warning about deprecation of 32-bit apps, so skip the test - // for future XCode versions as well const auto xcodeVersion = findXcodeVersion(); - if (xcodeVersion >= qbs::Version(11)) - QSKIP("32-bit arch build is no longer supported on macOS higher than 10.13.4."); + // XCode 11 produces warning about deprecation of 32-bit apps, but still works + const bool hasX86Mac = xcodeVersion < qbs::Version(12); + const bool hasArmMac = xcodeVersion >= qbs::Version(12); QDir::setCurrent(testDataDir + "/aggregateDependencyLinking"); - QCOMPARE(runQbs(QStringList{"-p", "multi_arch_lib"}), 0); + QbsRunParameters params{QStringList{"-p", "multi_arch_lib"}}; + params.arguments << QStringLiteral("products.multi_arch_lib.hasX86Mac:%1").arg(hasX86Mac); + params.arguments << QStringLiteral("products.multi_arch_lib.hasArmMac:%1").arg(hasArmMac); + QCOMPARE(runQbs(params), 0); + if (m_qbsStdout.contains("Cannot build fat binaries")) + QSKIP("Building fat binaries is not supported for this profile"); QCOMPARE(runQbs(QStringList{"-p", "just_app", "--command-echo-mode", "command-line"}), 0); int linkedInLibrariesCount = - QString::fromUtf8(m_qbsStdout).count(QStringLiteral("multi_arch_lib.a")); + QString::fromUtf8(m_qbsStdout).count(QStringLiteral("libmulti_arch_lib.a")); QCOMPARE(linkedInLibrariesCount, 1); + const auto fatLibPath = findFatLibrary(testDataDir, QStringLiteral("libmulti_arch_lib.a")); + QVERIFY(!fatLibPath.isEmpty()); + QVERIFY2(QString::fromUtf8(m_qbsStdout).contains(fatLibPath), m_qbsStdout); } void TestBlackboxApple::assetCatalog() |