1""" 2Test some lldb platform commands. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class PlatformCommandTestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 NO_DEBUG_INFO_TESTCASE = True 17 18 @no_debug_info_test 19 def test_help_platform(self): 20 self.runCmd("help platform") 21 22 @no_debug_info_test 23 def test_help_platform(self): 24 self.expect("help shell", substrs=["Run a shell command on the host.", 25 "shell <shell-command>"]) 26 27 28 @no_debug_info_test 29 def test_list(self): 30 self.expect("platform list", 31 patterns=['^Available platforms:']) 32 33 @no_debug_info_test 34 def test_process_list(self): 35 self.expect("platform process list", 36 substrs=['PID', 'TRIPLE', 'NAME']) 37 38 @no_debug_info_test 39 def test_process_info_with_no_arg(self): 40 """This is expected to fail and to return a proper error message.""" 41 self.expect("platform process info", error=True, 42 substrs=['one or more process id(s) must be specified']) 43 44 @no_debug_info_test 45 def test_status(self): 46 self.expect( 47 "platform status", 48 substrs=[ 49 'Platform', 50 'Triple', 51 'OS Version', 52 'Hostname', 53 'Kernel', 54 ]) 55 56 @expectedFailureAll(oslist=["windows"]) 57 @no_debug_info_test 58 def test_shell(self): 59 """ Test that the platform shell command can invoke ls. """ 60 triple = self.dbg.GetSelectedPlatform().GetTriple() 61 if re.match(".*-.*-windows", triple): 62 self.expect( 63 "platform shell dir c:\\", substrs=[ 64 "Windows", "Program Files"]) 65 self.expect("shell dir c:\\", substrs=["Windows", "Program Files"]) 66 elif re.match(".*-.*-.*-android", triple): 67 self.expect( 68 "platform shell ls /", 69 substrs=[ 70 "cache", 71 "dev", 72 "system"]) 73 self.expect("shell ls /", 74 substrs=["cache", "dev", "system"]) 75 else: 76 self.expect("platform shell ls /", substrs=["dev", "tmp", "usr"]) 77 self.expect("shell ls /", substrs=["dev", "tmp", "usr"]) 78 79 @no_debug_info_test 80 def test_shell_builtin(self): 81 """ Test a shell built-in command (echo) """ 82 self.expect("platform shell echo hello lldb", 83 substrs=["hello lldb"]) 84 self.expect("shell echo hello lldb", 85 substrs=["hello lldb"]) 86 87 88 @no_debug_info_test 89 def test_shell_timeout(self): 90 """ Test a shell built-in command (sleep) that times out """ 91 self.skipTest("Alias with option not supported by the command interpreter.") 92 self.expect("platform shell -t 1 -- sleep 15", error=True, substrs=[ 93 "error: timed out waiting for shell command to complete"]) 94 self.expect("shell -t 1 -- sleep 3", error=True, substrs=[ 95 "error: timed out waiting for shell command to complete"]) 96 97 @no_debug_info_test 98 def test_host_shell_interpreter(self): 99 """ Test the host platform shell with a different interpreter """ 100 self.build() 101 exe = self.getBuildArtifact('a.out') 102 self.expect("platform shell -h -s " + exe + " -- 'echo $0'", 103 substrs=['SUCCESS', 'a.out']) 104