summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2021-02-08 18:14:12 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2021-02-10 15:33:19 +0000
commit07b92e9ee58d0c971c9e0fb3e7c83f1f8f1d1079 (patch)
tree1ca75ea2420bb2f437740973c3a68c2c2e87533b /tests
parentf4623c70e298dc0bf8c73b02ff5150873229792d (diff)
downloadqbs-07b92e9ee58d0c971c9e0fb3e7c83f1f8f1d1079.tar.gz
baremetal: Add new 'compiler-defines-by-language' test
This test is an adaptation of a similar existing test. A main difference it that this test intended only for a `bare-metal` toolchains where there may be no support for a C ++ compiler. Change-Id: I4ea023743a4940c96dd9abc96ffda8cd06385b0b Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/app.c4
-rw-r--r--tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/compiler-defines-by-language.qbs69
-rw-r--r--tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/cpptest.cpp0
-rw-r--r--tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/ctest.c0
-rw-r--r--tests/auto/blackbox/tst_blackboxbaremetal.cpp7
-rw-r--r--tests/auto/blackbox/tst_blackboxbaremetal.h2
6 files changed, 82 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/app.c b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/app.c
new file mode 100644
index 000000000..58fe69254
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/app.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/compiler-defines-by-language.qbs b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/compiler-defines-by-language.qbs
new file mode 100644
index 000000000..5e8bbd62d
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/compiler-defines-by-language.qbs
@@ -0,0 +1,69 @@
+import "../BareMetalApplication.qbs" as BareMetalApplication
+
+Project {
+ property bool supportsCpp: {
+ if (qbs.toolchain.contains("sdcc"))
+ return false;
+ if (qbs.toolchain.contains("keil")) {
+ if (qbs.architecture === "mcs51"
+ || qbs.architecture === "mcs251"
+ || qbs.architecture === "c166") {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ BareMetalApplication {
+ name: "c_language"
+ files: ["app.c", "ctest.c"]
+ cpp.enableCompilerDefinesByLanguage: []
+ property var foo: {
+ if (!cpp.compilerDefinesByLanguage)
+ throw "ASSERT cpp.compilerDefinesByLanguage: "
+ + cpp.compilerDefinesByLanguage;
+ if (!cpp.compilerDefinesByLanguage["c"])
+ throw "ASSERT cpp.compilerDefinesByLanguage[\"c\"]: "
+ + cpp.compilerDefinesByLanguage["c"];
+ if (cpp.compilerDefinesByLanguage["cpp"])
+ throw "ASSERT !cpp.compilerDefinesByLanguage[\"cpp\"]: "
+ + cpp.compilerDefinesByLanguage["cpp"];
+ }
+ }
+
+ BareMetalApplication {
+ condition: supportsCpp
+ name: "cpp_language"
+ files: ["app.c", "cpptest.cpp"]
+ cpp.enableCompilerDefinesByLanguage: ["cpp"]
+ property var foo: {
+ if (!cpp.compilerDefinesByLanguage)
+ throw "ASSERT cpp.compilerDefinesByLanguage: "
+ + cpp.compilerDefinesByLanguage;
+ if (cpp.compilerDefinesByLanguage["c"])
+ throw "ASSERT !cpp.compilerDefinesByLanguage[\"c\"]: "
+ + cpp.compilerDefinesByLanguage["c"];
+ if (!cpp.compilerDefinesByLanguage["cpp"])
+ throw "ASSERT cpp.compilerDefinesByLanguage[\"cpp\"]: "
+ + cpp.compilerDefinesByLanguage["cpp"];
+ }
+ }
+
+ BareMetalApplication {
+ condition: supportsCpp
+ name: "c_and_cpp_language"
+ files: ["app.c", "ctest.c", "cpptest.cpp"]
+ cpp.enableCompilerDefinesByLanguage: ["c", "cpp"]
+ property var foo: {
+ if (!cpp.compilerDefinesByLanguage)
+ throw "ASSERT cpp.compilerDefinesByLanguage: "
+ + cpp.compilerDefinesByLanguage;
+ if (!cpp.compilerDefinesByLanguage["c"])
+ throw "ASSERT cpp.compilerDefinesByLanguage[\"c\"]: "
+ + cpp.compilerDefinesByLanguage["c"];
+ if (!cpp.compilerDefinesByLanguage["cpp"])
+ throw "ASSERT cpp.compilerDefinesByLanguage[\"cpp\"]: "
+ + cpp.compilerDefinesByLanguage["cpp"];
+ }
+ }
+}
diff --git a/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/cpptest.cpp b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/cpptest.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/cpptest.cpp
diff --git a/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/ctest.c b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/ctest.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/ctest.c
diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
index 6d7590209..d32abf82a 100644
--- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp
+++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp
@@ -244,4 +244,11 @@ void TestBlackboxBareMetal::linkerMapFile()
QCOMPARE(regularFileExists(linkerMap), generateMap);
}
+void TestBlackboxBareMetal::compilerDefinesByLanguage()
+{
+ QDir::setCurrent(testDataDir + "/compiler-defines-by-language");
+ QbsRunParameters params(QStringList{ "-f", "compiler-defines-by-language.qbs" });
+ QCOMPARE(runQbs(params), 0);
+}
+
QTEST_MAIN(TestBlackboxBareMetal)
diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.h b/tests/auto/blackbox/tst_blackboxbaremetal.h
index 581d1d580..39d2f36c9 100644
--- a/tests/auto/blackbox/tst_blackboxbaremetal.h
+++ b/tests/auto/blackbox/tst_blackboxbaremetal.h
@@ -64,6 +64,8 @@ private slots:
void linkerMapFile_data();
void linkerMapFile();
+ void compilerDefinesByLanguage();
+
private:
};