summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py79
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformPython.py81
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/Makefile5
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py32
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/main.cpp9
5 files changed, 206 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py
new file mode 100644
index 00000000000..ab45b221c94
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformCommand.py
@@ -0,0 +1,79 @@
+"""
+Test some lldb platform commands.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class PlatformCommandTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @no_debug_info_test
+ def test_help_platform(self):
+ self.runCmd("help platform")
+
+ @no_debug_info_test
+ def test_list(self):
+ self.expect("platform list",
+ patterns=['^Available platforms:'])
+
+ @no_debug_info_test
+ def test_process_list(self):
+ self.expect("platform process list",
+ substrs=['PID', 'TRIPLE', 'NAME'])
+
+ @no_debug_info_test
+ 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'])
+
+ @no_debug_info_test
+ def test_status(self):
+ self.expect(
+ "platform status",
+ substrs=[
+ 'Platform',
+ 'Triple',
+ 'OS Version',
+ 'Kernel',
+ 'Hostname'])
+
+ @expectedFailureAll(oslist=["windows"])
+ @no_debug_info_test
+ def test_shell(self):
+ """ Test that the platform shell command can invoke ls. """
+ triple = self.dbg.GetSelectedPlatform().GetTriple()
+ if re.match(".*-.*-windows", triple):
+ self.expect(
+ "platform shell dir c:\\", substrs=[
+ "Windows", "Program Files"])
+ elif re.match(".*-.*-.*-android", triple):
+ self.expect(
+ "platform shell ls /",
+ substrs=[
+ "cache",
+ "dev",
+ "system"])
+ else:
+ self.expect("platform shell ls /", substrs=["dev", "tmp", "usr"])
+
+ @no_debug_info_test
+ def test_shell_builtin(self):
+ """ Test a shell built-in command (echo) """
+ self.expect("platform shell echo hello lldb",
+ substrs=["hello lldb"])
+
+ # FIXME: re-enable once platform shell -t can specify the desired timeout
+ @no_debug_info_test
+ def test_shell_timeout(self):
+ """ Test a shell built-in command (sleep) that times out """
+ self.skipTest("due to taking too long to complete.")
+ self.expect("platform shell sleep 15", error=True, substrs=[
+ "error: timed out waiting for shell command to complete"])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformPython.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformPython.py
new file mode 100644
index 00000000000..ab10d30b6ff
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/basic/TestPlatformPython.py
@@ -0,0 +1,81 @@
+"""
+Test the lldb platform Python API.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class PlatformPythonTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @add_test_categories(['pyapi'])
+ @no_debug_info_test
+ def test_platform_list(self):
+ """Test SBDebugger::GetNumPlatforms() & GetPlatformAtIndex() API"""
+ # Verify the host platform is present by default.
+ initial_num_platforms = self.dbg.GetNumPlatforms()
+ self.assertGreater(initial_num_platforms, 0)
+ host_platform = self.dbg.GetPlatformAtIndex(0)
+ self.assertTrue(host_platform.IsValid() and
+ host_platform.GetName() == 'host',
+ 'The host platform is present')
+ # Select another platform and verify that the platform is added to
+ # the platform list.
+ platform_idx = self.dbg.GetNumAvailablePlatforms() - 1
+ if platform_idx < 1:
+ self.fail('No platforms other than host are available')
+ platform_data = self.dbg.GetAvailablePlatformInfoAtIndex(platform_idx)
+ platform_name = platform_data.GetValueForKey('name').GetStringValue(100)
+ self.assertNotEqual(platform_name, 'host')
+ self.dbg.SetCurrentPlatform(platform_name)
+ selected_platform = self.dbg.GetSelectedPlatform()
+ self.assertTrue(selected_platform.IsValid())
+ self.assertEqual(selected_platform.GetName(), platform_name)
+ self.assertEqual(self.dbg.GetNumPlatforms(), initial_num_platforms + 1)
+ platform_found = False
+ for platform_idx in range(self.dbg.GetNumPlatforms()):
+ platform = self.dbg.GetPlatformAtIndex(platform_idx)
+ if platform.GetName() == platform_name:
+ platform_found = True
+ break
+ self.assertTrue(platform_found)
+
+ @add_test_categories(['pyapi'])
+ @no_debug_info_test
+ def test_host_is_connected(self):
+ # We've already tested that this one IS the host platform.
+ host_platform = self.dbg.GetPlatformAtIndex(0)
+ self.assertTrue(host_platform.IsConnected(), "The host platform is always connected")
+
+
+ @add_test_categories(['pyapi'])
+ @no_debug_info_test
+ def test_available_platform_list(self):
+ """Test SBDebugger::GetNumAvailablePlatforms() and GetAvailablePlatformInfoAtIndex() API"""
+ num_platforms = self.dbg.GetNumAvailablePlatforms()
+ self.assertGreater(
+ num_platforms, 0,
+ 'There should be at least one platform available')
+
+ for i in range(num_platforms):
+ platform_data = self.dbg.GetAvailablePlatformInfoAtIndex(i)
+ name_data = platform_data.GetValueForKey('name')
+ desc_data = platform_data.GetValueForKey('description')
+ self.assertTrue(
+ name_data and name_data.IsValid(),
+ 'Platform has a name')
+ self.assertEqual(
+ name_data.GetType(), lldb.eStructuredDataTypeString,
+ 'Platform name is a string')
+ self.assertTrue(
+ desc_data and desc_data.IsValid(),
+ 'Platform has a description')
+ self.assertEqual(
+ desc_data.GetType(), lldb.eStructuredDataTypeString,
+ 'Platform description is a string')
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/Makefile
new file mode 100644
index 00000000000..b560876f24e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp
+
+EXE := TestProcess
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py
new file mode 100644
index 00000000000..102d6f92dd1
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py
@@ -0,0 +1,32 @@
+"""
+Test process list.
+"""
+
+
+
+import os
+import lldb
+import shutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ProcessListTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ @skipIfWindows # https://bugs.llvm.org/show_bug.cgi?id=43702
+ def test_process_list_with_args(self):
+ """Test process list show process args"""
+ self.build()
+ exe = self.getBuildArtifact("TestProcess")
+
+ # Spawn a new process
+ popen = self.spawnSubprocess(exe, args=["arg1", "--arg2", "arg3"])
+ self.addTearDownHook(self.cleanupSubprocesses)
+
+ self.expect("platform process list -v",
+ substrs=["TestProcess arg1 --arg2 arg3", str(popen.pid)])
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/main.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/main.cpp
new file mode 100644
index 00000000000..da43e60155e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/commands/platform/process/main.cpp
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+#include <chrono>
+#include <thread>
+
+int main(int argc, char const *argv[]) {
+ std::this_thread::sleep_for(std::chrono::seconds(30));
+ return 0;
+}