forked from qt-creator/qt-creator
SSH: Fix tests to adapt to new location (utils vs. core plugin).
This commit is contained in:
@@ -31,9 +31,9 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include <coreplugin/ssh/sftpchannel.h>
|
||||
#include <coreplugin/ssh/sshconnection.h>
|
||||
#include <coreplugin/ssh/sshremoteprocess.h>
|
||||
#include <utils/ssh/sftpchannel.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
#include <utils/ssh/sshremoteprocess.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QList>
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
class Test : public QObject {
|
||||
Q_OBJECT
|
||||
@@ -69,24 +69,24 @@ public:
|
||||
noUser.host = QLatin1String("localhost");
|
||||
noUser.port = 22;
|
||||
noUser.timeout = 30;
|
||||
noUser.authType = SshConnectionParameters::AuthByPwd;
|
||||
noUser.uname = QLatin1String("dumdidumpuffpuff");
|
||||
noUser.uname = QLatin1String("whatever");
|
||||
noUser.authenticationType = SshConnectionParameters::AuthenticationByPassword;
|
||||
noUser.userName = QLatin1String("dumdidumpuffpuff");
|
||||
noUser.password = QLatin1String("whatever");
|
||||
|
||||
SshConnectionParameters wrongPwd=SshConnectionParameters(SshConnectionParameters::DefaultProxy);
|
||||
wrongPwd.host = QLatin1String("localhost");
|
||||
wrongPwd.port = 22;
|
||||
wrongPwd.timeout = 30;
|
||||
wrongPwd.authType = SshConnectionParameters::AuthByPwd;
|
||||
wrongPwd.uname = QLatin1String("root");
|
||||
noUser.uname = QLatin1String("thiscantpossiblybeapasswordcanit");
|
||||
wrongPwd.authenticationType = SshConnectionParameters::AuthenticationByPassword;
|
||||
wrongPwd.userName = QLatin1String("root");
|
||||
noUser.password = QLatin1String("thiscantpossiblybeapasswordcanit");
|
||||
|
||||
SshConnectionParameters invalidKeyFile=SshConnectionParameters(SshConnectionParameters::DefaultProxy);
|
||||
invalidKeyFile.host = QLatin1String("localhost");
|
||||
invalidKeyFile.port = 22;
|
||||
invalidKeyFile.timeout = 30;
|
||||
invalidKeyFile.authType = SshConnectionParameters::AuthByKey;
|
||||
invalidKeyFile.uname = QLatin1String("root");
|
||||
invalidKeyFile.authenticationType = SshConnectionParameters::AuthenticationByKey;
|
||||
invalidKeyFile.userName = QLatin1String("root");
|
||||
invalidKeyFile.privateKeyFile
|
||||
= QLatin1String("somefilenamethatwedontexpecttocontainavalidkey");
|
||||
|
||||
@@ -129,7 +129,7 @@ private slots:
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
void handleError(Core::SshError error)
|
||||
void handleError(Utils::SshError error)
|
||||
{
|
||||
if (m_testSet.isEmpty()) {
|
||||
qDebug("Error: Received error %d, but no test was running.", error);
|
||||
@@ -173,8 +173,8 @@ private:
|
||||
SLOT(handleDisconnected()));
|
||||
connect(m_connection.data(), SIGNAL(dataAvailable(QString)), this,
|
||||
SLOT(handleDataAvailable(QString)));
|
||||
connect(m_connection.data(), SIGNAL(error(Core::SshError)), this,
|
||||
SLOT(handleError(Core::SshError)));
|
||||
connect(m_connection.data(), SIGNAL(error(Utils::SshError)), this,
|
||||
SLOT(handleError(Utils::SshError)));
|
||||
const TestItem &nextItem = m_testSet.first();
|
||||
m_timeoutTimer.stop();
|
||||
m_timeoutTimer.setInterval(qMax(10000, nextItem.params.timeout * 1000));
|
||||
|
@@ -36,16 +36,16 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
ArgumentsCollector::ArgumentsCollector(const QStringList &args)
|
||||
: m_arguments(args)
|
||||
{
|
||||
}
|
||||
|
||||
Core::SshConnectionParameters ArgumentsCollector::collect(bool &success) const
|
||||
Utils::SshConnectionParameters ArgumentsCollector::collect(bool &success) const
|
||||
{
|
||||
SshConnectionParameters parameters(Core::SshConnectionParameters::NoProxy);
|
||||
SshConnectionParameters parameters(Utils::SshConnectionParameters::NoProxy);
|
||||
try {
|
||||
bool authTypeGiven = false;
|
||||
bool portGiven = false;
|
||||
@@ -55,24 +55,24 @@ Core::SshConnectionParameters ArgumentsCollector::collect(bool &success) const
|
||||
int port;
|
||||
for (pos = 1; pos < m_arguments.count() - 1; ++pos) {
|
||||
if (checkAndSetStringArg(pos, parameters.host, "-h")
|
||||
|| checkAndSetStringArg(pos, parameters.uname, "-u"))
|
||||
|| checkAndSetStringArg(pos, parameters.userName, "-u"))
|
||||
continue;
|
||||
if (checkAndSetIntArg(pos, port, portGiven, "-p")
|
||||
|| checkAndSetIntArg(pos, parameters.timeout, timeoutGiven, "-t"))
|
||||
continue;
|
||||
if (checkAndSetStringArg(pos, parameters.pwd, "-pwd")) {
|
||||
if (checkAndSetStringArg(pos, parameters.password, "-pwd")) {
|
||||
if (!parameters.privateKeyFile.isEmpty())
|
||||
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
||||
parameters.authType
|
||||
= SshConnectionParameters::AuthByPwd;
|
||||
parameters.authenticationType
|
||||
= SshConnectionParameters::AuthenticationByPassword;
|
||||
authTypeGiven = true;
|
||||
continue;
|
||||
}
|
||||
if (checkAndSetStringArg(pos, parameters.privateKeyFile, "-k")) {
|
||||
if (!parameters.pwd.isEmpty())
|
||||
if (!parameters.password.isEmpty())
|
||||
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
||||
parameters.authType
|
||||
= SshConnectionParameters::AuthByKey;
|
||||
parameters.authenticationType
|
||||
= SshConnectionParameters::AuthenticationByKey;
|
||||
authTypeGiven = true;
|
||||
continue;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ Core::SshConnectionParameters ArgumentsCollector::collect(bool &success) const
|
||||
throw ArgumentErrorException(QLatin1String("No authentication argument given."));
|
||||
if (parameters.host.isEmpty())
|
||||
throw ArgumentErrorException(QLatin1String("No host given."));
|
||||
if (parameters.uname.isEmpty())
|
||||
if (parameters.userName.isEmpty())
|
||||
throw ArgumentErrorException(QLatin1String("No user name given."));
|
||||
|
||||
parameters.port = portGiven ? port : 22;
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#ifndef ARGUMENTSCOLLECTOR_H
|
||||
#define ARGUMENTSCOLLECTOR_H
|
||||
|
||||
#include <coreplugin/ssh/sshconnection.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
@@ -42,7 +42,7 @@ class ArgumentsCollector
|
||||
{
|
||||
public:
|
||||
ArgumentsCollector(const QStringList &args);
|
||||
Core::SshConnectionParameters collect(bool &success) const;
|
||||
Utils::SshConnectionParameters collect(bool &success) const;
|
||||
private:
|
||||
struct ArgumentErrorException
|
||||
{
|
||||
@@ -55,7 +55,7 @@ private:
|
||||
bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven,
|
||||
const char *opt) const;
|
||||
bool checkForNoProxy(int &pos,
|
||||
Core::SshConnectionParameters::ProxyType &type,
|
||||
Utils::SshConnectionParameters::ProxyType &type,
|
||||
bool &alreadyGiven) const;
|
||||
|
||||
const QStringList m_arguments;
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#include "argumentscollector.h"
|
||||
#include "remoteprocesstest.h"
|
||||
|
||||
#include <coreplugin/ssh/sshconnection.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QObject>
|
||||
@@ -43,13 +43,13 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
bool parseSuccess;
|
||||
const Core::SshConnectionParameters ¶meters
|
||||
const Utils::SshConnectionParameters ¶meters
|
||||
= ArgumentsCollector(app.arguments()).collect(parseSuccess);
|
||||
if (!parseSuccess)
|
||||
return EXIT_FAILURE;
|
||||
|
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
RemoteProcessTest::RemoteProcessTest(const SshConnectionParameters ¶ms)
|
||||
: m_timeoutTimer(new QTimer(this)),
|
||||
@@ -53,7 +53,7 @@ RemoteProcessTest::~RemoteProcessTest() { }
|
||||
|
||||
void RemoteProcessTest::run()
|
||||
{
|
||||
connect(m_remoteRunner.data(), SIGNAL(connectionError(Core::SshError)),
|
||||
connect(m_remoteRunner.data(), SIGNAL(connectionError(Utils::SshError)),
|
||||
SLOT(handleConnectionError()));
|
||||
connect(m_remoteRunner.data(), SIGNAL(processStarted()),
|
||||
SLOT(handleProcessStarted()));
|
||||
@@ -88,7 +88,7 @@ void RemoteProcessTest::handleProcessStarted()
|
||||
} else {
|
||||
m_started = true;
|
||||
if (m_state == TestingCrash) {
|
||||
Core::SshRemoteProcess::Ptr killer
|
||||
Utils::SshRemoteProcess::Ptr killer
|
||||
= m_remoteRunner->connection()->createRemoteProcess("pkill -9 sleep");
|
||||
killer->start();
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#ifndef SFTPTEST_H
|
||||
#define SFTPTEST_H
|
||||
|
||||
#include <coreplugin/ssh/sshremoteprocessrunner.h>
|
||||
#include <utils/ssh/sshremoteprocessrunner.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QTimer);
|
||||
#include <QtCore/QObject>
|
||||
@@ -43,7 +43,7 @@ class RemoteProcessTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RemoteProcessTest(const Core::SshConnectionParameters ¶ms);
|
||||
RemoteProcessTest(const Utils::SshConnectionParameters ¶ms);
|
||||
~RemoteProcessTest();
|
||||
void run();
|
||||
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
enum State { Inactive, TestingSuccess, TestingFailure, TestingCrash };
|
||||
|
||||
QTimer * const m_timeoutTimer;
|
||||
const Core::SshRemoteProcessRunner::Ptr m_remoteRunner;
|
||||
const Utils::SshRemoteProcessRunner::Ptr m_remoteRunner;
|
||||
QByteArray m_remoteStdout;
|
||||
QByteArray m_remoteStderr;
|
||||
State m_state;
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
ArgumentsCollector::ArgumentsCollector(const QStringList &args)
|
||||
: m_arguments(args)
|
||||
@@ -57,26 +57,26 @@ Parameters ArgumentsCollector::collect(bool &success) const
|
||||
int port;
|
||||
for (pos = 1; pos < m_arguments.count() - 1; ++pos) {
|
||||
if (checkAndSetStringArg(pos, parameters.sshParams.host, "-h")
|
||||
|| checkAndSetStringArg(pos, parameters.sshParams.uname, "-u"))
|
||||
|| checkAndSetStringArg(pos, parameters.sshParams.userName, "-u"))
|
||||
continue;
|
||||
if (checkAndSetIntArg(pos, port, portGiven, "-p")
|
||||
|| checkAndSetIntArg(pos, parameters.sshParams.timeout, timeoutGiven, "-t")
|
||||
|| checkAndSetIntArg(pos, parameters.smallFileCount, smallFileCountGiven, "-c")
|
||||
|| checkAndSetIntArg(pos, parameters.bigFileSize, bigFileSizeGiven, "-s"))
|
||||
continue;
|
||||
if (checkAndSetStringArg(pos, parameters.sshParams.pwd, "-pwd")) {
|
||||
if (checkAndSetStringArg(pos, parameters.sshParams.password, "-pwd")) {
|
||||
if (!parameters.sshParams.privateKeyFile.isEmpty())
|
||||
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
||||
parameters.sshParams.authType
|
||||
= SshConnectionParameters::AuthByPwd;
|
||||
parameters.sshParams.authenticationType
|
||||
= SshConnectionParameters::AuthenticationByPassword;
|
||||
authTypeGiven = true;
|
||||
continue;
|
||||
}
|
||||
if (checkAndSetStringArg(pos, parameters.sshParams.privateKeyFile, "-k")) {
|
||||
if (!parameters.sshParams.pwd.isEmpty())
|
||||
if (!parameters.sshParams.password.isEmpty())
|
||||
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
||||
parameters.sshParams.authType
|
||||
= SshConnectionParameters::AuthByKey;
|
||||
parameters.sshParams.authenticationType
|
||||
= SshConnectionParameters::AuthenticationByKey;
|
||||
authTypeGiven = true;
|
||||
continue;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ Parameters ArgumentsCollector::collect(bool &success) const
|
||||
throw ArgumentErrorException(QLatin1String("No authentication argument given."));
|
||||
if (parameters.sshParams.host.isEmpty())
|
||||
throw ArgumentErrorException(QLatin1String("No host given."));
|
||||
if (parameters.sshParams.uname.isEmpty())
|
||||
if (parameters.sshParams.userName.isEmpty())
|
||||
throw ArgumentErrorException(QLatin1String("No user name given."));
|
||||
|
||||
parameters.sshParams.port = portGiven ? port : 22;
|
||||
|
@@ -55,7 +55,7 @@ private:
|
||||
bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven,
|
||||
const char *opt) const;
|
||||
bool checkForNoProxy(int &pos,
|
||||
Core::SshConnectionParameters::ProxyType &type,
|
||||
Utils::SshConnectionParameters::ProxyType &type,
|
||||
bool &alreadyGiven) const;
|
||||
|
||||
const QStringList m_arguments;
|
||||
|
@@ -34,8 +34,8 @@
|
||||
#include "argumentscollector.h"
|
||||
#include "sftptest.h"
|
||||
|
||||
#include <coreplugin/ssh/sftpchannel.h>
|
||||
#include <coreplugin/ssh/sshconnection.h>
|
||||
#include <utils/ssh/sftpchannel.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QObject>
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@@ -34,12 +34,12 @@
|
||||
#ifndef PARAMETERS_H
|
||||
#define PARAMETERS_H
|
||||
|
||||
#include <coreplugin/ssh/sshconnection.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
|
||||
struct Parameters {
|
||||
Parameters() : sshParams(Core::SshConnectionParameters::DefaultProxy) {}
|
||||
Parameters() : sshParams(Utils::SshConnectionParameters::DefaultProxy) {}
|
||||
|
||||
Core::SshConnectionParameters sshParams;
|
||||
Utils::SshConnectionParameters sshParams;
|
||||
int smallFileCount;
|
||||
int bigFileSize;
|
||||
};
|
||||
|
@@ -41,7 +41,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
SftpTest::SftpTest(const Parameters ¶ms)
|
||||
: m_parameters(params), m_state(Inactive), m_error(false),
|
||||
@@ -61,7 +61,7 @@ void SftpTest::run()
|
||||
m_connection = SshConnection::create();
|
||||
connect(m_connection.data(), SIGNAL(connected()), this,
|
||||
SLOT(handleConnected()));
|
||||
connect(m_connection.data(), SIGNAL(error(Core::SshError)), this,
|
||||
connect(m_connection.data(), SIGNAL(error(Utils::SshError)), this,
|
||||
SLOT(handleError()));
|
||||
connect(m_connection.data(), SIGNAL(disconnected()), this,
|
||||
SLOT(handleDisconnected()));
|
||||
@@ -84,8 +84,8 @@ void SftpTest::handleConnected()
|
||||
SLOT(handleChannelInitialized()));
|
||||
connect(m_channel.data(), SIGNAL(initializationFailed(QString)), this,
|
||||
SLOT(handleChannelInitializationFailure(QString)));
|
||||
connect(m_channel.data(), SIGNAL(finished(Core::SftpJobId, QString)),
|
||||
this, SLOT(handleJobFinished(Core::SftpJobId, QString)));
|
||||
connect(m_channel.data(), SIGNAL(finished(Utils::SftpJobId, QString)),
|
||||
this, SLOT(handleJobFinished(Utils::SftpJobId, QString)));
|
||||
connect(m_channel.data(), SIGNAL(closed()), this,
|
||||
SLOT(handleChannelClosed()));
|
||||
m_state = InitializingChannel;
|
||||
@@ -192,7 +192,7 @@ void SftpTest::handleChannelClosed()
|
||||
m_connection->disconnectFromHost();
|
||||
}
|
||||
|
||||
void SftpTest::handleJobFinished(Core::SftpJobId job, const QString &error)
|
||||
void SftpTest::handleJobFinished(Utils::SftpJobId job, const QString &error)
|
||||
{
|
||||
switch (m_state) {
|
||||
case UploadingSmall:
|
||||
|
@@ -36,8 +36,8 @@
|
||||
|
||||
#include "parameters.h"
|
||||
|
||||
#include <coreplugin/ssh/sftpchannel.h>
|
||||
#include <coreplugin/ssh/sshconnection.h>
|
||||
#include <utils/ssh/sftpchannel.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include <QtCore/QHash>
|
||||
@@ -61,11 +61,11 @@ private slots:
|
||||
void handleDisconnected();
|
||||
void handleChannelInitialized();
|
||||
void handleChannelInitializationFailure(const QString &reason);
|
||||
void handleJobFinished(Core::SftpJobId job, const QString &error);
|
||||
void handleJobFinished(Utils::SftpJobId job, const QString &error);
|
||||
void handleChannelClosed();
|
||||
|
||||
private:
|
||||
typedef QHash<Core::SftpJobId, QString> JobMap;
|
||||
typedef QHash<Utils::SftpJobId, QString> JobMap;
|
||||
typedef QSharedPointer<QFile> FilePtr;
|
||||
enum State { Inactive, Connecting, InitializingChannel, UploadingSmall,
|
||||
DownloadingSmall, RemovingSmall, UploadingBig, DownloadingBig,
|
||||
@@ -77,25 +77,25 @@ private:
|
||||
QString cmpFileName(const QString &localFileName) const;
|
||||
QString remoteFilePath(const QString &localFileName) const;
|
||||
void earlyDisconnectFromHost();
|
||||
bool handleJobFinished(Core::SftpJobId job, JobMap &jobMap,
|
||||
bool handleJobFinished(Utils::SftpJobId job, JobMap &jobMap,
|
||||
const QString &error, const char *activity);
|
||||
bool handleBigJobFinished(Core::SftpJobId job, Core::SftpJobId expectedJob,
|
||||
bool handleBigJobFinished(Utils::SftpJobId job, Utils::SftpJobId expectedJob,
|
||||
const QString &error, const char *activity);
|
||||
bool compareFiles(QFile *orig, QFile *copy);
|
||||
|
||||
const Parameters m_parameters;
|
||||
State m_state;
|
||||
bool m_error;
|
||||
Core::SshConnection::Ptr m_connection;
|
||||
Core::SftpChannel::Ptr m_channel;
|
||||
Utils::SshConnection::Ptr m_connection;
|
||||
Utils::SftpChannel::Ptr m_channel;
|
||||
QList<FilePtr> m_localSmallFiles;
|
||||
JobMap m_smallFilesUploadJobs;
|
||||
JobMap m_smallFilesDownloadJobs;
|
||||
JobMap m_smallFilesRemovalJobs;
|
||||
FilePtr m_localBigFile;
|
||||
Core::SftpJobId m_bigFileUploadJob;
|
||||
Core::SftpJobId m_bigFileDownloadJob;
|
||||
Core::SftpJobId m_bigFileRemovalJob;
|
||||
Utils::SftpJobId m_bigFileUploadJob;
|
||||
Utils::SftpJobId m_bigFileDownloadJob;
|
||||
Utils::SftpJobId m_bigFileRemovalJob;
|
||||
QElapsedTimer m_bigJobTimer;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user