From a1b1759abfce0972a75072893148fc8ed7fa6bd2 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Mon, 18 Dec 2023 15:01:56 +0200 Subject: [PATCH] AndroidTestRunner: make build command program deduction more robust Currently, if the cmake program path passed to androidtestrunner contains space, QProcess will get an invalid program path. To fix that, quote the cmake command passed to androidtestrunner and use QProcess::splitCommand() to get the program and args list. Task-number: QTBUG-105524 Pick-to: 6.7 Change-Id: Icb665033884127972bff205157ff22aa469c135c Reviewed-by: Alexandru Croitor --- cmake/QtPlatformAndroid.cmake | 2 +- src/tools/androidtestrunner/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/QtPlatformAndroid.cmake b/cmake/QtPlatformAndroid.cmake index 91c968da370..f5869bd2288 100644 --- a/cmake/QtPlatformAndroid.cmake +++ b/cmake/QtPlatformAndroid.cmake @@ -201,7 +201,7 @@ function(qt_internal_android_test_arguments target timeout out_test_runner out_t "--path" "${apk_dir}" "--adb" "${ANDROID_SDK_ROOT}/platform-tools/adb" "--skip-install-root" - "--make" "${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${target}_make_apk" + "--make" "\"${CMAKE_COMMAND}\" --build ${CMAKE_BINARY_DIR} --target ${target}_make_apk" "--apk" "${apk_dir}/${target}.apk" "--ndk-stack" "${ANDROID_NDK_ROOT}/ndk-stack" "--timeout" "${timeout}" diff --git a/src/tools/androidtestrunner/main.cpp b/src/tools/androidtestrunner/main.cpp index 79bd95820a0..baad678ec02 100644 --- a/src/tools/androidtestrunner/main.cpp +++ b/src/tools/androidtestrunner/main.cpp @@ -191,7 +191,7 @@ static bool execAdbCommand(const QStringList &args, QByteArray *output = nullptr static bool execCommand(const QString &command, QByteArray *output = nullptr, bool verbose = true) { - auto args = command.split(u' '); + auto args = QProcess::splitCommand(command); const auto program = args.first(); args.removeOne(program); return execCommand(program, args, output, verbose);