forked from qt-creator/qt-creator
Qnx: Simplify QnxDeviceTester
Change-Id: I789c5ab4fa4a6f79f89db4159d889f67223b8619 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -15,27 +15,13 @@ using namespace Utils;
|
||||
namespace Qnx::Internal {
|
||||
|
||||
QnxDeviceTester::QnxDeviceTester(QObject *parent)
|
||||
: ProjectExplorer::DeviceTester(parent)
|
||||
{
|
||||
m_genericTester = new RemoteLinux::GenericLinuxDeviceTester(this);
|
||||
connect(m_genericTester, &DeviceTester::progressMessage,
|
||||
this, &DeviceTester::progressMessage);
|
||||
connect(m_genericTester, &DeviceTester::errorMessage,
|
||||
this, &DeviceTester::errorMessage);
|
||||
connect(m_genericTester, &DeviceTester::finished,
|
||||
this, &QnxDeviceTester::finished);
|
||||
}
|
||||
|
||||
static QStringList versionSpecificCommandsToTest(int versionNumber)
|
||||
{
|
||||
if (versionNumber > 0x060500)
|
||||
return {"slog2info"};
|
||||
return {};
|
||||
}
|
||||
: RemoteLinux::GenericLinuxDeviceTester(parent)
|
||||
{}
|
||||
|
||||
void QnxDeviceTester::testDevice(const ProjectExplorer::IDevice::Ptr &device)
|
||||
{
|
||||
static const QStringList s_commandsToTest = {"awk",
|
||||
QStringList commandsToTest = {
|
||||
"awk",
|
||||
"cat",
|
||||
"cut",
|
||||
"df",
|
||||
@@ -51,19 +37,24 @@ void QnxDeviceTester::testDevice(const ProjectExplorer::IDevice::Ptr &device)
|
||||
"sed",
|
||||
"sleep",
|
||||
"tail",
|
||||
"uname"};
|
||||
m_device = device;
|
||||
QnxDevice::ConstPtr qnxDevice = m_device.dynamicCast<const QnxDevice>();
|
||||
m_genericTester->setExtraCommandsToTest(
|
||||
s_commandsToTest + versionSpecificCommandsToTest(qnxDevice->qnxVersion()));
|
||||
"uname"
|
||||
};
|
||||
|
||||
QnxDevice::ConstPtr qnxDevice = device.dynamicCast<const QnxDevice>();
|
||||
QTC_ASSERT(qnxDevice, return);
|
||||
|
||||
if (qnxDevice->qnxVersion() > 0x060500)
|
||||
commandsToTest.append("slog2info");
|
||||
|
||||
setExtraCommandsToTest(commandsToTest);
|
||||
|
||||
using namespace Tasking;
|
||||
|
||||
auto setupHandler = [this](QtcProcess &process) {
|
||||
auto setupHandler = [device, this](QtcProcess &process) {
|
||||
emit progressMessage(Tr::tr("Checking that files can be created in %1...")
|
||||
.arg(Constants::QNX_TMP_DIR));
|
||||
const QString pidFile = QString("%1/qtc_xxxx.pid").arg(Constants::QNX_TMP_DIR);
|
||||
const CommandLine cmd(m_device->filePath("/bin/sh"),
|
||||
const CommandLine cmd(device->filePath("/bin/sh"),
|
||||
{"-c", QLatin1String("rm %1 > /dev/null 2>&1; echo ABC > %1 && rm %1").arg(pidFile)});
|
||||
process.setCommand(cmd);
|
||||
};
|
||||
@@ -77,14 +68,9 @@ void QnxDeviceTester::testDevice(const ProjectExplorer::IDevice::Ptr &device)
|
||||
: Tr::tr("Files cannot be created in %1.").arg(Constants::QNX_TMP_DIR);
|
||||
emit errorMessage(message + '\n');
|
||||
};
|
||||
m_genericTester->setExtraTests({Process(setupHandler, doneHandler, errorHandler)});
|
||||
setExtraTests({Process(setupHandler, doneHandler, errorHandler)});
|
||||
|
||||
m_genericTester->testDevice(device);
|
||||
}
|
||||
|
||||
void QnxDeviceTester::stopTest()
|
||||
{
|
||||
m_genericTester->stopTest();
|
||||
RemoteLinux::GenericLinuxDeviceTester::testDevice(device);
|
||||
}
|
||||
|
||||
} // Qnx::Internal
|
||||
|
@@ -7,17 +7,12 @@
|
||||
|
||||
namespace Qnx::Internal {
|
||||
|
||||
class QnxDeviceTester : public ProjectExplorer::DeviceTester
|
||||
class QnxDeviceTester : public RemoteLinux::GenericLinuxDeviceTester
|
||||
{
|
||||
public:
|
||||
explicit QnxDeviceTester(QObject *parent = nullptr);
|
||||
|
||||
void testDevice(const ProjectExplorer::IDevice::Ptr &device) override;
|
||||
void stopTest() override;
|
||||
|
||||
private:
|
||||
RemoteLinux::GenericLinuxDeviceTester *m_genericTester = nullptr;
|
||||
ProjectExplorer::IDevice::ConstPtr m_device;
|
||||
};
|
||||
|
||||
} // Qnx::Internal
|
||||
|
Reference in New Issue
Block a user