1"""
2Test handling of the situation where the main thread exits but the other threads
3in the process keep running.
4"""
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9import lldbsuite.test.lldbutil as lldbutil
10
11
12class ThreadExitTestCase(TestBase):
13    NO_DEBUG_INFO_TESTCASE = True
14
15    # Needs os-specific implementation in the inferior
16    @skipIf(oslist=no_match(["linux"]))
17    def test(self):
18        self.build()
19        lldbutil.run_to_source_breakpoint(self, "// break here",
20                lldb.SBFileSpec("main.cpp"))
21
22        # There should be one (non-main) thread left
23        self.assertEquals(self.process().GetNumThreads(), 1)
24
25        # Ensure we can evaluate_expressions in this state
26        self.expect_expr("call_me()", result_value="12345")
27
28        self.runCmd("continue")
29        self.assertEquals(self.process().GetExitStatus(), 47)
30