summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2023-05-25 08:48:57 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2023-05-25 12:54:09 -0700
commit2238dcc39358353cac21df75c3c3286ab20b8f53 (patch)
tree1bb7ec8d7405ccd7fdb5a8a78d0cf5ef40bcc963 /lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
parentdaeee56798c51e8f007e8e8e6e677a420b14c9ef (diff)
[NFC][Py Reformat] Reformat python files in lldb
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black` (23.1.0). If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run `git checkout --ours <yourfile>` and then reformat it with black. RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Differential revision: https://reviews.llvm.org/D151460
Diffstat (limited to 'lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py')
-rw-r--r--lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py98
1 files changed, 62 insertions, 36 deletions
diff --git a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
index c778a556f9fa..9ec49d0069a6 100644
--- a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
+++ b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
@@ -3,7 +3,6 @@ Test that the Python operating system plugin works correctly
"""
-
import os
import lldb
from lldbsuite.test.lldbtest import *
@@ -29,8 +28,10 @@ class PluginPythonOSPlugin(TestBase):
reg_value = thread.GetThreadID() + 1
for reg in registers:
self.assertEqual(
- reg.GetValueAsUnsigned(), reg_value,
- "Verify the registers contains the correct value")
+ reg.GetValueAsUnsigned(),
+ reg_value,
+ "Verify the registers contains the correct value",
+ )
reg_value = reg_value + 1
def run_python_os_funcionality(self):
@@ -41,8 +42,7 @@ class PluginPythonOSPlugin(TestBase):
# Create a target by the debugger.
exe = self.getBuildArtifact("a.out")
- python_os_plugin_path = os.path.join(self.getSourceDir(),
- "operating_system.py")
+ python_os_plugin_path = os.path.join(self.getSourceDir(), "operating_system.py")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
@@ -57,7 +57,8 @@ class PluginPythonOSPlugin(TestBase):
# Now launch the process, and do not stop at entry point.
process = target.LaunchSimple(
- arguments, environment, self.get_process_working_directory())
+ arguments, environment, self.get_process_working_directory()
+ )
self.assertTrue(process, PROCESS_IS_VALID)
# Make sure there are no OS plug-in created thread when we first stop
@@ -65,57 +66,68 @@ class PluginPythonOSPlugin(TestBase):
thread = process.GetThreadByID(0x111111111)
self.assertFalse(
thread.IsValid(),
- "Make sure there is no thread 0x111111111 before we load the python OS plug-in")
+ "Make sure there is no thread 0x111111111 before we load the python OS plug-in",
+ )
thread = process.GetThreadByID(0x222222222)
self.assertFalse(
thread.IsValid(),
- "Make sure there is no thread 0x222222222 before we load the python OS plug-in")
+ "Make sure there is no thread 0x222222222 before we load the python OS plug-in",
+ )
thread = process.GetThreadByID(0x333333333)
self.assertFalse(
thread.IsValid(),
- "Make sure there is no thread 0x333333333 before we load the python OS plug-in")
+ "Make sure there is no thread 0x333333333 before we load the python OS plug-in",
+ )
# Now load the python OS plug-in which should update the thread list and we should have
# OS plug-in created threads with the IDs: 0x111111111, 0x222222222,
# 0x333333333
- command = "settings set target.process.python-os-plugin-path '%s'" % python_os_plugin_path
+ command = (
+ "settings set target.process.python-os-plugin-path '%s'"
+ % python_os_plugin_path
+ )
self.dbg.HandleCommand(command)
# Verify our OS plug-in threads showed up
thread = process.GetThreadByID(0x111111111)
self.assertTrue(
thread.IsValid(),
- "Make sure there is a thread 0x111111111 after we load the python OS plug-in")
+ "Make sure there is a thread 0x111111111 after we load the python OS plug-in",
+ )
self.verify_os_thread_registers(thread)
thread = process.GetThreadByID(0x222222222)
self.assertTrue(
thread.IsValid(),
- "Make sure there is a thread 0x222222222 after we load the python OS plug-in")
+ "Make sure there is a thread 0x222222222 after we load the python OS plug-in",
+ )
self.verify_os_thread_registers(thread)
thread = process.GetThreadByID(0x333333333)
self.assertTrue(
thread.IsValid(),
- "Make sure there is a thread 0x333333333 after we load the python OS plug-in")
+ "Make sure there is a thread 0x333333333 after we load the python OS plug-in",
+ )
self.verify_os_thread_registers(thread)
# Now clear the OS plug-in path to make the OS plug-in created threads
# disappear
- self.dbg.HandleCommand(
- "settings clear target.process.python-os-plugin-path")
+ self.dbg.HandleCommand("settings clear target.process.python-os-plugin-path")
# Verify the threads are gone after unloading the python OS plug-in
thread = process.GetThreadByID(0x111111111)
self.assertFalse(
thread.IsValid(),
- "Make sure there is no thread 0x111111111 after we unload the python OS plug-in")
+ "Make sure there is no thread 0x111111111 after we unload the python OS plug-in",
+ )
thread = process.GetThreadByID(0x222222222)
self.assertFalse(
thread.IsValid(),
- "Make sure there is no thread 0x222222222 after we unload the python OS plug-in")
+ "Make sure there is no thread 0x222222222 after we unload the python OS plug-in",
+ )
thread = process.GetThreadByID(0x333333333)
self.assertFalse(
thread.IsValid(),
- "Make sure there is no thread 0x333333333 after we unload the python OS plug-in")
+ "Make sure there is no thread 0x333333333 after we unload the python OS plug-in",
+ )
def run_python_os_step(self):
"""Test that the Python operating system plugin works correctly and allows single stepping of a virtual thread that is backed by a real thread"""
@@ -125,8 +137,9 @@ class PluginPythonOSPlugin(TestBase):
# Create a target by the debugger.
exe = self.getBuildArtifact("a.out")
- python_os_plugin_path = os.path.join(self.getSourceDir(),
- "operating_system2.py")
+ python_os_plugin_path = os.path.join(
+ self.getSourceDir(), "operating_system2.py"
+ )
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
@@ -141,7 +154,8 @@ class PluginPythonOSPlugin(TestBase):
# Now launch the process, and do not stop at entry point.
process = target.LaunchSimple(
- arguments, environment, self.get_process_working_directory())
+ arguments, environment, self.get_process_working_directory()
+ )
self.assertTrue(process, PROCESS_IS_VALID)
# Make sure there are no OS plug-in created thread when we first stop
@@ -149,32 +163,39 @@ class PluginPythonOSPlugin(TestBase):
thread = process.GetThreadByID(0x111111111)
self.assertFalse(
thread.IsValid(),
- "Make sure there is no thread 0x111111111 before we load the python OS plug-in")
+ "Make sure there is no thread 0x111111111 before we load the python OS plug-in",
+ )
# Now load the python OS plug-in which should update the thread list and we should have
# OS plug-in created threads with the IDs: 0x111111111, 0x222222222,
# 0x333333333
- command = "settings set target.process.python-os-plugin-path '%s'" % python_os_plugin_path
+ command = (
+ "settings set target.process.python-os-plugin-path '%s'"
+ % python_os_plugin_path
+ )
self.dbg.HandleCommand(command)
# Verify our OS plug-in threads showed up
thread = process.GetThreadByID(0x111111111)
self.assertTrue(
thread.IsValid(),
- "Make sure there is a thread 0x111111111 after we load the python OS plug-in")
+ "Make sure there is a thread 0x111111111 after we load the python OS plug-in",
+ )
frame = thread.GetFrameAtIndex(0)
self.assertTrue(
- frame.IsValid(),
- "Make sure we get a frame from thread 0x111111111")
+ frame.IsValid(), "Make sure we get a frame from thread 0x111111111"
+ )
line_entry = frame.GetLineEntry()
self.assertEqual(
- line_entry.GetFileSpec().GetFilename(), 'main.c',
- "Make sure we stopped on line 5 in main.c")
+ line_entry.GetFileSpec().GetFilename(),
+ "main.c",
+ "Make sure we stopped on line 5 in main.c",
+ )
self.assertEqual(
- line_entry.GetLine(), 5,
- "Make sure we stopped on line 5 in main.c")
+ line_entry.GetLine(), 5, "Make sure we stopped on line 5 in main.c"
+ )
# Now single step thread 0x111111111 and make sure it does what we need
# it to
@@ -182,12 +203,17 @@ class PluginPythonOSPlugin(TestBase):
frame = thread.GetFrameAtIndex(0)
self.assertTrue(
- frame.IsValid(),
- "Make sure we get a frame from thread 0x111111111")
+ frame.IsValid(), "Make sure we get a frame from thread 0x111111111"
+ )
line_entry = frame.GetLineEntry()
self.assertEqual(
- line_entry.GetFileSpec().GetFilename(), 'main.c',
- "Make sure we stepped from line 5 to line 6 in main.c")
- self.assertEquals(line_entry.GetLine(), 6,
- "Make sure we stepped from line 5 to line 6 in main.c")
+ line_entry.GetFileSpec().GetFilename(),
+ "main.c",
+ "Make sure we stepped from line 5 to line 6 in main.c",
+ )
+ self.assertEquals(
+ line_entry.GetLine(),
+ 6,
+ "Make sure we stepped from line 5 to line 6 in main.c",
+ )