diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2022-02-12 12:47:12 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2022-02-15 15:30:04 +0000 |
commit | 363e32d41c297355c9766c34ac6b61bfbc668b6a (patch) | |
tree | 38f9884c2264cff0d07b27a3aa9f0e8f6c0a8ff2 | |
parent | b32d967c0d88098505479a8cf384338b63a3aea5 (diff) |
baremetal: Add launch of test application target if possible
The idea is to check that the compiled application works correctly
by running it and reading its output. This will only work if the host
platform and target platform are the same, otherwise the launch is
simply skipped.
Since we use baremetal tests also to test other platforms (for example,
using the OpenWatcom or DigitalMars toolchains), the base application
`BareMetalApplication.qbs` is created as a console application.
The reason is that for baremetal it is always a console, but for
non-baremetal it can also be a GUI which requires a different main
function.
Change-Id: I520ba411582223950521b4b06c2e01bce49fe089
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
4 files changed, 29 insertions, 1 deletions
diff --git a/tests/auto/blackbox/testdata-baremetal/BareMetalApplication.qbs b/tests/auto/blackbox/testdata-baremetal/BareMetalApplication.qbs index f23cf1a39..a11855727 100644 --- a/tests/auto/blackbox/testdata-baremetal/BareMetalApplication.qbs +++ b/tests/auto/blackbox/testdata-baremetal/BareMetalApplication.qbs @@ -1,5 +1,25 @@ +import qbs.Host + BareMetalProduct { type: "application" + consoleApplication: true + + property bool dummy: { + if (qbs.targetPlatform !== Host.platform() + || qbs.architecture !== Host.architecture()) { + + function supportsCrossRun() { + // We can run 32 bit applications on 64 bit Windows. + if (Host.platform() === "windows" && Host.architecture() === "x86_64" + && qbs.targetPlatform === "windows" && qbs.architecture === "x86") { + return true; + } + } + + if (!supportsCrossRun()) + console.info("targetPlatform differs from hostPlatform") + } + } Group { condition: qbs.toolchain.contains("cosmic") diff --git a/tests/auto/blackbox/testdata-baremetal/one-object-application/main.c b/tests/auto/blackbox/testdata-baremetal/one-object-application/main.c index 58fe69254..d5ac449bf 100644 --- a/tests/auto/blackbox/testdata-baremetal/one-object-application/main.c +++ b/tests/auto/blackbox/testdata-baremetal/one-object-application/main.c @@ -1,4 +1,6 @@ +#include <stdio.h> int main(void) { + printf("Hello from app\n"); return 0; } diff --git a/tests/auto/blackbox/testdata-baremetal/two-object-application/fun.c b/tests/auto/blackbox/testdata-baremetal/two-object-application/fun.c index 3b8c8f2f4..e5850346a 100644 --- a/tests/auto/blackbox/testdata-baremetal/two-object-application/fun.c +++ b/tests/auto/blackbox/testdata-baremetal/two-object-application/fun.c @@ -1,4 +1,6 @@ +#include <stdio.h> int f(void) { + printf("Hello from app\n"); return 0; } diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp index e0a068bc6..fda544b8b 100644 --- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp +++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp @@ -110,7 +110,11 @@ void TestBlackboxBareMetal::application() QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); if (m_qbsStdout.contains("unsupported toolset:")) QSKIP(unsupportedToolsetMessage(m_qbsStdout)); - QCOMPARE(runQbs(), 0); + QCOMPARE(runQbs(QbsRunParameters("build")), 0); + if (m_qbsStdout.contains("targetPlatform differs from hostPlatform")) + QSKIP("Cannot run binaries in cross-compiled build"); + QCOMPARE(runQbs(QbsRunParameters("run")), 0); + QVERIFY2(m_qbsStdout.contains("Hello from app"), m_qbsStdout.constData()); } void TestBlackboxBareMetal::staticLibraryDependencies() |