aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2018-02-28 09:32:42 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2018-02-28 09:41:48 +0000
commit29994ea8ef88b898521eadbb5f7a5444ab46f6c0 (patch)
treec3af4aebc37de3d00cb23ea817cffc0fd4bee281 /tests
parent78696cb39bbc9e6460c7d77fb9949fe2516ae4dd (diff)
Guard QScriptEngine's creation/destruction with a mutex
When building multiple configurations in one go we create one QScriptEngine per configuration, each in its own thread, but nearly at the same time. It turns out that QScriptEngine's creation/destruction is not thread-safe, which leads to all kinds of interesting effects in the multiple configurations case. We fix this by guarding creation/destruction of QScriptEngine with a mutex. Task-number: QBS-1308 Change-Id: Ie01733d5943f1fb89e1d25344c4ffa998095e394 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/blackbox/testdata/multiple-configurations/file.cpp6
-rw-r--r--tests/auto/blackbox/testdata/multiple-configurations/file.h1
-rw-r--r--tests/auto/blackbox/testdata/multiple-configurations/lib.cpp1
-rw-r--r--tests/auto/blackbox/testdata/multiple-configurations/lib.h1
-rw-r--r--tests/auto/blackbox/testdata/multiple-configurations/main.cpp6
-rw-r--r--tests/auto/blackbox/testdata/multiple-configurations/multiple-configurations.qbs15
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp29
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
-rw-r--r--tests/auto/language/tst_language.cpp2
9 files changed, 61 insertions, 1 deletions
diff --git a/tests/auto/blackbox/testdata/multiple-configurations/file.cpp b/tests/auto/blackbox/testdata/multiple-configurations/file.cpp
new file mode 100644
index 000000000..44ebc2ee3
--- /dev/null
+++ b/tests/auto/blackbox/testdata/multiple-configurations/file.cpp
@@ -0,0 +1,6 @@
+#include <lib.h>
+
+void f()
+{
+ l();
+}
diff --git a/tests/auto/blackbox/testdata/multiple-configurations/file.h b/tests/auto/blackbox/testdata/multiple-configurations/file.h
new file mode 100644
index 000000000..789447c02
--- /dev/null
+++ b/tests/auto/blackbox/testdata/multiple-configurations/file.h
@@ -0,0 +1 @@
+void f();
diff --git a/tests/auto/blackbox/testdata/multiple-configurations/lib.cpp b/tests/auto/blackbox/testdata/multiple-configurations/lib.cpp
new file mode 100644
index 000000000..9a6145659
--- /dev/null
+++ b/tests/auto/blackbox/testdata/multiple-configurations/lib.cpp
@@ -0,0 +1 @@
+void l() {}
diff --git a/tests/auto/blackbox/testdata/multiple-configurations/lib.h b/tests/auto/blackbox/testdata/multiple-configurations/lib.h
new file mode 100644
index 000000000..f8be99ced
--- /dev/null
+++ b/tests/auto/blackbox/testdata/multiple-configurations/lib.h
@@ -0,0 +1 @@
+void l();
diff --git a/tests/auto/blackbox/testdata/multiple-configurations/main.cpp b/tests/auto/blackbox/testdata/multiple-configurations/main.cpp
new file mode 100644
index 000000000..4fa5b1f97
--- /dev/null
+++ b/tests/auto/blackbox/testdata/multiple-configurations/main.cpp
@@ -0,0 +1,6 @@
+#include <file.h>
+
+int main()
+{
+ f();
+}
diff --git a/tests/auto/blackbox/testdata/multiple-configurations/multiple-configurations.qbs b/tests/auto/blackbox/testdata/multiple-configurations/multiple-configurations.qbs
new file mode 100644
index 000000000..f8371e983
--- /dev/null
+++ b/tests/auto/blackbox/testdata/multiple-configurations/multiple-configurations.qbs
@@ -0,0 +1,15 @@
+import qbs
+
+Project {
+ StaticLibrary {
+ name: "lib"
+ Depends { name: "cpp" }
+ files: ["lib.cpp", "lib.h"]
+ }
+ CppApplication {
+ name: "app"
+ Depends { name: "lib" }
+ cpp.includePaths: project.sourceDirectory
+ files: ["file.cpp", "file.h", "main.cpp"]
+ }
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 8ef77c9b4..6ace7e674 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -3910,6 +3910,35 @@ void TestBlackbox::multipleChanges()
QVERIFY(m_qbsStdout.contains("prop: true"));
}
+void TestBlackbox::multipleConfigurations()
+{
+ QDir::setCurrent(testDataDir + "/multiple-configurations");
+ QbsRunParameters params(QStringList{"config:x", "config:y", "config:z"});
+ params.profile.clear();
+ struct DefaultProfileSwitcher
+ {
+ DefaultProfileSwitcher()
+ {
+ const SettingsPtr s = settings();
+ oldDefaultProfile = s->defaultProfile();
+ s->setValue("defaultProfile", profileName());
+ s->sync();
+ }
+ ~DefaultProfileSwitcher()
+ {
+ const SettingsPtr s = settings();
+ s->setValue("defaultProfile", oldDefaultProfile);
+ s->sync();
+ }
+ QVariant oldDefaultProfile;
+ };
+ DefaultProfileSwitcher dps;
+ QCOMPARE(runQbs(params), 0);
+ QCOMPARE(m_qbsStdout.count("compiling lib.cpp"), 3);
+ QCOMPARE(m_qbsStdout.count("compiling file.cpp"), 3);
+ QCOMPARE(m_qbsStdout.count("compiling main.cpp"), 3);
+}
+
void TestBlackbox::nestedGroups()
{
QDir::setCurrent(testDataDir + "/nested-groups");
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 9cf76ab5a..d0f8ab7b3 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -153,6 +153,7 @@ private slots:
void missingOverridePrefix();
void movedFileDependency();
void multipleChanges();
+ void multipleConfigurations();
void nestedGroups();
void nestedProperties();
void newOutputArtifact();
diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp
index 35f18732c..f1e21cc26 100644
--- a/tests/auto/language/tst_language.cpp
+++ b/tests/auto/language/tst_language.cpp
@@ -174,7 +174,7 @@ void TestLanguage::init()
void TestLanguage::initTestCase()
{
m_logger = Logger(m_logSink);
- m_engine = new ScriptEngine(m_logger, EvalContext::PropertyEvaluation, this);
+ m_engine = ScriptEngine::create(m_logger, EvalContext::PropertyEvaluation, this);
loader = new Loader(m_engine, m_logger);
loader->setSearchPaths(QStringList()
<< QLatin1String(SRCDIR "/../../../share/qbs"));