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