forked from qt-creator/qt-creator
RemoteLinux: Check SFTP functionality in device test
Uploading files is a typical activity when working with remote devices, so we should give early feedback if that won't be possible. Change-Id: I1dc578306b0179f6453bd7163a560880c99b0e13 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <projectexplorer/devicesupport/deviceusedportsgatherer.h>
|
||||
#include <utils/port.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <ssh/sftpchannel.h>
|
||||
#include <ssh/sshremoteprocess.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
|
||||
@@ -38,7 +39,7 @@ namespace RemoteLinux {
|
||||
namespace Internal {
|
||||
namespace {
|
||||
|
||||
enum State { Inactive, Connecting, RunningUname, TestingPorts };
|
||||
enum State { Inactive, Connecting, RunningUname, TestingPorts, TestingSftp };
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
@@ -49,6 +50,7 @@ public:
|
||||
SshConnection *connection = nullptr;
|
||||
SshRemoteProcess::Ptr process;
|
||||
DeviceUsedPortsGatherer portsGatherer;
|
||||
SftpChannel::Ptr sftpChannel;
|
||||
State state = Inactive;
|
||||
};
|
||||
|
||||
@@ -96,6 +98,9 @@ void GenericLinuxDeviceTester::stopTest()
|
||||
case RunningUname:
|
||||
d->process->close();
|
||||
break;
|
||||
case TestingSftp:
|
||||
d->sftpChannel->closeChannel();
|
||||
break;
|
||||
case Inactive:
|
||||
break;
|
||||
}
|
||||
@@ -170,9 +175,31 @@ void GenericLinuxDeviceTester::handlePortListReady()
|
||||
emit errorMessage(tr("The following specified ports are currently in use: %1")
|
||||
.arg(portList) + QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
emit progressMessage(tr("Checking if an SFTP channel can be set up..."));
|
||||
d->sftpChannel = d->connection->createSftpChannel();
|
||||
connect(d->sftpChannel.data(), &SftpChannel::initialized,
|
||||
this, &GenericLinuxDeviceTester::handleSftpInitialized);
|
||||
connect(d->sftpChannel.data(), &SftpChannel::channelError,
|
||||
this, &GenericLinuxDeviceTester::handleSftpError);
|
||||
d->state = TestingSftp;
|
||||
d->sftpChannel->initialize();
|
||||
}
|
||||
|
||||
void GenericLinuxDeviceTester::handleSftpInitialized()
|
||||
{
|
||||
QTC_ASSERT(d->state == TestingSftp, return);
|
||||
emit progressMessage(tr("SFTP channel successfully initialized.\n"));
|
||||
setFinished(TestSuccess);
|
||||
}
|
||||
|
||||
void GenericLinuxDeviceTester::handleSftpError(const QString &message)
|
||||
{
|
||||
QTC_ASSERT(d->state == TestingSftp, return);
|
||||
emit errorMessage(tr("Error setting up SFTP channel: %1\n").arg(message));
|
||||
setFinished(TestFailure);
|
||||
}
|
||||
|
||||
void GenericLinuxDeviceTester::setFinished(TestResult result)
|
||||
{
|
||||
d->state = Inactive;
|
||||
|
||||
Reference in New Issue
Block a user