xref: /llvm-project/lldb/test/API/functionalities/thread/main_thread_exit/TestMainThreadExit.py (revision 80fcecb13c388ff087a27a4b0e7ca3dd8c98eaa4)
14384c96fSPavel Labath"""
24384c96fSPavel LabathTest handling of the situation where the main thread exits but the other threads
34384c96fSPavel Labathin the process keep running.
44384c96fSPavel Labath"""
54384c96fSPavel Labath
64384c96fSPavel Labathimport lldb
74384c96fSPavel Labathfrom lldbsuite.test.decorators import *
84384c96fSPavel Labathfrom lldbsuite.test.lldbtest import *
94384c96fSPavel Labathimport lldbsuite.test.lldbutil as lldbutil
104384c96fSPavel Labath
114384c96fSPavel Labath
124384c96fSPavel Labathclass ThreadExitTestCase(TestBase):
134384c96fSPavel Labath    NO_DEBUG_INFO_TESTCASE = True
144384c96fSPavel Labath
154384c96fSPavel Labath    # Needs os-specific implementation in the inferior
164384c96fSPavel Labath    @skipIf(oslist=no_match(["linux"]))
174384c96fSPavel Labath    def test(self):
184384c96fSPavel Labath        self.build()
192238dcc3SJonas Devlieghere        lldbutil.run_to_source_breakpoint(
202238dcc3SJonas Devlieghere            self, "// break here", lldb.SBFileSpec("main.cpp")
212238dcc3SJonas Devlieghere        )
224384c96fSPavel Labath
234384c96fSPavel Labath        # There should be one (non-main) thread left
24*80fcecb1SJonas Devlieghere        self.assertEqual(self.process().GetNumThreads(), 1)
254384c96fSPavel Labath
264384c96fSPavel Labath        # Ensure we can evaluate_expressions in this state
274384c96fSPavel Labath        self.expect_expr("call_me()", result_value="12345")
284384c96fSPavel Labath
294384c96fSPavel Labath        self.runCmd("continue")
300165b73bSPavel Labath        # Exit code depends on the version of the linux kernel
310165b73bSPavel Labath        self.assertIn(self.process().GetExitStatus(), [42, 47])
32