forked from qt-creator/qt-creator
LinuxDeviceTester: Use Storage for internal inter-process data
Change-Id: If186c2cd83781a1de4c2a9d579611079ee7318b4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -21,6 +21,11 @@ using namespace Utils::Tasking;
|
|||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
struct TransferStorage
|
||||||
|
{
|
||||||
|
bool sftpWorks = false;
|
||||||
|
};
|
||||||
|
|
||||||
class GenericLinuxDeviceTesterPrivate
|
class GenericLinuxDeviceTesterPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -29,15 +34,15 @@ public:
|
|||||||
TaskItem echoTask() const;
|
TaskItem echoTask() const;
|
||||||
TaskItem unameTask() const;
|
TaskItem unameTask() const;
|
||||||
TaskItem gathererTask() const;
|
TaskItem gathererTask() const;
|
||||||
TaskItem transferTask(FileTransferMethod method);
|
TaskItem transferTask(FileTransferMethod method,
|
||||||
TaskItem transferTasks();
|
const TreeStorage<TransferStorage> &storage) const;
|
||||||
|
TaskItem transferTasks() const;
|
||||||
TaskItem commandTask(const QString &commandName) const;
|
TaskItem commandTask(const QString &commandName) const;
|
||||||
TaskItem commandTasks() const;
|
TaskItem commandTasks() const;
|
||||||
|
|
||||||
GenericLinuxDeviceTester *q = nullptr;
|
GenericLinuxDeviceTester *q = nullptr;
|
||||||
IDevice::Ptr m_device;
|
IDevice::Ptr m_device;
|
||||||
std::unique_ptr<TaskTree> m_taskTree;
|
std::unique_ptr<TaskTree> m_taskTree;
|
||||||
bool m_sftpWorks = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const QStringList s_commandsToTest = {"base64",
|
const QStringList s_commandsToTest = {"base64",
|
||||||
@@ -142,7 +147,8 @@ TaskItem GenericLinuxDeviceTesterPrivate::gathererTask() const
|
|||||||
return PortGatherer(setup, done, error);
|
return PortGatherer(setup, done, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method)
|
TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method,
|
||||||
|
const TreeStorage<TransferStorage> &storage) const
|
||||||
{
|
{
|
||||||
const auto setup = [this, method](FileTransfer &transfer) {
|
const auto setup = [this, method](FileTransfer &transfer) {
|
||||||
emit q->progressMessage(Tr::tr("Checking whether \"%1\" works...")
|
emit q->progressMessage(Tr::tr("Checking whether \"%1\" works...")
|
||||||
@@ -150,15 +156,15 @@ TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method
|
|||||||
transfer.setTransferMethod(method);
|
transfer.setTransferMethod(method);
|
||||||
transfer.setTestDevice(m_device);
|
transfer.setTestDevice(m_device);
|
||||||
};
|
};
|
||||||
const auto done = [this, method](const FileTransfer &) {
|
const auto done = [this, method, storage](const FileTransfer &) {
|
||||||
const QString methodName = FileTransfer::transferMethodName(method);
|
const QString methodName = FileTransfer::transferMethodName(method);
|
||||||
emit q->progressMessage(Tr::tr("\"%1\" is functional.\n").arg(methodName));
|
emit q->progressMessage(Tr::tr("\"%1\" is functional.\n").arg(methodName));
|
||||||
if (method == FileTransferMethod::Rsync)
|
if (method == FileTransferMethod::Rsync)
|
||||||
m_device->setExtraData(Constants::SupportsRSync, true);
|
m_device->setExtraData(Constants::SupportsRSync, true);
|
||||||
else
|
else
|
||||||
m_sftpWorks = true;
|
storage->sftpWorks = true;
|
||||||
};
|
};
|
||||||
const auto error = [this, method](const FileTransfer &transfer) {
|
const auto error = [this, method, storage](const FileTransfer &transfer) {
|
||||||
const QString methodName = FileTransfer::transferMethodName(method);
|
const QString methodName = FileTransfer::transferMethodName(method);
|
||||||
const ProcessResultData resultData = transfer.resultData();
|
const ProcessResultData resultData = transfer.resultData();
|
||||||
QString error;
|
QString error;
|
||||||
@@ -173,7 +179,7 @@ TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method
|
|||||||
emit q->errorMessage(error);
|
emit q->errorMessage(error);
|
||||||
if (method == FileTransferMethod::Rsync) {
|
if (method == FileTransferMethod::Rsync) {
|
||||||
m_device->setExtraData(Constants::SupportsRSync, false);
|
m_device->setExtraData(Constants::SupportsRSync, false);
|
||||||
if (!m_sftpWorks)
|
if (!storage->sftpWorks)
|
||||||
return;
|
return;
|
||||||
const QString sftp = FileTransfer::transferMethodName(FileTransferMethod::Sftp);
|
const QString sftp = FileTransfer::transferMethodName(FileTransferMethod::Sftp);
|
||||||
const QString rsync = methodName;
|
const QString rsync = methodName;
|
||||||
@@ -184,12 +190,14 @@ TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method
|
|||||||
return TransferTest(setup, done, error);
|
return TransferTest(setup, done, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskItem GenericLinuxDeviceTesterPrivate::transferTasks()
|
TaskItem GenericLinuxDeviceTesterPrivate::transferTasks() const
|
||||||
{
|
{
|
||||||
|
TreeStorage<TransferStorage> storage;
|
||||||
return Tasking::Group {
|
return Tasking::Group {
|
||||||
continueOnDone,
|
continueOnDone,
|
||||||
transferTask(FileTransferMethod::Sftp),
|
Storage(storage),
|
||||||
transferTask(FileTransferMethod::Rsync),
|
transferTask(FileTransferMethod::Sftp, storage),
|
||||||
|
transferTask(FileTransferMethod::Rsync, storage),
|
||||||
OnGroupError([this] { emit q->errorMessage(Tr::tr("Deployment to this device will not "
|
OnGroupError([this] { emit q->errorMessage(Tr::tr("Deployment to this device will not "
|
||||||
"work out of the box.\n"));
|
"work out of the box.\n"));
|
||||||
})
|
})
|
||||||
@@ -243,7 +251,6 @@ void GenericLinuxDeviceTester::testDevice(const IDevice::Ptr &deviceConfiguratio
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(!d->m_taskTree, return);
|
QTC_ASSERT(!d->m_taskTree, return);
|
||||||
|
|
||||||
d->m_sftpWorks = false;
|
|
||||||
d->m_device = deviceConfiguration;
|
d->m_device = deviceConfiguration;
|
||||||
|
|
||||||
auto allFinished = [this](DeviceTester::TestResult testResult) {
|
auto allFinished = [this](DeviceTester::TestResult testResult) {
|
||||||
|
Reference in New Issue
Block a user