forked from qt-creator/qt-creator
DeviceShell: Test no-script fallback
Change-Id: I97f6df6face701b247b6be3320d89511a1310857 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -151,7 +151,8 @@ done) > $FINAL_OUT
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DeviceShell::DeviceShell()
|
DeviceShell::DeviceShell(bool forceFailScriptInstallation)
|
||||||
|
: m_forceFailScriptInstallation(forceFailScriptInstallation)
|
||||||
{
|
{
|
||||||
m_thread.setObjectName("DeviceShell");
|
m_thread.setObjectName("DeviceShell");
|
||||||
m_thread.start();
|
m_thread.start();
|
||||||
@@ -389,6 +390,11 @@ bool DeviceShell::checkCommand(const QByteArray &command)
|
|||||||
|
|
||||||
bool DeviceShell::installShellScript()
|
bool DeviceShell::installShellScript()
|
||||||
{
|
{
|
||||||
|
if (m_forceFailScriptInstallation) {
|
||||||
|
m_shellScriptState = State::NoScript;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!checkCommand("base64")) {
|
if (!checkCommand("base64")) {
|
||||||
m_shellScriptState = State::NoScript;
|
m_shellScriptState = State::NoScript;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
ExitCode,
|
ExitCode,
|
||||||
};
|
};
|
||||||
|
|
||||||
DeviceShell();
|
DeviceShell(bool forceFailScriptInstallation = false);
|
||||||
virtual ~DeviceShell();
|
virtual ~DeviceShell();
|
||||||
|
|
||||||
bool start();
|
bool start();
|
||||||
@@ -90,6 +90,9 @@ private:
|
|||||||
|
|
||||||
State m_shellScriptState = State::Unknown;
|
State m_shellScriptState = State::Unknown;
|
||||||
QStringList m_missingFeatures;
|
QStringList m_missingFeatures;
|
||||||
|
|
||||||
|
// Only used for tests
|
||||||
|
bool m_forceFailScriptInstallation = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ using namespace Utils;
|
|||||||
class TestShell : public DeviceShell
|
class TestShell : public DeviceShell
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestShell(CommandLine cmdLine)
|
TestShell(CommandLine cmdLine, bool failScript = false)
|
||||||
: m_cmdLine(std::move(cmdLine))
|
: DeviceShell(failScript)
|
||||||
|
, m_cmdLine(std::move(cmdLine))
|
||||||
{
|
{
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
@@ -340,6 +341,25 @@ private slots:
|
|||||||
|
|
||||||
QVERIFY (!Utils::anyOf(results, [&results](const QByteArray r){ return r != results[0]; }));
|
QVERIFY (!Utils::anyOf(results, [&results](const QByteArray r){ return r != results[0]; }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testNoScript_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<CommandLine>("cmdLine");
|
||||||
|
for (const auto &cmdLine : m_availableShells) {
|
||||||
|
QTest::newRow(cmdLine.executable().baseName().toUtf8()) << cmdLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testNoScript()
|
||||||
|
{
|
||||||
|
QFETCH(CommandLine, cmdLine);
|
||||||
|
|
||||||
|
TestShell shell(cmdLine, true);
|
||||||
|
QCOMPARE(shell.state(), DeviceShell::State::NoScript);
|
||||||
|
|
||||||
|
const bool result = shell.runInShell({"echo", {"Hello"}});
|
||||||
|
QCOMPARE(result, true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(tst_DeviceShell)
|
QTEST_GUILESS_MAIN(tst_DeviceShell)
|
||||||
|
|||||||
Reference in New Issue
Block a user