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
|
||||
|
||||
DeviceShell::DeviceShell()
|
||||
DeviceShell::DeviceShell(bool forceFailScriptInstallation)
|
||||
: m_forceFailScriptInstallation(forceFailScriptInstallation)
|
||||
{
|
||||
m_thread.setObjectName("DeviceShell");
|
||||
m_thread.start();
|
||||
@@ -389,6 +390,11 @@ bool DeviceShell::checkCommand(const QByteArray &command)
|
||||
|
||||
bool DeviceShell::installShellScript()
|
||||
{
|
||||
if (m_forceFailScriptInstallation) {
|
||||
m_shellScriptState = State::NoScript;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checkCommand("base64")) {
|
||||
m_shellScriptState = State::NoScript;
|
||||
return false;
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
ExitCode,
|
||||
};
|
||||
|
||||
DeviceShell();
|
||||
DeviceShell(bool forceFailScriptInstallation = false);
|
||||
virtual ~DeviceShell();
|
||||
|
||||
bool start();
|
||||
@@ -90,6 +90,9 @@ private:
|
||||
|
||||
State m_shellScriptState = State::Unknown;
|
||||
QStringList m_missingFeatures;
|
||||
|
||||
// Only used for tests
|
||||
bool m_forceFailScriptInstallation = false;
|
||||
};
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
@@ -20,8 +20,9 @@ using namespace Utils;
|
||||
class TestShell : public DeviceShell
|
||||
{
|
||||
public:
|
||||
TestShell(CommandLine cmdLine)
|
||||
: m_cmdLine(std::move(cmdLine))
|
||||
TestShell(CommandLine cmdLine, bool failScript = false)
|
||||
: DeviceShell(failScript)
|
||||
, m_cmdLine(std::move(cmdLine))
|
||||
{
|
||||
start();
|
||||
}
|
||||
@@ -340,6 +341,25 @@ private slots:
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user