diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
commit | ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (patch) | |
tree | 27916256fdeeb57d10d2f3d6948be5d71a703215 /packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py | |
parent | 76e0736e7fcfeb179779e49c05604464b1ccd704 (diff) |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py')
-rw-r--r-- | packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py b/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py index 1009536b3709b..065c707448909 100644 --- a/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py +++ b/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py @@ -325,3 +325,79 @@ 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 basic 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") + + # Additional process info varies by platform, so just check that + # whatever info was retrieved is consistent and nothing blows up. + if process_info.UserIDIsValid(): + self.assertNotEqual( + process_info.GetUserID(), lldb.UINT32_MAX, + "Process user ID is valid") + else: + self.assertEqual( + process_info.GetUserID(), lldb.UINT32_MAX, + "Process user ID is invalid") + + if process_info.GroupIDIsValid(): + self.assertNotEqual( + process_info.GetGroupID(), lldb.UINT32_MAX, + "Process group ID is valid") + else: + self.assertEqual( + process_info.GetGroupID(), lldb.UINT32_MAX, + "Process group ID is invalid") + + if process_info.EffectiveUserIDIsValid(): + self.assertNotEqual( + process_info.GetEffectiveUserID(), lldb.UINT32_MAX, + "Process effective user ID is valid") + else: + self.assertEqual( + process_info.GetEffectiveUserID(), lldb.UINT32_MAX, + "Process effective user ID is invalid") + + if process_info.EffectiveGroupIDIsValid(): + self.assertNotEqual( + process_info.GetEffectiveGroupID(), lldb.UINT32_MAX, + "Process effective group ID is valid") + else: + self.assertEqual( + process_info.GetEffectiveGroupID(), lldb.UINT32_MAX, + "Process effective group ID is invalid") + + process_info.GetParentProcessID() |