blob: 97908269da85cce3b6d8db0de6e3bc9c6cab9e6f [file] [log] [blame]
Johnny Chenc6401792011-03-30 21:19:59 +00001"""
2Test some lldb platform commands.
3"""
4
Zachary Turner77db4a82015-10-22 20:06:20 +00005import lldb_shared
6
Johnny Chenc6401792011-03-30 21:19:59 +00007import os, time
Johnny Chenc6401792011-03-30 21:19:59 +00008import lldb
9from lldbtest import *
10
11class PlatformCommandTestCase(TestBase):
12
Greg Clayton4570d3e2013-12-10 23:19:29 +000013 mydir = TestBase.compute_mydir(__file__)
Johnny Chenc6401792011-03-30 21:19:59 +000014
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000015 @no_debug_info_test
Johnny Chenc6401792011-03-30 21:19:59 +000016 def test_help_platform(self):
17 self.runCmd("help platform")
18
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000019 @no_debug_info_test
Johnny Chenc6401792011-03-30 21:19:59 +000020 def test_list(self):
21 self.expect("platform list",
22 patterns = ['^Available platforms:'])
23
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000024 @no_debug_info_test
Johnny Chenc6401792011-03-30 21:19:59 +000025 def test_process_list(self):
26 self.expect("platform process list",
Jason Molenda75906f42014-10-02 06:17:15 +000027 substrs = ['PID', 'TRIPLE', 'NAME'])
Johnny Chenc6401792011-03-30 21:19:59 +000028
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000029 @no_debug_info_test
Johnny Chenfa92ecc2011-05-09 20:51:47 +000030 def test_process_info_with_no_arg(self):
31 """This is expected to fail and to return a proper error message."""
32 self.expect("platform process info", error=True,
33 substrs = ['one or more process id(s) must be specified'])
34
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000035 @no_debug_info_test
Johnny Chenc6401792011-03-30 21:19:59 +000036 def test_status(self):
37 self.expect("platform status",
38 substrs = ['Platform', 'Triple', 'OS Version', 'Kernel', 'Hostname'])
39
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000040 @no_debug_info_test
Daniel Maleabb247fb2013-08-27 21:01:01 +000041 def test_shell(self):
42 """ Test that the platform shell command can invoke ls. """
Tamas Berghammerccd28a12015-03-04 11:18:34 +000043 triple = self.dbg.GetSelectedPlatform().GetTriple()
44 if re.match(".*-.*-windows", triple):
Zachary Turner57ee6d62014-12-08 21:50:05 +000045 self.expect("platform shell dir c:\\", substrs = ["Windows", "Program Files"])
Tamas Berghammerccd28a12015-03-04 11:18:34 +000046 elif re.match(".*-.*-.*-android", triple):
47 self.expect("platform shell ls /", substrs = ["cache", "dev", "system"])
Zachary Turner57ee6d62014-12-08 21:50:05 +000048 else:
49 self.expect("platform shell ls /", substrs = ["dev", "tmp", "usr"])
Daniel Maleabb247fb2013-08-27 21:01:01 +000050
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000051 @no_debug_info_test
Daniel Maleabb247fb2013-08-27 21:01:01 +000052 def test_shell_builtin(self):
53 """ Test a shell built-in command (echo) """
54 self.expect("platform shell echo hello lldb",
55 substrs = ["hello lldb"])
56
57 #FIXME: re-enable once platform shell -t can specify the desired timeout
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000058 @no_debug_info_test
Daniel Maleabb247fb2013-08-27 21:01:01 +000059 def test_shell_timeout(self):
60 """ Test a shell built-in command (sleep) that times out """
61 self.skipTest("due to taking too long to complete.")
62 self.expect("platform shell sleep 15", error=True,
63 substrs = ["error: timed out waiting for shell command to complete"])