[Lldb-commits] [lldb] b53641c - [lldb] Fix flakyness in TestProcessList

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 1 07:05:28 PDT 2022


Author: Pavel Labath
Date: 2022-08-01T16:05:01+02:00
New Revision: b53641cb72acae8973a16c4f5567885bd3fe85c0

URL: https://github.com/llvm/llvm-project/commit/b53641cb72acae8973a16c4f5567885bd3fe85c0
DIFF: https://github.com/llvm/llvm-project/commit/b53641cb72acae8973a16c4f5567885bd3fe85c0.diff

LOG: [lldb] Fix flakyness in TestProcessList

If the test is too fast it can read the process list before the forked
child process actually manages to exec the process with the right
arguments.

Use our file-based synchronization primitives to ensure the child is
up-and-running before we fetch the process list.

Added: 
    

Modified: 
    lldb/test/API/commands/platform/process/list/TestProcessList.py
    lldb/test/API/commands/platform/process/list/main.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/commands/platform/process/list/TestProcessList.py b/lldb/test/API/commands/platform/process/list/TestProcessList.py
index 5daf5dc49b52a..683b62e56e171 100644
--- a/lldb/test/API/commands/platform/process/list/TestProcessList.py
+++ b/lldb/test/API/commands/platform/process/list/TestProcessList.py
@@ -23,8 +23,10 @@ def test_process_list_with_args(self):
         exe = self.getBuildArtifact("TestProcess")
 
         # Spawn a new process
-        popen = self.spawnSubprocess(exe, args=["arg1", "--arg2", "arg3"])
-
-        substrs = [str(popen.pid), "TestProcess arg1 --arg2 arg3"]
+        sync_file = lldbutil.append_to_process_working_directory(self,
+                "ready.txt")
+        popen = self.spawnSubprocess(exe, args=[sync_file, "arg1", "--arg2", "arg3"])
+        lldbutil.wait_for_file_on_target(self, sync_file)
 
+        substrs = [str(popen.pid), "TestProcess", "arg1 --arg2 arg3"]
         self.expect("platform process list -v", substrs=substrs)

diff  --git a/lldb/test/API/commands/platform/process/list/main.cpp b/lldb/test/API/commands/platform/process/list/main.cpp
index da43e60155ea0..955f6e4382d20 100644
--- a/lldb/test/API/commands/platform/process/list/main.cpp
+++ b/lldb/test/API/commands/platform/process/list/main.cpp
@@ -1,9 +1,9 @@
-#include <stdio.h>
-
 #include <chrono>
+#include <fstream>
 #include <thread>
 
 int main(int argc, char const *argv[]) {
+  std::ofstream(argv[1]).close();
   std::this_thread::sleep_for(std::chrono::seconds(30));
   return 0;
 }


        


More information about the lldb-commits mailing list