xref: /llvm-project/lldb/test/API/driver/job_control/TestJobControl.py (revision 1b70580dd867195b0442e582eccd42abc41ee12d)
1"""
2Test lldb's handling of job control signals (SIGTSTP, SIGCONT).
3"""
4
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test.lldbpexpect import PExpectTest
8
9
10class JobControlTest(PExpectTest):
11    @skipIf(macos_version=["<", "14.0"], asan=True)
12    @skipIf(oslist=["linux"], archs=["arm", "aarch64"])
13    def test_job_control(self):
14        def post_spawn():
15            self.child.expect("PID=([0-9]+)")
16            self.lldb_pid = int(self.child.match[1])
17
18        run_under = [sys.executable, self.getSourcePath("shell.py")]
19        self.launch(run_under=run_under, post_spawn=post_spawn)
20
21        os.kill(self.lldb_pid, signal.SIGTSTP)
22        self.child.expect("STATUS=([0-9]+)")
23        status = int(self.child.match[1])
24
25        self.assertTrue(os.WIFSTOPPED(status))
26        self.assertEqual(os.WSTOPSIG(status), signal.SIGTSTP)
27
28        os.kill(self.lldb_pid, signal.SIGCONT)
29
30        self.child.sendline("quit")
31        self.child.expect("RETURNCODE=0")
32