summaryrefslogtreecommitdiff
path: root/src/tools/androidtestrunner
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2022-08-10 00:02:59 +0300
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2022-08-11 13:21:44 +0000
commitedc024e826d41a98cb7779e9834e83d7ea5da171 (patch)
treee9754903df078ce182f8d41b25365241d30dff20 /src/tools/androidtestrunner
parent55af91f822027f079e435eb13d9bf379496fe1bb (diff)
downloadqtbase-edc024e826d41a98cb7779e9834e83d7ea5da171.tar.gz
Android: handle quoted args passed to an app
Currently, arguments passed to the app through applicationArguments extra bundle treat every space as an argument separator. This then doesn't handle the case where an argument is a space separated quoted multi-word. This is more apparent when androidtestrunner is passing test arguments to the app where an argument can be a test case with a data tag that contains a space, which then is treated as two separate tag names. This change makes sure that androidtestrunner quotes each argument, and the app doesn't split the arguments list by spaces, but rather passed the argument string directly to c++ where QProcess::splitCommand() is used to get the correct set of arguments that will be passed to main(). Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104730 Change-Id: I45d8ca979d90f2a383c84623f0eb2eec29bba727 Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/tools/androidtestrunner')
-rw-r--r--src/tools/androidtestrunner/main.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/tools/androidtestrunner/main.cpp b/src/tools/androidtestrunner/main.cpp
index 489560a3e0..a5e249affc 100644
--- a/src/tools/androidtestrunner/main.cpp
+++ b/src/tools/androidtestrunner/main.cpp
@@ -313,7 +313,7 @@ static bool parseTestArgs()
QString file;
QString logType;
- QString unhandledArgs;
+ QStringList unhandledArgs;
for (int i = 0; i < g_options.testArgsList.size(); ++i) {
const QString &arg = g_options.testArgsList[i].trimmed();
if (arg == QStringLiteral("--"))
@@ -335,7 +335,7 @@ static bool parseTestArgs()
if (match.hasMatch()) {
logType = match.capturedTexts().at(1);
} else {
- unhandledArgs += QStringLiteral(" %1").arg(arg);
+ unhandledArgs << QStringLiteral(" \\\"%1\\\"").arg(arg);
}
}
}
@@ -345,10 +345,13 @@ static bool parseTestArgs()
for (const auto &format : g_options.outFiles.keys())
g_options.testArgs += QStringLiteral(" -o output.%1,%1").arg(format);
- g_options.testArgs += unhandledArgs;
- g_options.testArgs = QStringLiteral("shell am start -e applicationArguments \\\"%1\\\" -n %2/%3").arg(shellQuote(g_options.testArgs.trimmed()),
- g_options.package,
- g_options.activity);
+ g_options.testArgs += unhandledArgs.join(u' ');
+
+ g_options.testArgs = QStringLiteral("shell am start -e applicationArguments \"%1\" -n %2/%3")
+ .arg(shellQuote(g_options.testArgs.trimmed()))
+ .arg(g_options.package)
+ .arg(g_options.activity);
+
return true;
}