summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs20
-rw-r--r--tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/fun.c4
-rw-r--r--tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/main.c6
-rw-r--r--tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/fun.c4
-rw-r--r--tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs20
-rw-r--r--tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/main.c6
-rw-r--r--tests/auto/blackbox/tst_blackboxbaremetal.cpp89
-rw-r--r--tests/auto/blackbox/tst_blackboxbaremetal.h3
8 files changed, 113 insertions, 39 deletions
diff --git a/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs
new file mode 100644
index 000000000..5ae0316c7
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs
@@ -0,0 +1,20 @@
+import "../BareMetalApplication.qbs" as BareMetalApplication
+
+BareMetalApplication {
+ condition: {
+ if (qbs.toolchainType === "iar")
+ return true;
+ if (qbs.toolchainType === "keil") {
+ if (qbs.architecture === "mcs51"
+ || qbs.architecture === "mcs251"
+ || qbs.architecture === "c166") {
+ return true;
+ }
+ }
+ console.info("unsupported toolset: %%"
+ + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%");
+ return false;
+ }
+ cpp.generateCompilerListingFiles: false
+ files: ["main.c", "fun.c"]
+}
diff --git a/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/fun.c b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/fun.c
new file mode 100644
index 000000000..3b8c8f2f4
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/fun.c
@@ -0,0 +1,4 @@
+int f(void)
+{
+ return 0;
+}
diff --git a/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/main.c b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/main.c
new file mode 100644
index 000000000..2c3d7726c
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/main.c
@@ -0,0 +1,6 @@
+extern int f(void);
+
+int main(void)
+{
+ return f();
+}
diff --git a/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/fun.c b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/fun.c
new file mode 100644
index 000000000..3b8c8f2f4
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/fun.c
@@ -0,0 +1,4 @@
+int f(void)
+{
+ return 0;
+}
diff --git a/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs
new file mode 100644
index 000000000..aebbfb664
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs
@@ -0,0 +1,20 @@
+import "../BareMetalApplication.qbs" as BareMetalApplication
+
+BareMetalApplication {
+ condition: {
+ if (qbs.toolchainType === "iar")
+ return true;
+ if (qbs.toolchainType === "keil") {
+ if (qbs.architecture === "mcs51"
+ || qbs.architecture === "mcs251"
+ || qbs.architecture === "c166") {
+ return true;
+ }
+ }
+ console.info("unsupported toolset: %%"
+ + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%");
+ return false;
+ }
+ cpp.generateCompilerListingFiles: true
+ files: ["main.c", "fun.c"]
+}
diff --git a/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/main.c b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/main.c
new file mode 100644
index 000000000..2c3d7726c
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/main.c
@@ -0,0 +1,6 @@
+extern int f(void);
+
+int main(void)
+{
+ return f();
+}
diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
index 1f79ad5c7..9dc8bbab3 100644
--- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp
+++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
@@ -47,6 +47,15 @@ static bool extractUnsupportedToolset(const QByteArray &output,
return true;
}
+static QByteArray unsupportedToolsetMessage(const QByteArray &output)
+{
+ QByteArray toolchain;
+ QByteArray architecture;
+ extractUnsupportedToolset(output, toolchain, architecture);
+ return "Unsupported toolchain '" + toolchain
+ + "' for architecture '" + architecture + "'";
+}
+
TestBlackboxBareMetal::TestBlackboxBareMetal()
: TestBlackboxBase (SRCDIR "/testdata-baremetal", "blackbox-baremetal")
{
@@ -56,18 +65,12 @@ void TestBlackboxBareMetal::targetPlatform()
{
QDir::setCurrent(testDataDir + "/target-platform");
QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0);
- if (!m_qbsStdout.contains("unsupported toolset:")) {
- const bool hasNoPlatform = m_qbsStdout.contains("has no platform: true");
- QCOMPARE(hasNoPlatform, true);
- const bool hasNoOS = m_qbsStdout.contains("has no os: true");
- QCOMPARE(hasNoOS, true);
- } else {
- QByteArray toolchain;
- QByteArray architecture;
- extractUnsupportedToolset(m_qbsStdout, toolchain, architecture);
- QSKIP("Unsupported toolchain '" + toolchain
- + "' for architecture '" + architecture + "'");
- }
+ if (m_qbsStdout.contains("unsupported toolset:"))
+ QSKIP(unsupportedToolsetMessage(m_qbsStdout));
+ const bool hasNoPlatform = m_qbsStdout.contains("has no platform: true");
+ QCOMPARE(hasNoPlatform, true);
+ const bool hasNoOS = m_qbsStdout.contains("has no os: true");
+ QCOMPARE(hasNoOS, true);
}
void TestBlackboxBareMetal::application_data()
@@ -83,15 +86,9 @@ void TestBlackboxBareMetal::application()
QFETCH(QString, testPath);
QDir::setCurrent(testDataDir + testPath);
QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0);
- if (!m_qbsStdout.contains("unsupported toolset:")) {
- QCOMPARE(runQbs(), 0);
- } else {
- QByteArray toolchain;
- QByteArray architecture;
- extractUnsupportedToolset(m_qbsStdout, toolchain, architecture);
- QSKIP("Unsupported toolchain '" + toolchain
- + "' for architecture '" + architecture + "'");
- }
+ if (m_qbsStdout.contains("unsupported toolset:"))
+ QSKIP(unsupportedToolsetMessage(m_qbsStdout));
+ QCOMPARE(runQbs(), 0);
}
void TestBlackboxBareMetal::staticLibraryDependencies()
@@ -111,15 +108,9 @@ void TestBlackboxBareMetal::externalStaticLibraries()
{
QDir::setCurrent(testDataDir + "/external-static-libraries");
QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0);
- if (!m_qbsStdout.contains("unsupported toolset:")) {
- QCOMPARE(runQbs(), 0);
- } else {
- QByteArray toolchain;
- QByteArray architecture;
- extractUnsupportedToolset(m_qbsStdout, toolchain, architecture);
- QSKIP("Unsupported toolchain '" + toolchain
- + "' for architecture '" + architecture + "'");
- }
+ if (m_qbsStdout.contains("unsupported toolset:"))
+ QSKIP(unsupportedToolsetMessage(m_qbsStdout));
+ QCOMPARE(runQbs(), 0);
}
void TestBlackboxBareMetal::userIncludePaths()
@@ -144,15 +135,9 @@ void TestBlackboxBareMetal::preincludeHeaders()
{
QDir::setCurrent(testDataDir + "/preinclude-headers");
QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0);
- if (!m_qbsStdout.contains("unsupported toolset:")) {
- QCOMPARE(runQbs(), 0);
- } else {
- QByteArray toolchain;
- QByteArray architecture;
- extractUnsupportedToolset(m_qbsStdout, toolchain, architecture);
- QSKIP("Unsupported toolchain '" + toolchain
- + "' for architecture '" + architecture + "'");
- }
+ if (m_qbsStdout.contains("unsupported toolset:"))
+ QSKIP(unsupportedToolsetMessage(m_qbsStdout));
+ QCOMPARE(runQbs(), 0);
}
void TestBlackboxBareMetal::defines()
@@ -161,4 +146,30 @@ void TestBlackboxBareMetal::defines()
QCOMPARE(runQbs(), 0);
}
+void TestBlackboxBareMetal::compilerListingFiles_data()
+{
+ QTest::addColumn<QString>("testPath");
+ QTest::addColumn<bool>("generateListing");
+ QTest::newRow("do-not-generate-compiler-listing") << "/do-not-generate-compiler-listing" << false;
+ QTest::newRow("generate-compiler-listing") << "/generate-compiler-listing" << true;
+}
+
+void TestBlackboxBareMetal::compilerListingFiles()
+{
+ QFETCH(QString, testPath);
+ QFETCH(bool, generateListing);
+ QDir::setCurrent(testDataDir + testPath);
+ QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0);
+ if (m_qbsStdout.contains("unsupported toolset:"))
+ QSKIP(unsupportedToolsetMessage(m_qbsStdout));
+ QCOMPARE(runQbs(), 0);
+ const QString productName = testPath.mid(1);
+ const QString productBuildDir = relativeProductBuildDir(productName);
+ const QString hash = inputDirHash(".");
+ const QString mainListing = productBuildDir + "/" + hash + "/main.c.lst";
+ QCOMPARE(regularFileExists(mainListing), generateListing);
+ const QString fooListing = productBuildDir + "/" + hash + "/fun.c.lst";
+ QCOMPARE(regularFileExists(fooListing), generateListing);
+}
+
QTEST_MAIN(TestBlackboxBareMetal)
diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.h b/tests/auto/blackbox/tst_blackboxbaremetal.h
index 75914dbd5..2838e9474 100644
--- a/tests/auto/blackbox/tst_blackboxbaremetal.h
+++ b/tests/auto/blackbox/tst_blackboxbaremetal.h
@@ -57,6 +57,9 @@ private slots:
void defines();
+ void compilerListingFiles_data();
+ void compilerListingFiles();
+
private:
};