aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-10-19 17:06:52 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-10-19 15:32:31 +0000
commit6dbdb2dc9ad626eacd350373060a0679feb7d9b9 (patch)
treeb2097b297fdae9409a7d9fb4ed8b7a692dda3ef9
parent0ccee2cfc5011553ed65c391f80d037f68861568 (diff)
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>
-rw-r--r--src/plugins/remotelinux/linuxdevicetester.cpp29
-rw-r--r--src/plugins/remotelinux/linuxdevicetester.h3
2 files changed, 30 insertions, 2 deletions
diff --git a/src/plugins/remotelinux/linuxdevicetester.cpp b/src/plugins/remotelinux/linuxdevicetester.cpp
index c27bafb6a7..dfce1ab267 100644
--- a/src/plugins/remotelinux/linuxdevicetester.cpp
+++ b/src/plugins/remotelinux/linuxdevicetester.cpp
@@ -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;
diff --git a/src/plugins/remotelinux/linuxdevicetester.h b/src/plugins/remotelinux/linuxdevicetester.h
index 1f7af9ab54..d845c2e26c 100644
--- a/src/plugins/remotelinux/linuxdevicetester.h
+++ b/src/plugins/remotelinux/linuxdevicetester.h
@@ -50,7 +50,8 @@ private:
void handleProcessFinished(int exitStatus);
void handlePortsGatheringError(const QString &message);
void handlePortListReady();
-
+ void handleSftpInitialized();
+ void handleSftpError(const QString &message);
void setFinished(ProjectExplorer::DeviceTester::TestResult result);
Internal::GenericLinuxDeviceTesterPrivate * const d;