From bb247fb58a15ad0e6c3e874a066cc13cd38e3719 Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Tue, 27 Aug 2013 21:01:01 +0000 Subject: [PATCH] Fix 'platform shell' command for Linux host and remote lldb-platform connections - add default timeout of 10s (unil qPlatform_RunCommand supports timeout packets and CommandObjectPlatform is updated to read a timeout flag/setting) - add a few tests for platform shell llvm-svn: 189405 --- lldb/source/Commands/CommandObjectPlatform.cpp | 4 ++-- .../gdb-remote/GDBRemoteCommunicationServer.cpp | 4 +++- .../platform/TestPlatformCommand.py | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index 68a1dec1cb98..09942f967534 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -1949,7 +1949,8 @@ public: public: CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + Options(interpreter), + timeout(10) { } @@ -1999,7 +2000,6 @@ public: virtual void OptionParsingStarting () { - timeout = 10; } // Options table: Required for subclasses of Options. diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index 5078170238d1..5c69b89e83ef 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -1254,7 +1254,9 @@ GDBRemoteCommunicationServer::Handle_qPlatform_RunCommand (StringExtractorGDBRem return false; if (packet.GetChar() != ',') return false; - uint32_t timeout = packet.GetHexMaxU32(false, 32); + // FIXME: add timeout to qPlatform_RunCommand packet + // uint32_t timeout = packet.GetHexMaxU32(false, 32); + uint32_t timeout = 10; if (packet.GetChar() == ',') packet.GetHexByteString(working_dir); int status, signo; diff --git a/lldb/test/functionalities/platform/TestPlatformCommand.py b/lldb/test/functionalities/platform/TestPlatformCommand.py index 6c9143b11ab2..2803e712f8ba 100644 --- a/lldb/test/functionalities/platform/TestPlatformCommand.py +++ b/lldb/test/functionalities/platform/TestPlatformCommand.py @@ -32,6 +32,23 @@ class PlatformCommandTestCase(TestBase): self.expect("platform status", substrs = ['Platform', 'Triple', 'OS Version', 'Kernel', 'Hostname']) + def test_shell(self): + """ Test that the platform shell command can invoke ls. """ + self.expect("platform shell ls /", + substrs = ["dev", "tmp", "usr"]) + + def test_shell_builtin(self): + """ Test a shell built-in command (echo) """ + self.expect("platform shell echo hello lldb", + substrs = ["hello lldb"]) + + #FIXME: re-enable once platform shell -t can specify the desired timeout + def test_shell_timeout(self): + """ Test a shell built-in command (sleep) that times out """ + self.skipTest("due to taking too long to complete.") + self.expect("platform shell sleep 15", error=True, + substrs = ["error: timed out waiting for shell command to complete"]) + if __name__ == '__main__': import atexit