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
This commit is contained in:
Daniel Malea 2013-08-27 21:01:01 +00:00
parent 4244cbd9be
commit bb247fb58a
3 changed files with 22 additions and 3 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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