summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2023-01-10 16:28:25 -0800
committerMed Ismail Bennani <medismail.bennani@gmail.com>2023-01-12 19:20:51 -0800
commit8f549c5329275293ced1d5eb87a1cf8b3d52a794 (patch)
treecadf4424fc5af20033bfe1f5b2c313b479f3aca8 /lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
parente3930e77fc5b626a3c6b95f08ed25a3f8807c579 (diff)
[lldb/test] Fix data racing issue in TestStackCoreScriptedProcess
This patch should fix an nondeterministic error in TestStackCoreScriptedProcess. In order to test both the multithreading capability and shared library loading in Scripted Processes, the test would create multiple threads that would take the same variable as a reference. The first thread would alter the value and the second thread would monitor the value until it gets altered. This assumed a certain ordering regarding the `std::thread` spawning, however the ordering was not always guaranteed at runtime. To fix that, the test now makes use of a `std::condition_variable` shared between the each thread. On the former, it will notify the other thread when the variable gets initialized or updated and on the latter, it will wait until the variable it receives a new notification. This should fix the data racing issue while preserving the testing coverage. rdar://98678134 Differential Revision: https://reviews.llvm.org/D139484 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py')
-rw-r--r--lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py b/lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
index 7a6a7ddb4b77..8555faf67226 100644
--- a/lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
+++ b/lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
@@ -17,7 +17,7 @@ class StackCoreScriptedProcesTestCase(TestBase):
def create_stack_skinny_corefile(self, file):
self.build()
target, process, thread, _ = lldbutil.run_to_source_breakpoint(self, "// break here",
- lldb.SBFileSpec("baz.c"))
+ lldb.SBFileSpec("baz.cpp"))
self.assertTrue(process.IsValid(), "Process is invalid.")
# FIXME: Use SBAPI to save the process corefile.
self.runCmd("process save-core -s stack " + file)
@@ -109,9 +109,9 @@ class StackCoreScriptedProcesTestCase(TestBase):
self.assertTrue(func, "Invalid function.")
self.assertIn("baz", frame.GetFunctionName())
- self.assertEqual(frame.vars.GetSize(), 2)
- self.assertEqual(int(frame.vars.GetFirstValueByName('j').GetValue()), 42 * 42)
+ self.assertGreater(frame.vars.GetSize(), 0)
self.assertEqual(int(frame.vars.GetFirstValueByName('k').GetValue()), 42)
+ self.assertEqual(int(frame.vars.GetFirstValueByName('j').Dereference().GetValue()), 42 * 42)
corefile_dylib = self.get_module_with_name(corefile_target, 'libbaz.dylib')
self.assertTrue(corefile_dylib, "Dynamic library libbaz.dylib not found.")