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