summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/python_api/process
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/python_api/process')
-rw-r--r--lldb/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py
index 1009536b370..bffbf431587 100644
--- a/lldb/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py
+++ b/lldb/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py
@@ -325,3 +325,66 @@ class ProcessAPITestCase(TestBase):
num = process.GetNumSupportedHardwareWatchpoints(error)
if self.TraceOn() and error.Success():
print("Number of supported hardware watchpoints: %d" % num)
+
+ @add_test_categories(['pyapi'])
+ @no_debug_info_test
+ def test_get_process_info(self):
+ """Test SBProcess::GetProcessInfo() API with a locally launched process."""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Launch the process and stop at the entry point.
+ launch_info = lldb.SBLaunchInfo(None)
+ launch_info.SetWorkingDirectory(self.get_process_working_directory())
+ launch_flags = launch_info.GetLaunchFlags()
+ launch_flags |= lldb.eLaunchFlagStopAtEntry
+ launch_info.SetLaunchFlags(launch_flags)
+ error = lldb.SBError()
+ process = target.Launch(launch_info, error)
+
+ if not error.Success():
+ self.fail("Failed to launch process")
+
+ # Verify all process info can be retrieved successfully
+ process_info = process.GetProcessInfo()
+ self.assertTrue(process_info.IsValid())
+ file_spec = process_info.GetExecutableFile()
+ self.assertTrue(file_spec.IsValid())
+ process_name = process_info.GetName()
+ self.assertIsNotNone(process_name, "Process has a name")
+ self.assertGreater(len(process_name), 0, "Process name isn't blank")
+ self.assertEqual(file_spec.GetFilename(), "a.out")
+ self.assertNotEqual(
+ process_info.GetProcessID(), lldb.LLDB_INVALID_PROCESS_ID,
+ "Process ID is valid")
+
+ if self.getPlatform() != 'windows':
+ self.assertTrue(process_info.UserIDIsValid())
+ self.assertNotEqual(
+ process_info.GetUserID(), lldb.UINT32_MAX,
+ "Process user ID is valid")
+ self.assertTrue(process_info.GroupIDIsValid())
+ self.assertNotEqual(
+ process_info.GetGroupID(), lldb.UINT32_MAX,
+ "Process group ID is valid")
+ self.assertTrue(process_info.EffectiveUserIDIsValid())
+ self.assertNotEqual(
+ process_info.GetEffectiveUserID(), lldb.UINT32_MAX,
+ "Process effective user ID is valid")
+ self.assertTrue(process_info.EffectiveGroupIDIsValid())
+ self.assertNotEqual(
+ process_info.GetEffectiveGroupID(), lldb.UINT32_MAX,
+ "Process effective group ID is valid")
+ self.assertNotEqual(
+ process_info.GetParentProcessID(), lldb.LLDB_INVALID_PROCESS_ID,
+ "Parent process ID is valid"
+ )
+
+ # Verify that a dead process doesn't yield stale process info
+ process.Kill()
+ process_info = process.GetProcessInfo()
+ self.assertFalse(process_info.IsValid())
OpenPOWER on IntegriCloud