forked from OSchip/llvm-project
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. llvm-svn: 369930
This commit is contained in:
parent
2511b5a463
commit
7305397a14
|
@ -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"))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue