forked from qt-creator/qt-creator
SSH: Fix autotest
- Consider the case of connection sharing being disabled. - Adapt to slower environments. Change-Id: I088622034c26ea343eb78161b24c43b3286b0512 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -231,7 +231,7 @@ void SshConnection::disconnectFromHost()
|
||||
case Connecting:
|
||||
case Connected:
|
||||
if (!d->sharingEnabled) {
|
||||
emitDisconnected();
|
||||
QTimer::singleShot(0, this, &SshConnection::emitDisconnected);
|
||||
return;
|
||||
}
|
||||
d->state = Disconnecting;
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <ssh/sftptransfer.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <ssh/sshremoteprocessrunner.h>
|
||||
#include <ssh/sshsettings.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
@@ -171,8 +172,10 @@ void tst_Ssh::errorHandling()
|
||||
connection.connectToHost();
|
||||
loop.exec();
|
||||
QVERIFY(timer.isActive());
|
||||
QCOMPARE(connection.state(), SshConnection::Unconnected);
|
||||
QVERIFY(!connection.errorString().isEmpty());
|
||||
const bool expectConnected = !SshSettings::connectionSharingEnabled();
|
||||
QCOMPARE(connection.state(), expectConnected ? SshConnection::Connected
|
||||
: SshConnection::Unconnected);
|
||||
QCOMPARE(connection.errorString().isEmpty(), expectConnected);
|
||||
QVERIFY(!disconnected);
|
||||
QVERIFY2(dataReceived.isEmpty(), qPrintable(dataReceived));
|
||||
}
|
||||
@@ -374,7 +377,7 @@ void tst_Ssh::sftp()
|
||||
};
|
||||
FilesToTransfer filesToUpload;
|
||||
std::srand(QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
const QString fileName = "sftptestfile" + QString::number(i + 1);
|
||||
QFile file(dirForFilesToUpload.path() + '/' + fileName);
|
||||
QVERIFY2(file.open(QIODevice::WriteOnly), qPrintable(file.errorString()));
|
||||
@@ -413,7 +416,7 @@ void tst_Ssh::sftp()
|
||||
QTimer timer;
|
||||
QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||
timer.setSingleShot(true);
|
||||
timer.setInterval((params.timeout + 5) * 1000);
|
||||
timer.setInterval(30 * 1000);
|
||||
timer.start();
|
||||
upload->start();
|
||||
loop.exec();
|
||||
@@ -453,7 +456,7 @@ void tst_Ssh::sftp()
|
||||
// Download the uploaded files to a different location
|
||||
const QStringList allUploadedFileNames
|
||||
= QDir(dirForFilesToUpload.path()).entryList(QDir::Files);
|
||||
QCOMPARE(allUploadedFileNames.size(), 1001);
|
||||
QCOMPARE(allUploadedFileNames.size(), 101);
|
||||
for (const QString &fileName : allUploadedFileNames) {
|
||||
const QString localFilePath = dirForFilesToUpload.path() + '/' + fileName;
|
||||
const QString remoteFilePath = getRemoteFilePath(fileName);
|
||||
@@ -462,7 +465,7 @@ void tst_Ssh::sftp()
|
||||
QVERIFY(downloadJob != SftpInvalidJob);
|
||||
jobs << downloadJob;
|
||||
}
|
||||
QCOMPARE(jobs.size(), 1001);
|
||||
QCOMPARE(jobs.size(), 101);
|
||||
loop.exec();
|
||||
QVERIFY(!invalidFinishedSignal);
|
||||
QVERIFY2(jobError.isEmpty(), qPrintable(jobError));
|
||||
@@ -490,6 +493,7 @@ void tst_Ssh::sftp()
|
||||
}
|
||||
|
||||
// Remove the uploaded files on the remote system
|
||||
timer.setInterval((params.timeout + 5) * 1000);
|
||||
for (const QString &fileName : allUploadedFileNames) {
|
||||
const QString remoteFilePath = getRemoteFilePath(fileName);
|
||||
const SftpJobId removeJob = sftpChannel->removeFile(remoteFilePath);
|
||||
|
Reference in New Issue
Block a user