blob: ab88b25038e49f0158047c89d5c049ce4b33bd93 [file] [log] [blame]
Johnny Chenc6401792011-03-30 21:19:59 +00001"""
2Test some lldb platform commands.
3"""
4
5import os, time
6import unittest2
7import lldb
8from lldbtest import *
9
10class PlatformCommandTestCase(TestBase):
11
Greg Clayton4570d3e2013-12-10 23:19:29 +000012 mydir = TestBase.compute_mydir(__file__)
Johnny Chenc6401792011-03-30 21:19:59 +000013
14 def test_help_platform(self):
15 self.runCmd("help platform")
16
17 def test_list(self):
18 self.expect("platform list",
19 patterns = ['^Available platforms:'])
20
21 def test_process_list(self):
22 self.expect("platform process list",
Jason Molenda75906f42014-10-02 06:17:15 +000023 substrs = ['PID', 'TRIPLE', 'NAME'])
Johnny Chenc6401792011-03-30 21:19:59 +000024
Johnny Chenfa92ecc2011-05-09 20:51:47 +000025 def test_process_info_with_no_arg(self):
26 """This is expected to fail and to return a proper error message."""
27 self.expect("platform process info", error=True,
28 substrs = ['one or more process id(s) must be specified'])
29
Johnny Chenc6401792011-03-30 21:19:59 +000030 def test_status(self):
31 self.expect("platform status",
32 substrs = ['Platform', 'Triple', 'OS Version', 'Kernel', 'Hostname'])
33
Daniel Maleabb247fb2013-08-27 21:01:01 +000034 def test_shell(self):
35 """ Test that the platform shell command can invoke ls. """
36 self.expect("platform shell ls /",
37 substrs = ["dev", "tmp", "usr"])
38
39 def test_shell_builtin(self):
40 """ Test a shell built-in command (echo) """
41 self.expect("platform shell echo hello lldb",
42 substrs = ["hello lldb"])
43
44 #FIXME: re-enable once platform shell -t can specify the desired timeout
45 def test_shell_timeout(self):
46 """ Test a shell built-in command (sleep) that times out """
47 self.skipTest("due to taking too long to complete.")
48 self.expect("platform shell sleep 15", error=True,
49 substrs = ["error: timed out waiting for shell command to complete"])
50
Johnny Chenc6401792011-03-30 21:19:59 +000051
52if __name__ == '__main__':
53 import atexit
54 lldb.SBDebugger.Initialize()
55 atexit.register(lambda: lldb.SBDebugger.Terminate())
56 unittest2.main()