From e094e738b0cdf7204e8b6363025cae1f62a52db0 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 31 Mar 2023 12:28:54 +0200 Subject: [PATCH] RemoteLinux: Have an extra simple echo test First test without additional complications through quoting. Makes debugging easier. Change-Id: I3ea1a0725474fed09204fda1219cbc535bd2ef7c Reviewed-by: Christian Stenger Reviewed-by: --- src/plugins/remotelinux/linuxdevicetester.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/plugins/remotelinux/linuxdevicetester.cpp b/src/plugins/remotelinux/linuxdevicetester.cpp index 85bafe44eaf..af13c599e7f 100644 --- a/src/plugins/remotelinux/linuxdevicetester.cpp +++ b/src/plugins/remotelinux/linuxdevicetester.cpp @@ -34,7 +34,7 @@ public: QStringList commandsToTest() const; - TaskItem echoTask() const; + TaskItem echoTask(const QString &contents) const; TaskItem unameTask() const; TaskItem gathererTask() const; TaskItem transferTask(FileTransferMethod method, @@ -50,8 +50,6 @@ public: QList m_extraTests; }; -static const char s_echoContents[] = "Hello Remote World!"; - QStringList GenericLinuxDeviceTesterPrivate::commandsToTest() const { static const QStringList s_commandsToTest = {"base64", @@ -92,15 +90,15 @@ QStringList GenericLinuxDeviceTesterPrivate::commandsToTest() const return commands; } -TaskItem GenericLinuxDeviceTesterPrivate::echoTask() const +TaskItem GenericLinuxDeviceTesterPrivate::echoTask(const QString &contents) const { - const auto setup = [this](QtcProcess &process) { + const auto setup = [this, contents](QtcProcess &process) { emit q->progressMessage(Tr::tr("Sending echo to device...")); - process.setCommand({m_device->filePath("echo"), {s_echoContents}}); + process.setCommand({m_device->filePath("echo"), {contents}}); }; - const auto done = [this](const QtcProcess &process) { + const auto done = [this, contents](const QtcProcess &process) { const QString reply = Utils::chopIfEndsWith(process.cleanedStdOut(), '\n'); - if (reply != s_echoContents) + if (reply != contents) emit q->errorMessage(Tr::tr("Device replied to echo with unexpected contents: \"%1\"") .arg(reply) + '\n'); else @@ -284,7 +282,8 @@ void GenericLinuxDeviceTester::testDevice(const IDevice::Ptr &deviceConfiguratio }; QList taskItems = { - d->echoTask(), + d->echoTask("Hello"), // No quoting necessary + d->echoTask("Hello Remote World!"), // Checks quoting, too. d->unameTask(), d->gathererTask(), d->transferTasks()