]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/platform/TestPlatformCommand.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / platform / TestPlatformCommand.py
1 """
2 Test some lldb platform commands.
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15 class PlatformCommandTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     @no_debug_info_test
20     def test_help_platform(self):
21         self.runCmd("help platform")
22
23     @no_debug_info_test
24     def test_list(self):
25         self.expect("platform list",
26             patterns = ['^Available platforms:'])
27
28     @no_debug_info_test
29     def test_process_list(self):
30         self.expect("platform process list",
31             substrs = ['PID', 'TRIPLE', 'NAME'])
32
33     @no_debug_info_test
34     def test_process_info_with_no_arg(self):
35         """This is expected to fail and to return a proper error message."""
36         self.expect("platform process info", error=True,
37             substrs = ['one or more process id(s) must be specified'])
38
39     @no_debug_info_test
40     def test_status(self):
41         self.expect("platform status",
42             substrs = ['Platform', 'Triple', 'OS Version', 'Kernel', 'Hostname'])
43
44     @no_debug_info_test
45     def test_shell(self):
46         """ Test that the platform shell command can invoke ls. """
47         triple = self.dbg.GetSelectedPlatform().GetTriple()
48         if re.match(".*-.*-windows", triple):
49           self.expect("platform shell dir c:\\", substrs = ["Windows", "Program Files"])
50         elif re.match(".*-.*-.*-android", triple):
51           self.expect("platform shell ls /", substrs = ["cache", "dev", "system"])
52         else:
53           self.expect("platform shell ls /", substrs = ["dev", "tmp", "usr"])
54
55     @no_debug_info_test
56     def test_shell_builtin(self):
57         """ Test a shell built-in command (echo) """
58         self.expect("platform shell echo hello lldb",
59             substrs = ["hello lldb"])
60
61     #FIXME: re-enable once platform shell -t can specify the desired timeout
62     @no_debug_info_test
63     def test_shell_timeout(self):
64         """ Test a shell built-in command (sleep) that times out """
65         self.skipTest("due to taking too long to complete.")
66         self.expect("platform shell sleep 15", error=True,
67                 substrs = ["error: timed out waiting for shell command to complete"])