[Lldb-commits] [lldb] [lldb][AIX] get host info for AIX (cont..) (PR #138687)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue May 27 07:43:00 PDT 2025


================
@@ -90,6 +92,30 @@ TEST(Host, LaunchProcessSetsArgv0) {
   ASSERT_THAT(exit_status.get_future().get(), 0);
 }
 
+TEST(Host, FindProcesses) {
+  SubsystemRAII<FileSystem, HostInfo> subsystems;
+
+  if (test_arg != 0)
+    exit(0);
+
+  ProcessLaunchInfo info;
+  ProcessInstanceInfoList processes;
+  ProcessInstanceInfoMatch match(TestMainArgv0, NameMatch::Equals);
+  info.SetExecutableFile(FileSpec(TestMainArgv0),
+                         /*add_exe_file_as_first_arg=*/true);
+  info.GetArguments().AppendArgument("--gtest_filter=Host.FindProcesses");
+  info.GetArguments().AppendArgument("--test-arg=48");
+  std::promise<int> exit_status;
+  info.SetMonitorProcessCallback([&](lldb::pid_t pid, int signal, int status) {
+    exit_status.set_value(status);
+  });
+  ASSERT_THAT_ERROR(Host::LaunchProcess(info).takeError(), Succeeded());
+  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+  ASSERT_TRUE(Host::FindProcesses(match, processes));
+  ASSERT_EQ(processes[0].GetArg0(), TestMainArgv0);
----------------
labath wrote:

Find the process in the list (in theory, this could find more than one instance) with the expected PID, and then check that it's GetExecutableFile() matches the one from the launch info (better not check for argv0, as not all implementations may be able to obtain that).

https://github.com/llvm/llvm-project/pull/138687


More information about the lldb-commits mailing list