summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorIvan Komissarov <abbapoh@gmail.com>2020-01-12 14:09:29 +0100
committerIvan Komissarov <ABBAPOH@gmail.com>2020-08-07 11:11:28 +0000
commite3fe3e19cb1d06ae9a0a37bc6fdac25d57bdfe4a (patch)
tree0c168437e6bb17f56bffcb9cd0f21313b58ffefd /tests/auto
parentc6400e94e01c8170740c52c916d171072d2c1f2c (diff)
downloadqbs-e3fe3e19cb1d06ae9a0a37bc6fdac25d57bdfe4a.tar.gz
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')
-rw-r--r--tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs27
-rw-r--r--tests/auto/blackbox/tst_blackboxapple.cpp39
2 files changed, 57 insertions, 9 deletions
diff --git a/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs b/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs
index a65dcd023..0dc55fde9 100644
--- a/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs
+++ b/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs
@@ -9,10 +9,25 @@ Project {
Depends { name: "cpp" }
Depends { name: "bundle" }
+ property bool hasX86Mac: true // cannot use xcode.version in qbs.architectures
+ property bool hasArmMac: false
bundle.isBundle: false
// This will generate 2 multiplex configs and an aggregate.
- qbs.architectures: ["x86", "x86_64"]
+ qbs.architectures: {
+ if (qbs.targetPlatform === "macos") {
+ if (hasX86Mac)
+ return ["x86_64", "x86"];
+ else if (hasArmMac)
+ return ["arm64", "x86_64"];
+ } else if (qbs.targetPlatform === "ios") {
+ return ["arm64", "armv7a"];
+ }
+ console.info("Cannot build fat binaries for this target platform ("
+ + qbs.targetPlatform + ")");
+ return original;
+ }
+
qbs.buildVariant: "debug"
cpp.minimumMacosVersion: "10.8"
}
@@ -22,14 +37,20 @@ Project {
files: ["app.c"]
// This should link only against the aggregate static library, and not against
- // the {debug, x86_64} variant, or worse - against both the single arch variant
+ // the {debug, arm64} variant, or worse - against both the single arch variant
// and the lipo-ed one.
Depends { name: "multi_arch_lib" }
Depends { name: "bundle" }
bundle.isBundle: false
- qbs.architecture: "x86_64"
+ qbs.architecture: {
+ if (qbs.targetPlatform === "macos")
+ return "x86_64";
+ else if (qbs.targetPlatform === "ios")
+ return "arm64";
+ return original;
+ }
qbs.buildVariant: "debug"
cpp.minimumMacosVersion: "10.8"
multiplexByQbsProperties: []
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()