1""" 2Tests ThreadSanitizer's support to detect a leaked thread. 3""" 4 5import lldb 6from lldbsuite.test.lldbtest import * 7from lldbsuite.test.decorators import * 8import lldbsuite.test.lldbutil as lldbutil 9 10 11class TsanThreadLeakTestCase(TestBase): 12 13 mydir = TestBase.compute_mydir(__file__) 14 15 @expectedFailureAll( 16 oslist=["linux"], 17 bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)") 18 @expectedFailureNetBSD 19 @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default 20 @skipIfRemote 21 @skipUnlessThreadSanitizer 22 def test(self): 23 self.build() 24 self.tsan_tests() 25 26 def tsan_tests(self): 27 exe = self.getBuildArtifact("a.out") 28 self.expect( 29 "file " + exe, 30 patterns=["Current executable set to .*a.out"]) 31 32 self.runCmd("run") 33 34 stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() 35 if stop_reason == lldb.eStopReasonExec: 36 # On OS X 10.10 and older, we need to re-exec to enable 37 # interceptors. 38 self.runCmd("continue") 39 40 # the stop reason of the thread should be breakpoint. 41 self.expect("thread list", "A thread leak should be detected", 42 substrs=['stopped', 'stop reason = Thread leak detected']) 43 44 self.assertEqual( 45 self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(), 46 lldb.eStopReasonInstrumentation) 47