Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / functionalities / tsan / multiple / TestTsanMultiple.py
blob6d844fc9b07346fdd1df7d01f480dff4a3e3b865
1 """
2 Test ThreadSanitizer when multiple different issues are found.
3 """
5 import lldb
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test.decorators import *
8 import lldbsuite.test.lldbutil as lldbutil
9 import json
12 class TsanMultipleTestCase(TestBase):
13 @expectedFailureAll(
14 oslist=["linux"],
15 bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)",
17 @expectedFailureNetBSD
18 @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
19 @skipIfRemote
20 @skipUnlessThreadSanitizer
21 @add_test_categories(["objc"])
22 def test(self):
23 self.build()
24 self.tsan_tests()
26 def tsan_tests(self):
27 exe = self.getBuildArtifact("a.out")
28 self.expect("file " + exe, patterns=["Current executable set to .*a.out"])
30 self.runCmd("env TSAN_OPTIONS=abort_on_error=0")
32 self.runCmd("run")
34 stop_reason = (
35 self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason()
37 if stop_reason == lldb.eStopReasonExec:
38 # On OS X 10.10 and older, we need to re-exec to enable
39 # interceptors.
40 self.runCmd("continue")
42 report_count = 0
43 while (
44 self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason()
45 == lldb.eStopReasonInstrumentation
47 report_count += 1
49 stop_description = (
50 self.dbg.GetSelectedTarget()
51 .process.GetSelectedThread()
52 .GetStopDescription(100)
55 self.assertTrue(
56 (stop_description == "Data race detected")
57 or (stop_description == "Use of deallocated memory detected")
58 or (stop_description == "Thread leak detected")
59 or (
60 stop_description
61 == "Use of an uninitialized or destroyed mutex detected"
63 or (
64 stop_description
65 == "Unlock of an unlocked mutex (or by a wrong thread) detected"
69 self.expect(
70 "thread info -s",
71 "The extended stop info should contain the TSan provided fields",
72 substrs=["instrumentation_class", "description", "mops"],
75 output_lines = self.res.GetOutput().split("\n")
76 json_line = "\n".join(output_lines[2:])
77 data = json.loads(json_line)
78 self.assertEqual(data["instrumentation_class"], "ThreadSanitizer")
80 backtraces = (
81 self.dbg.GetSelectedTarget()
82 .process.GetSelectedThread()
83 .GetStopReasonExtendedBacktraces(
84 lldb.eInstrumentationRuntimeTypeThreadSanitizer
87 self.assertTrue(backtraces.GetSize() >= 1)
89 self.runCmd("continue")
91 self.assertEqual(
92 self.dbg.GetSelectedTarget().process.GetState(),
93 lldb.eStateExited,
94 PROCESS_EXITED,