GenericLinuxDeviceTester: Don't use SshRemoteProcess for uname

Use QtcProcess with a path on device instead.

Change-Id: If38731f0648412874ebb1319ec53627f65f69108
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2022-05-03 09:35:20 +02:00
parent 9402841d99
commit 910dd04bf7
2 changed files with 14 additions and 15 deletions

View File

@@ -53,7 +53,7 @@ class GenericLinuxDeviceTesterPrivate
public: public:
IDevice::Ptr deviceConfiguration; IDevice::Ptr deviceConfiguration;
SshConnection *connection = nullptr; SshConnection *connection = nullptr;
SshRemoteProcessPtr process; QtcProcess unameProcess;
DeviceUsedPortsGatherer portsGatherer; DeviceUsedPortsGatherer portsGatherer;
SftpTransferPtr sftpTransfer; SftpTransferPtr sftpTransfer;
QtcProcess rsyncProcess; QtcProcess rsyncProcess;
@@ -68,6 +68,10 @@ using namespace Internal;
GenericLinuxDeviceTester::GenericLinuxDeviceTester(QObject *parent) GenericLinuxDeviceTester::GenericLinuxDeviceTester(QObject *parent)
: DeviceTester(parent), d(new GenericLinuxDeviceTesterPrivate) : DeviceTester(parent), d(new GenericLinuxDeviceTesterPrivate)
{ {
connect(&d->unameProcess, &QtcProcess::done, this,
&GenericLinuxDeviceTester::handleUnameFinished);
connect(&d->rsyncProcess, &QtcProcess::done, this,
&GenericLinuxDeviceTester::handleRsyncFinished);
SshRemoteProcess::setupSshEnvironment(&d->rsyncProcess); SshRemoteProcess::setupSshEnvironment(&d->rsyncProcess);
} }
@@ -107,14 +111,13 @@ void GenericLinuxDeviceTester::stopTest()
d->portsGatherer.stop(); d->portsGatherer.stop();
break; break;
case RunningUname: case RunningUname:
d->process->close(); d->unameProcess.close();
break; break;
case TestingSftp: case TestingSftp:
d->sftpTransfer->stop(); d->sftpTransfer->stop();
break; break;
case TestingRsync: case TestingRsync:
d->rsyncProcess.disconnect(); d->rsyncProcess.close();
d->rsyncProcess.kill();
case Inactive: case Inactive:
break; break;
} }
@@ -126,13 +129,11 @@ void GenericLinuxDeviceTester::handleConnected()
{ {
QTC_ASSERT(d->state == Connecting, return); QTC_ASSERT(d->state == Connecting, return);
d->process = d->connection->createRemoteProcess("uname -rsm"); d->unameProcess.setCommand({d->deviceConfiguration->mapToGlobalPath("uname"), {"-rsm"}});
connect(d->process.get(), &QtcProcess::done,
this, &GenericLinuxDeviceTester::handleProcessFinished);
emit progressMessage(tr("Checking kernel version...")); emit progressMessage(tr("Checking kernel version..."));
d->state = RunningUname; d->state = RunningUname;
d->process->start(); d->unameProcess.start();
} }
void GenericLinuxDeviceTester::handleConnectionFailure() void GenericLinuxDeviceTester::handleConnectionFailure()
@@ -144,18 +145,18 @@ void GenericLinuxDeviceTester::handleConnectionFailure()
setFinished(TestFailure); setFinished(TestFailure);
} }
void GenericLinuxDeviceTester::handleProcessFinished() void GenericLinuxDeviceTester::handleUnameFinished()
{ {
QTC_ASSERT(d->state == RunningUname, return); QTC_ASSERT(d->state == RunningUname, return);
if (!d->process->errorString().isEmpty() || d->process->exitCode() != 0) { if (!d->unameProcess.errorString().isEmpty() || d->unameProcess.exitCode() != 0) {
const QByteArray stderrOutput = d->process->readAllStandardError(); const QByteArray stderrOutput = d->unameProcess.readAllStandardError();
if (!stderrOutput.isEmpty()) if (!stderrOutput.isEmpty())
emit errorMessage(tr("uname failed: %1").arg(QString::fromUtf8(stderrOutput)) + QLatin1Char('\n')); emit errorMessage(tr("uname failed: %1").arg(QString::fromUtf8(stderrOutput)) + QLatin1Char('\n'));
else else
emit errorMessage(tr("uname failed.") + QLatin1Char('\n')); emit errorMessage(tr("uname failed.") + QLatin1Char('\n'));
} else { } else {
emit progressMessage(QString::fromUtf8(d->process->readAllStandardOutput())); emit progressMessage(QString::fromUtf8(d->unameProcess.readAllStandardOutput()));
} }
connect(&d->portsGatherer, &DeviceUsedPortsGatherer::error, connect(&d->portsGatherer, &DeviceUsedPortsGatherer::error,
@@ -222,8 +223,6 @@ void GenericLinuxDeviceTester::handleSftpFinished(const QString &error)
void GenericLinuxDeviceTester::testRsync() void GenericLinuxDeviceTester::testRsync()
{ {
emit progressMessage(tr("Checking whether rsync works...")); emit progressMessage(tr("Checking whether rsync works..."));
connect(&d->rsyncProcess, &QtcProcess::done, this,
&GenericLinuxDeviceTester::handleRsyncFinished);
const RsyncCommandLine cmdLine = RsyncDeployStep::rsyncCommand(*d->connection, const RsyncCommandLine cmdLine = RsyncDeployStep::rsyncCommand(*d->connection,
RsyncDeployStep::defaultFlags()); RsyncDeployStep::defaultFlags());
const QStringList args = QStringList(cmdLine.options) const QStringList args = QStringList(cmdLine.options)

View File

@@ -47,7 +47,7 @@ public:
private: private:
void handleConnected(); void handleConnected();
void handleConnectionFailure(); void handleConnectionFailure();
void handleProcessFinished(); void handleUnameFinished();
void handlePortsGatheringError(const QString &message); void handlePortsGatheringError(const QString &message);
void handlePortListReady(); void handlePortListReady();
void handleSftpStarted(); void handleSftpStarted();