aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox/tst_blackboxbaremetal.cpp
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2020-08-06 17:31:17 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2020-08-07 15:50:11 +0000
commit95e1b0a2bb301b75315100e3cb252a25e6e0ce05 (patch)
treeb197ac58e2bb360d869c1228eda962cb4aa116f4 /tests/auto/blackbox/tst_blackboxbaremetal.cpp
parent3c6ae1f54008ffba6a1e1d47f929d706df744729 (diff)
baremetal: Add new 'generate-linker-map-file' test
This test checks the cpp.generateLinkerMapFile property, which enables or disables generation for the linker map file. Take into account, that currently not all toolchains completely supports or implements this feature, and this test skips such toolchains. Change-Id: I5ba90116ab0481bb65ff866cf02f8a1963cf00a9 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'tests/auto/blackbox/tst_blackboxbaremetal.cpp')
-rw-r--r--tests/auto/blackbox/tst_blackboxbaremetal.cpp49
1 files changed, 46 insertions, 3 deletions
diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
index 9dc8bbab3..50be987a2 100644
--- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp
+++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
@@ -34,8 +34,8 @@
#include <QtCore/qregularexpression.h>
-static bool extractUnsupportedToolset(const QByteArray &output,
- QByteArray &toolchain, QByteArray &architecture)
+static bool extractToolset(const QByteArray &output,
+ QByteArray &toolchain, QByteArray &architecture)
{
const QRegularExpression re("%%(\\w+)%%, %%(\\w+)%%");
QRegularExpressionMatchIterator it = re.globalMatch(output);
@@ -51,11 +51,22 @@ static QByteArray unsupportedToolsetMessage(const QByteArray &output)
{
QByteArray toolchain;
QByteArray architecture;
- extractUnsupportedToolset(output, toolchain, architecture);
+ extractToolset(output, toolchain, architecture);
return "Unsupported toolchain '" + toolchain
+ "' for architecture '" + architecture + "'";
}
+static QString linkerMapFileExtension(const QByteArray &toolchain, const QByteArray &architecture)
+{
+ if (toolchain == "keil") {
+ if (architecture == "mcs51" || architecture == "mcs251")
+ return QStringLiteral(".m51");
+ if (architecture == "c166")
+ return QStringLiteral(".m66");
+ }
+ return QStringLiteral(".map");
+}
+
TestBlackboxBareMetal::TestBlackboxBareMetal()
: TestBlackboxBase (SRCDIR "/testdata-baremetal", "blackbox-baremetal")
{
@@ -172,4 +183,36 @@ void TestBlackboxBareMetal::compilerListingFiles()
QCOMPARE(regularFileExists(fooListing), generateListing);
}
+void TestBlackboxBareMetal::linkerMapFile_data()
+{
+ QTest::addColumn<QString>("testPath");
+ QTest::addColumn<bool>("generateMap");
+ QTest::newRow("do-not-generate-linker-map") << "/do-not-generate-linker-map" << false;
+ QTest::newRow("generate-linker-map") << "/generate-linker-map" << true;
+}
+
+void TestBlackboxBareMetal::linkerMapFile()
+{
+ QFETCH(QString, testPath);
+ QFETCH(bool, generateMap);
+ QDir::setCurrent(testDataDir + testPath);
+ QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0);
+ if (m_qbsStdout.contains("unsupported toolset:"))
+ QSKIP(unsupportedToolsetMessage(m_qbsStdout));
+ if (!m_qbsStdout.contains("current toolset:"))
+ QFAIL("No current toolset pattern exists");
+
+ QByteArray toolchain;
+ QByteArray architecture;
+ if (!extractToolset(m_qbsStdout, toolchain, architecture))
+ QFAIL("Unable to extract current toolset");
+
+ QCOMPARE(runQbs(), 0);
+ const QString productName = testPath.mid(1);
+ const QString productBuildDir = relativeProductBuildDir(productName);
+ const auto extension = linkerMapFileExtension(toolchain, architecture);
+ const QString linkerMap = productBuildDir + "/" + productName + extension;
+ QCOMPARE(regularFileExists(linkerMap), generateMap);
+}
+
QTEST_MAIN(TestBlackboxBareMetal)