blob: 6333fdcffc210beb972c8e7cb8ac4a60f03fc990 [file] [log] [blame]
Johnny Chenc6401792011-03-30 21:19:59 +00001"""
2Test some lldb platform commands.
3"""
4
Zachary Turner35d017f2015-10-23 17:04:29 +00005from __future__ import print_function
6
Zachary Turner0a0490b2015-10-27 20:12:05 +00007import use_lldb_suite
Zachary Turner77db4a82015-10-22 20:06:20 +00008
Johnny Chenc6401792011-03-30 21:19:59 +00009import os, time
Johnny Chenc6401792011-03-30 21:19:59 +000010import lldb
11from lldbtest import *
12
13class PlatformCommandTestCase(TestBase):
14
Greg Clayton4570d3e2013-12-10 23:19:29 +000015 mydir = TestBase.compute_mydir(__file__)
Johnny Chenc6401792011-03-30 21:19:59 +000016
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000017 @no_debug_info_test
Johnny Chenc6401792011-03-30 21:19:59 +000018 def test_help_platform(self):
19 self.runCmd("help platform")
20
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000021 @no_debug_info_test
Johnny Chenc6401792011-03-30 21:19:59 +000022 def test_list(self):
23 self.expect("platform list",
24 patterns = ['^Available platforms:'])
25
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000026 @no_debug_info_test
Johnny Chenc6401792011-03-30 21:19:59 +000027 def test_process_list(self):
28 self.expect("platform process list",
Jason Molenda75906f42014-10-02 06:17:15 +000029 substrs = ['PID', 'TRIPLE', 'NAME'])
Johnny Chenc6401792011-03-30 21:19:59 +000030
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000031 @no_debug_info_test
Johnny Chenfa92ecc2011-05-09 20:51:47 +000032 def test_process_info_with_no_arg(self):
33 """This is expected to fail and to return a proper error message."""
34 self.expect("platform process info", error=True,
35 substrs = ['one or more process id(s) must be specified'])
36
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000037 @no_debug_info_test
Johnny Chenc6401792011-03-30 21:19:59 +000038 def test_status(self):
39 self.expect("platform status",
40 substrs = ['Platform', 'Triple', 'OS Version', 'Kernel', 'Hostname'])
41
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000042 @no_debug_info_test
Daniel Maleabb247fb2013-08-27 21:01:01 +000043 def test_shell(self):
44 """ Test that the platform shell command can invoke ls. """
Tamas Berghammerccd28a12015-03-04 11:18:34 +000045 triple = self.dbg.GetSelectedPlatform().GetTriple()
46 if re.match(".*-.*-windows", triple):
Zachary Turner57ee6d62014-12-08 21:50:05 +000047 self.expect("platform shell dir c:\\", substrs = ["Windows", "Program Files"])
Tamas Berghammerccd28a12015-03-04 11:18:34 +000048 elif re.match(".*-.*-.*-android", triple):
49 self.expect("platform shell ls /", substrs = ["cache", "dev", "system"])
Zachary Turner57ee6d62014-12-08 21:50:05 +000050 else:
51 self.expect("platform shell ls /", substrs = ["dev", "tmp", "usr"])
Daniel Maleabb247fb2013-08-27 21:01:01 +000052
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000053 @no_debug_info_test
Daniel Maleabb247fb2013-08-27 21:01:01 +000054 def test_shell_builtin(self):
55 """ Test a shell built-in command (echo) """
56 self.expect("platform shell echo hello lldb",
57 substrs = ["hello lldb"])
58
59 #FIXME: re-enable once platform shell -t can specify the desired timeout
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000060 @no_debug_info_test
Daniel Maleabb247fb2013-08-27 21:01:01 +000061 def test_shell_timeout(self):
62 """ Test a shell built-in command (sleep) that times out """
63 self.skipTest("due to taking too long to complete.")
64 self.expect("platform shell sleep 15", error=True,
65 substrs = ["error: timed out waiting for shell command to complete"])