[Lldb-commits] [lldb] r369930 - TestFunctionStarts.py: add synchronization

Frederic Riss via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 26 10:14:05 PDT 2019


Author: friss
Date: Mon Aug 26 10:14:05 2019
New Revision: 369930

URL: http://llvm.org/viewvc/llvm-project?rev=369930&view=rev
Log:
TestFunctionStarts.py: add synchronization

We have started to see the no_binary version of this test
fail. The reason is that the binary was being removed
before the spawn actually launched the inferior. Add a
simple filesystem based synchronization to avoid this race.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/TestFunctionStarts.py
    lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/main.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/TestFunctionStarts.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/TestFunctionStarts.py?rev=369930&r1=369929&r2=369930&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/TestFunctionStarts.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/TestFunctionStarts.py Mon Aug 26 10:14:05 2019
@@ -43,8 +43,20 @@ class FunctionStartsTestCase(TestBase):
         except CalledProcessError as cmd_error:
             self.fail("Strip failed: %d"%(cmd_error.returncode))
 
-        popen = self.spawnSubprocess(exe)
+        # Use a file as a synchronization point between test and inferior.
+        pid_file_path = lldbutil.append_to_process_working_directory(self,
+            "token_pid_%d" % (int(os.getpid())))
+        self.addTearDownHook(
+            lambda: self.run_platform_command(
+                "rm %s" %
+                (pid_file_path)))
+
+        popen = self.spawnSubprocess(exe, [pid_file_path])
         self.addTearDownHook(self.cleanupSubprocesses)
+
+        # Wait until process has fully started up.
+        pid = lldbutil.wait_for_file_on_target(self, pid_file_path)
+
         if in_memory:
           remove_file(exe)            
 
@@ -68,7 +80,8 @@ class FunctionStartsTestCase(TestBase):
         thread = threads[0]
         self.assertTrue(thread.num_frames > 1, "Couldn't backtrace.")
         name = thread.frame[1].GetFunctionName()
-        self.assertEqual("___lldb_unnamed_symbol1$$StripMe", name, "Frame name not synthetic")
+        self.assertTrue(name.startswith("___lldb_unnamed_symbol"))
+        self.assertTrue(name.endswith("$$StripMe"))
         
 
         

Modified: lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/main.cpp?rev=369930&r1=369929&r2=369930&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/main.cpp (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/macosx/function-starts/main.cpp Mon Aug 26 10:14:05 2019
@@ -2,6 +2,7 @@
 #include <fcntl.h>
 
 #include <chrono>
+#include <fstream>
 #include <thread>
 
 extern void dont_strip_me()
@@ -21,6 +22,11 @@ static void *a_function()
 
 int main(int argc, char const *argv[])
 {
+    {
+        // Create file to signal that this process has started up.
+        std::ofstream f;
+        f.open(argv[1]);
+    }
     a_function();
     return 0;
 }




More information about the lldb-commits mailing list