diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2019-06-19 11:15:41 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2019-06-19 13:00:19 +0200 |
commit | cefaa2ff4c1d206c6daaba995d5c3572d089ac00 (patch) | |
tree | 40f9671f73cc42fa00fe12c7fa33d3e84bb76405 /src/tools | |
parent | e428cdc32cac0791c2b1eec254794a87e4da7c71 (diff) | |
download | qtbase-cefaa2ff4c1d206c6daaba995d5c3572d089ac00.tar.gz |
Fix androidtestrunner for windows
First, we cannot quote the whole command in double quotes, since the
command itself very often have double quotes inside it.
Secondly, we should use the same that the ssh(1) command does:
Instead of adb shell setprop foo 'a b' we should use
adb shell setprop foo "'a b'" as explained here:
[https://developer.android.com/studio/command-line/adb#shellcommands]
Last hunk in isRunning():
The pipe character got eaten by the shell if we used a single quote (so
the stuff after the pipe (grep) was actually run locally).
Switching to ssh-style quoting fixed that.
Change-Id: I3075cdf8595ac2549cec8019f2cba79f77815e0b
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/androidtestrunner/main.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/tools/androidtestrunner/main.cpp b/src/tools/androidtestrunner/main.cpp index 043c827403..bb69b7b914 100644 --- a/src/tools/androidtestrunner/main.cpp +++ b/src/tools/androidtestrunner/main.cpp @@ -108,18 +108,12 @@ static Options g_options; static bool execCommand(const QString &command, QByteArray *output = nullptr, bool verbose = false) { -#if defined(Q_OS_WIN32) - QString processedCommand = QLatin1Char('\"') + command + QLatin1Char('\"'); -#else - const QString& processedCommand = command; -#endif - if (verbose) - fprintf(stdout, "Execute %s\n", processedCommand.toUtf8().constData()); - FILE *process = popen(processedCommand.toUtf8().constData(), QT_POPEN_READ); + fprintf(stdout, "Execute %s\n", command.toUtf8().constData()); + FILE *process = popen(command.toUtf8().constData(), QT_POPEN_READ); if (!process) { - fprintf(stderr, "Cannot execute command %s", qPrintable(processedCommand)); + fprintf(stderr, "Cannot execute command %s", qPrintable(command)); return false; } char buffer[512]; @@ -368,7 +362,7 @@ static bool parseTestArgs() 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.testArgs = QStringLiteral("shell am start -e applicationArguments \"'%1'\" -n %2/%3").arg(shellQuote(g_options.testArgs.trimmed()), g_options.package, g_options.activity); return true; @@ -376,8 +370,8 @@ static bool parseTestArgs() static bool isRunning() { QByteArray output; - if (!execCommand(QStringLiteral("%1 shell 'ps | grep \" %2\"'").arg(g_options.adbCommand, - shellQuoteUnix(g_options.package)), &output)) { + if (!execCommand(QStringLiteral("%1 shell \"ps | grep ' %2'\"").arg(g_options.adbCommand, + shellQuote(g_options.package)), &output)) { return false; } |