================
@@ -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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to