summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-12-06 16:57:52 +0100
committerOliver Wolff <oliver.wolff@qt.io>2018-12-07 09:03:17 +0000
commita165d75dcbb7ce410e414b4b31d746ab3774dc11 (patch)
tree7c2defda61398f85f3daa71d4cae13ab5fe09a71
parentb402c1cff5deefd382bbcc56900c66c7ed0124ed (diff)
downloadqttools-a165d75dcbb7ce410e414b4b31d746ab3774dc11.tar.gz
winrtrunner: Pass logging rules set in the environment to the app
If an auto test fails Coin tries to rerun the same test with logging enabled to get additional information. Instead of just enabling extended logging for winrtrunner we have to pass these rules to the application that is run by winrtrunner to be able to obtain the information. As we cannot set the application's environment from winrtrunner we write qtlogging.ini where the application expects it to be so that logging is enabled on startup. Change-Id: I238a083f6d499f5b6b5eadb43545a5857050a2e8 Reviewed-by: Andre de la Rocha <andre.rocha@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r--src/winrtrunner/appxlocalengine.cpp25
-rw-r--r--src/winrtrunner/appxlocalengine.h1
-rw-r--r--src/winrtrunner/appxphoneengine.cpp6
-rw-r--r--src/winrtrunner/appxphoneengine.h1
-rw-r--r--src/winrtrunner/main.cpp7
-rw-r--r--src/winrtrunner/runner.cpp8
-rw-r--r--src/winrtrunner/runner.h1
-rw-r--r--src/winrtrunner/runnerengine.h1
8 files changed, 50 insertions, 0 deletions
diff --git a/src/winrtrunner/appxlocalengine.cpp b/src/winrtrunner/appxlocalengine.cpp
index e255f0a98..69bc39919 100644
--- a/src/winrtrunner/appxlocalengine.cpp
+++ b/src/winrtrunner/appxlocalengine.cpp
@@ -690,6 +690,31 @@ bool AppxLocalEngine::setLoopbackExemptServerEnabled(bool enabled)
return true;
}
+bool AppxLocalEngine::setLoggingRules(const QByteArray &rules)
+{
+ qCDebug(lcWinRtRunner) << __FUNCTION__;
+
+ QDir loggingIniDir(devicePath(QLatin1String("QtProject")));
+ if (!loggingIniDir.exists() && !loggingIniDir.mkpath(QStringLiteral("."))) {
+ qCWarning(lcWinRtRunner) << "Could not create" << loggingIniDir;
+ return false;
+ }
+ QFile loggingIniFile(loggingIniDir.absolutePath().append(QLatin1String("/qtlogging.ini")));
+ if (loggingIniFile.exists() && !loggingIniFile.remove()) {
+ qCWarning(lcWinRtRunner) << loggingIniFile << "already exists.";
+ return false;
+ }
+ if (!loggingIniFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ qCWarning(lcWinRtRunner) << "Could not open" << loggingIniFile << "for writing.";
+ return false;
+ }
+
+ QTextStream stream(&loggingIniFile);
+ stream << "[Rules]\n" << rules;
+
+ return true;
+}
+
bool AppxLocalEngine::suspend()
{
diff --git a/src/winrtrunner/appxlocalengine.h b/src/winrtrunner/appxlocalengine.h
index 291149bd3..0049b6ba4 100644
--- a/src/winrtrunner/appxlocalengine.h
+++ b/src/winrtrunner/appxlocalengine.h
@@ -64,6 +64,7 @@ public:
bool disableDebugging() override;
bool setLoopbackExemptClientEnabled(bool enabled) override;
bool setLoopbackExemptServerEnabled(bool enabled) override;
+ bool setLoggingRules(const QByteArray &rules) override;
bool suspend() override;
bool waitForFinished(int secs) override;
bool stop() override;
diff --git a/src/winrtrunner/appxphoneengine.cpp b/src/winrtrunner/appxphoneengine.cpp
index e45d007e4..39c3b2712 100644
--- a/src/winrtrunner/appxphoneengine.cpp
+++ b/src/winrtrunner/appxphoneengine.cpp
@@ -471,6 +471,12 @@ bool AppxPhoneEngine::setLoopbackExemptServerEnabled(bool)
return false;
}
+bool AppxPhoneEngine::setLoggingRules(const QByteArray &)
+{
+ qCDebug(lcWinRtRunner) << __FUNCTION__;
+ return false;
+}
+
bool AppxPhoneEngine::suspend()
{
qCDebug(lcWinRtRunner) << __FUNCTION__;
diff --git a/src/winrtrunner/appxphoneengine.h b/src/winrtrunner/appxphoneengine.h
index 641bf4653..b462e797f 100644
--- a/src/winrtrunner/appxphoneengine.h
+++ b/src/winrtrunner/appxphoneengine.h
@@ -64,6 +64,7 @@ public:
bool disableDebugging() override;
bool setLoopbackExemptClientEnabled(bool enabled) override;
bool setLoopbackExemptServerEnabled(bool enabled) override;
+ bool setLoggingRules(const QByteArray &rules) override;
bool suspend() override;
bool waitForFinished(int secs) override;
bool stop() override;
diff --git a/src/winrtrunner/main.cpp b/src/winrtrunner/main.cpp
index aa5ac8f06..72dd763c8 100644
--- a/src/winrtrunner/main.cpp
+++ b/src/winrtrunner/main.cpp
@@ -282,6 +282,13 @@ int main(int argc, char *argv[])
return ignoreErrors ? 0 : 3;
}
+ // If logging rules are set via env variable, we pass these to the application we are running
+ const QByteArray loggingRules = qgetenv("QT_LOGGING_RULES");
+ if (!loggingRules.isNull() && !runner.setLoggingRules(loggingRules)) {
+ qCDebug(lcWinRtRunner) << "Could not set logging rules, exiting with code 3.";
+ return ignoreErrors ? 0 : 3;
+ }
+
if (parser.isSet(debugOption)) {
const QString &debuggerExecutable = parser.value(debugOption);
const QString &debuggerArguments = parser.value(debuggerArgumentsOption);
diff --git a/src/winrtrunner/runner.cpp b/src/winrtrunner/runner.cpp
index 9794fd605..e816d9baa 100644
--- a/src/winrtrunner/runner.cpp
+++ b/src/winrtrunner/runner.cpp
@@ -233,6 +233,14 @@ bool Runner::setLoopbackExemptServerEnabled(bool enabled)
return d->engine->setLoopbackExemptServerEnabled(enabled);
}
+bool Runner::setLoggingRules(const QByteArray &rules)
+{
+ Q_D(Runner);
+ Q_ASSERT(d->engine);
+
+ return d->engine->setLoggingRules(rules);
+}
+
bool Runner::suspend()
{
Q_D(Runner);
diff --git a/src/winrtrunner/runner.h b/src/winrtrunner/runner.h
index 743156154..00b251be8 100644
--- a/src/winrtrunner/runner.h
+++ b/src/winrtrunner/runner.h
@@ -70,6 +70,7 @@ public:
bool disableDebugging();
bool setLoopbackExemptClientEnabled(bool enabled);
bool setLoopbackExemptServerEnabled(bool enabled);
+ bool setLoggingRules(const QByteArray &rules);
bool suspend();
bool stop();
bool wait(int maxWaitTime = 0);
diff --git a/src/winrtrunner/runnerengine.h b/src/winrtrunner/runnerengine.h
index 4cdd8f36f..44565c46c 100644
--- a/src/winrtrunner/runnerengine.h
+++ b/src/winrtrunner/runnerengine.h
@@ -55,6 +55,7 @@ public:
virtual bool disableDebugging() = 0;
virtual bool setLoopbackExemptClientEnabled(bool enabled) = 0;
virtual bool setLoopbackExemptServerEnabled(bool enabled) = 0;
+ virtual bool setLoggingRules(const QByteArray &rules) = 0;
virtual bool suspend() = 0;
virtual bool waitForFinished(int secs) = 0;
virtual bool stop() = 0;