Johnny Chen | c640179 | 2011-03-30 21:19:59 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test some lldb platform commands. |
| 3 | """ |
| 4 | |
Zachary Turner | 77db4a8 | 2015-10-22 20:06:20 +0000 | [diff] [blame^] | 5 | import lldb_shared |
| 6 | |
Johnny Chen | c640179 | 2011-03-30 21:19:59 +0000 | [diff] [blame] | 7 | import os, time |
Johnny Chen | c640179 | 2011-03-30 21:19:59 +0000 | [diff] [blame] | 8 | import lldb |
| 9 | from lldbtest import * |
| 10 | |
| 11 | class PlatformCommandTestCase(TestBase): |
| 12 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 13 | mydir = TestBase.compute_mydir(__file__) |
Johnny Chen | c640179 | 2011-03-30 21:19:59 +0000 | [diff] [blame] | 14 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 15 | @no_debug_info_test |
Johnny Chen | c640179 | 2011-03-30 21:19:59 +0000 | [diff] [blame] | 16 | def test_help_platform(self): |
| 17 | self.runCmd("help platform") |
| 18 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 19 | @no_debug_info_test |
Johnny Chen | c640179 | 2011-03-30 21:19:59 +0000 | [diff] [blame] | 20 | def test_list(self): |
| 21 | self.expect("platform list", |
| 22 | patterns = ['^Available platforms:']) |
| 23 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 24 | @no_debug_info_test |
Johnny Chen | c640179 | 2011-03-30 21:19:59 +0000 | [diff] [blame] | 25 | def test_process_list(self): |
| 26 | self.expect("platform process list", |
Jason Molenda | 75906f4 | 2014-10-02 06:17:15 +0000 | [diff] [blame] | 27 | substrs = ['PID', 'TRIPLE', 'NAME']) |
Johnny Chen | c640179 | 2011-03-30 21:19:59 +0000 | [diff] [blame] | 28 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 29 | @no_debug_info_test |
Johnny Chen | fa92ecc | 2011-05-09 20:51:47 +0000 | [diff] [blame] | 30 | 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 Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 35 | @no_debug_info_test |
Johnny Chen | c640179 | 2011-03-30 21:19:59 +0000 | [diff] [blame] | 36 | def test_status(self): |
| 37 | self.expect("platform status", |
| 38 | substrs = ['Platform', 'Triple', 'OS Version', 'Kernel', 'Hostname']) |
| 39 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 40 | @no_debug_info_test |
Daniel Malea | bb247fb | 2013-08-27 21:01:01 +0000 | [diff] [blame] | 41 | def test_shell(self): |
| 42 | """ Test that the platform shell command can invoke ls. """ |
Tamas Berghammer | ccd28a1 | 2015-03-04 11:18:34 +0000 | [diff] [blame] | 43 | triple = self.dbg.GetSelectedPlatform().GetTriple() |
| 44 | if re.match(".*-.*-windows", triple): |
Zachary Turner | 57ee6d6 | 2014-12-08 21:50:05 +0000 | [diff] [blame] | 45 | self.expect("platform shell dir c:\\", substrs = ["Windows", "Program Files"]) |
Tamas Berghammer | ccd28a1 | 2015-03-04 11:18:34 +0000 | [diff] [blame] | 46 | elif re.match(".*-.*-.*-android", triple): |
| 47 | self.expect("platform shell ls /", substrs = ["cache", "dev", "system"]) |
Zachary Turner | 57ee6d6 | 2014-12-08 21:50:05 +0000 | [diff] [blame] | 48 | else: |
| 49 | self.expect("platform shell ls /", substrs = ["dev", "tmp", "usr"]) |
Daniel Malea | bb247fb | 2013-08-27 21:01:01 +0000 | [diff] [blame] | 50 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 51 | @no_debug_info_test |
Daniel Malea | bb247fb | 2013-08-27 21:01:01 +0000 | [diff] [blame] | 52 | 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 Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 58 | @no_debug_info_test |
Daniel Malea | bb247fb | 2013-08-27 21:01:01 +0000 | [diff] [blame] | 59 | 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"]) |