2011-03-30 21:19:59 +00:00
|
|
|
"""
|
|
|
|
|
Test some lldb platform commands.
|
|
|
|
|
"""
|
|
|
|
|
|
2015-10-23 17:04:29 +00:00
|
|
|
|
2015-11-03 19:20:39 +00:00
|
|
|
|
2011-03-30 21:19:59 +00:00
|
|
|
import lldb
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test.decorators import *
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbtest import *
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test import lldbutil
|
2011-03-30 21:19:59 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-03-30 21:19:59 +00:00
|
|
|
class PlatformCommandTestCase(TestBase):
|
|
|
|
|
|
2013-12-10 23:19:29 +00:00
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2011-03-30 21:19:59 +00:00
|
|
|
|
2015-09-30 10:12:40 +00:00
|
|
|
@no_debug_info_test
|
2011-03-30 21:19:59 +00:00
|
|
|
def test_help_platform(self):
|
|
|
|
|
self.runCmd("help platform")
|
|
|
|
|
|
2020-05-09 10:10:35 +02:00
|
|
|
@no_debug_info_test
|
|
|
|
|
def test_help_platform(self):
|
|
|
|
|
self.expect("help shell", substrs=["Run a shell command on the host.",
|
|
|
|
|
"shell <shell-command>"])
|
|
|
|
|
|
|
|
|
|
|
2015-09-30 10:12:40 +00:00
|
|
|
@no_debug_info_test
|
2011-03-30 21:19:59 +00:00
|
|
|
def test_list(self):
|
|
|
|
|
self.expect("platform list",
|
|
|
|
|
patterns=['^Available platforms:'])
|
|
|
|
|
|
2015-09-30 10:12:40 +00:00
|
|
|
@no_debug_info_test
|
2011-03-30 21:19:59 +00:00
|
|
|
def test_process_list(self):
|
|
|
|
|
self.expect("platform process list",
|
2014-10-02 06:17:15 +00:00
|
|
|
substrs=['PID', 'TRIPLE', 'NAME'])
|
2011-03-30 21:19:59 +00:00
|
|
|
|
2015-09-30 10:12:40 +00:00
|
|
|
@no_debug_info_test
|
2011-05-09 20:51:47 +00:00
|
|
|
def test_process_info_with_no_arg(self):
|
|
|
|
|
"""This is expected to fail and to return a proper error message."""
|
|
|
|
|
self.expect("platform process info", error=True,
|
|
|
|
|
substrs=['one or more process id(s) must be specified'])
|
|
|
|
|
|
2015-09-30 10:12:40 +00:00
|
|
|
@no_debug_info_test
|
2011-03-30 21:19:59 +00:00
|
|
|
def test_status(self):
|
|
|
|
|
self.expect(
|
|
|
|
|
"platform status",
|
|
|
|
|
substrs=[
|
|
|
|
|
'Platform',
|
|
|
|
|
'Triple',
|
|
|
|
|
'OS Version',
|
2020-01-31 14:23:56 -08:00
|
|
|
'Hostname',
|
2011-03-30 21:19:59 +00:00
|
|
|
'Kernel',
|
2020-01-31 14:23:56 -08:00
|
|
|
])
|
2011-03-30 21:19:59 +00:00
|
|
|
|
2019-02-07 18:22:00 +00:00
|
|
|
@expectedFailureAll(oslist=["windows"])
|
2015-09-30 10:12:40 +00:00
|
|
|
@no_debug_info_test
|
2013-08-27 21:01:01 +00:00
|
|
|
def test_shell(self):
|
|
|
|
|
""" Test that the platform shell command can invoke ls. """
|
2015-03-04 11:18:34 +00:00
|
|
|
triple = self.dbg.GetSelectedPlatform().GetTriple()
|
|
|
|
|
if re.match(".*-.*-windows", triple):
|
2014-12-08 21:50:05 +00:00
|
|
|
self.expect(
|
|
|
|
|
"platform shell dir c:\\", substrs=[
|
|
|
|
|
"Windows", "Program Files"])
|
2020-05-09 10:10:35 +02:00
|
|
|
self.expect("shell dir c:\\", substrs=["Windows", "Program Files"])
|
2015-03-04 11:18:34 +00:00
|
|
|
elif re.match(".*-.*-.*-android", triple):
|
|
|
|
|
self.expect(
|
|
|
|
|
"platform shell ls /",
|
|
|
|
|
substrs=[
|
|
|
|
|
"cache",
|
|
|
|
|
"dev",
|
|
|
|
|
"system"])
|
2020-05-09 10:10:35 +02:00
|
|
|
self.expect("shell ls /",
|
|
|
|
|
substrs=["cache", "dev", "system"])
|
2014-12-08 21:50:05 +00:00
|
|
|
else:
|
|
|
|
|
self.expect("platform shell ls /", substrs=["dev", "tmp", "usr"])
|
2020-05-09 10:10:35 +02:00
|
|
|
self.expect("shell ls /", substrs=["dev", "tmp", "usr"])
|
2013-08-27 21:01:01 +00:00
|
|
|
|
2015-09-30 10:12:40 +00:00
|
|
|
@no_debug_info_test
|
2013-08-27 21:01:01 +00:00
|
|
|
def test_shell_builtin(self):
|
|
|
|
|
""" Test a shell built-in command (echo) """
|
|
|
|
|
self.expect("platform shell echo hello lldb",
|
|
|
|
|
substrs=["hello lldb"])
|
2020-05-09 10:10:35 +02:00
|
|
|
self.expect("shell echo hello lldb",
|
|
|
|
|
substrs=["hello lldb"])
|
|
|
|
|
|
2013-08-27 21:01:01 +00:00
|
|
|
|
2015-09-30 10:12:40 +00:00
|
|
|
@no_debug_info_test
|
2013-08-27 21:01:01 +00:00
|
|
|
def test_shell_timeout(self):
|
|
|
|
|
""" Test a shell built-in command (sleep) that times out """
|
2020-05-09 10:10:35 +02:00
|
|
|
self.skipTest("Alias with option not supported by the command interpreter.")
|
|
|
|
|
self.expect("platform shell -t 1 -- sleep 15", error=True, substrs=[
|
|
|
|
|
"error: timed out waiting for shell command to complete"])
|
|
|
|
|
self.expect("shell -t 1 -- sleep 3", error=True, substrs=[
|
2013-08-27 21:01:01 +00:00
|
|
|
"error: timed out waiting for shell command to complete"])
|