Qnx: Simplify QnxDeviceTester

Change-Id: I789c5ab4fa4a6f79f89db4159d889f67223b8619
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-03-14 16:38:02 +01:00
parent 0842f69888
commit 52a7205965
2 changed files with 34 additions and 53 deletions

View File

@@ -15,27 +15,13 @@ using namespace Utils;
namespace Qnx::Internal { namespace Qnx::Internal {
QnxDeviceTester::QnxDeviceTester(QObject *parent) QnxDeviceTester::QnxDeviceTester(QObject *parent)
: ProjectExplorer::DeviceTester(parent) : RemoteLinux::GenericLinuxDeviceTester(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 {};
}
void QnxDeviceTester::testDevice(const ProjectExplorer::IDevice::Ptr &device) void QnxDeviceTester::testDevice(const ProjectExplorer::IDevice::Ptr &device)
{ {
static const QStringList s_commandsToTest = {"awk", QStringList commandsToTest = {
"awk",
"cat", "cat",
"cut", "cut",
"df", "df",
@@ -51,19 +37,24 @@ void QnxDeviceTester::testDevice(const ProjectExplorer::IDevice::Ptr &device)
"sed", "sed",
"sleep", "sleep",
"tail", "tail",
"uname"}; "uname"
m_device = device; };
QnxDevice::ConstPtr qnxDevice = m_device.dynamicCast<const QnxDevice>();
m_genericTester->setExtraCommandsToTest( QnxDevice::ConstPtr qnxDevice = device.dynamicCast<const QnxDevice>();
s_commandsToTest + versionSpecificCommandsToTest(qnxDevice->qnxVersion())); QTC_ASSERT(qnxDevice, return);
if (qnxDevice->qnxVersion() > 0x060500)
commandsToTest.append("slog2info");
setExtraCommandsToTest(commandsToTest);
using namespace Tasking; 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...") emit progressMessage(Tr::tr("Checking that files can be created in %1...")
.arg(Constants::QNX_TMP_DIR)); .arg(Constants::QNX_TMP_DIR));
const QString pidFile = QString("%1/qtc_xxxx.pid").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)}); {"-c", QLatin1String("rm %1 > /dev/null 2>&1; echo ABC > %1 && rm %1").arg(pidFile)});
process.setCommand(cmd); 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); : Tr::tr("Files cannot be created in %1.").arg(Constants::QNX_TMP_DIR);
emit errorMessage(message + '\n'); emit errorMessage(message + '\n');
}; };
m_genericTester->setExtraTests({Process(setupHandler, doneHandler, errorHandler)}); setExtraTests({Process(setupHandler, doneHandler, errorHandler)});
m_genericTester->testDevice(device); RemoteLinux::GenericLinuxDeviceTester::testDevice(device);
}
void QnxDeviceTester::stopTest()
{
m_genericTester->stopTest();
} }
} // Qnx::Internal } // Qnx::Internal

View File

@@ -7,17 +7,12 @@
namespace Qnx::Internal { namespace Qnx::Internal {
class QnxDeviceTester : public ProjectExplorer::DeviceTester class QnxDeviceTester : public RemoteLinux::GenericLinuxDeviceTester
{ {
public: public:
explicit QnxDeviceTester(QObject *parent = nullptr); explicit QnxDeviceTester(QObject *parent = nullptr);
void testDevice(const ProjectExplorer::IDevice::Ptr &device) override; void testDevice(const ProjectExplorer::IDevice::Ptr &device) override;
void stopTest() override;
private:
RemoteLinux::GenericLinuxDeviceTester *m_genericTester = nullptr;
ProjectExplorer::IDevice::ConstPtr m_device;
}; };
} // Qnx::Internal } // Qnx::Internal