2 Tests that TSan and LLDB have correct thread numbers.
6 from lldbsuite
.test
.lldbtest
import *
7 from lldbsuite
.test
.decorators
import *
8 import lldbsuite
.test
.lldbutil
as lldbutil
12 class TsanThreadNumbersTestCase(TestBase
):
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
20 @skipUnlessThreadSanitizer
26 exe
= self
.getBuildArtifact("a.out")
27 self
.expect("file " + exe
, patterns
=["Current executable set to .*a.out"])
32 self
.dbg
.GetSelectedTarget().process
.GetSelectedThread().GetStopReason()
34 if stop_reason
== lldb
.eStopReasonExec
:
35 # On OS X 10.10 and older, we need to re-exec to enable
37 self
.runCmd("continue")
39 # the stop reason of the thread should be breakpoint.
42 "A data race should be detected",
43 substrs
=["stopped", "stop reason = Data race detected"],
47 self
.dbg
.GetSelectedTarget().process
.GetSelectedThread().GetStopReason(),
48 lldb
.eStopReasonInstrumentation
,
52 self
.dbg
.GetSelectedTarget().process
.GetSelectedThread().GetIndexID()
57 "The extended stop info should contain the TSan provided fields",
58 substrs
=["instrumentation_class", "description", "mops"],
61 output_lines
= self
.res
.GetOutput().split("\n")
62 json_line
= "\n".join(output_lines
[2:])
63 data
= json
.loads(json_line
)
64 self
.assertEqual(data
["instrumentation_class"], "ThreadSanitizer")
65 self
.assertEqual(data
["issue_type"], "data-race")
66 self
.assertEqual(len(data
["mops"]), 2)
68 self
.assertEqual(data
["mops"][0]["thread_id"], report_thread_id
)
70 other_thread_id
= data
["mops"][1]["thread_id"]
71 self
.assertNotEqual(other_thread_id
, report_thread_id
)
72 other_thread
= self
.dbg
.GetSelectedTarget().process
.GetThreadByIndexID(
75 self
.assertTrue(other_thread
.IsValid())
77 self
.runCmd("thread select %d" % other_thread_id
)
81 "The other thread should be stopped in f1 or f2",
82 substrs
=["a.out", "main.c"],