summaryrefslogtreecommitdiffstats
path: root/lldb/test/tools/lldb-mi/TestMiExit.py
blob: e69edfe3d2886563a066a2a978491de9652d6aa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Test that the lldb-mi driver works properly with "-gdb-exit".
"""

import lldbmi_testcase
from lldbtest import *
import unittest2

class MiExitTestCase(lldbmi_testcase.MiTestCaseBase):

    @lldbmi_test
    @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
    @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
    @skipIfLinux # llvm.org/pr22411: Failure presumably due to known thread races
    def test_lldbmi_gdbexit(self):
        """Test that '-gdb-exit' terminates debug session and exits."""

        self.spawnLldbMi(args = None)

        # Load executable
        self.runCmd("-file-exec-and-symbols %s" % self.myexe)
        self.expect("\^done")

        # Run to main
        self.runCmd("-break-insert -f main")
        self.expect("\^done,bkpt={number=\"1\"")
        self.runCmd("-exec-run")
        self.expect("\^running")
        self.expect("\*stopped,reason=\"breakpoint-hit\"")

        # Test -gdb-exit: try to exit and check that program is finished
        self.runCmd("-gdb-exit")
        self.expect("\^exit")
        import pexpect
        self.expect(pexpect.EOF)

    @lldbmi_test
    @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
    @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
    @skipIfLinux # llvm.org/pr22411: Failure presumably due to known thread races
    def test_lldbmi_quit(self):
        """Test that 'quit' exits immediately."""

        self.spawnLldbMi(args = None)

        # Load executable
        self.runCmd("-file-exec-and-symbols %s" % self.myexe)
        self.expect("\^done")

        # Run to main
        self.runCmd("-break-insert -f main")
        self.expect("\^done,bkpt={number=\"1\"")
        self.runCmd("-exec-run")
        self.expect("\^running")
        self.expect("\*stopped,reason=\"breakpoint-hit\"")

        # Test quit: try to exit and check that program is finished
        self.runCmd("quit")
        import pexpect
        self.expect(pexpect.EOF)

if __name__ == '__main__':
    unittest2.main()
OpenPOWER on IntegriCloud