1"""
2Test lldb breakpoint ids.
3"""
4
5
6
7import lldb
8from lldbsuite.test.lldbtest import *
9import lldbsuite.test.lldbutil as lldbutil
10
11
12class BreakpointIDTestCase(TestBase):
13
14    def test(self):
15        self.build()
16
17        exe = self.getBuildArtifact("a.out")
18        self.expect("file " + exe,
19                    patterns=["Current executable set to .*a.out"])
20
21        bpno = lldbutil.run_break_set_by_symbol(
22            self, 'product', num_expected_locations=-1, sym_exact=False)
23        self.assertEquals(bpno, 1, "First breakpoint number is 1.")
24
25        bpno = lldbutil.run_break_set_by_symbol(
26            self, 'sum', num_expected_locations=-1, sym_exact=False)
27        self.assertEquals(bpno, 2, "Second breakpoint number is 2.")
28
29        bpno = lldbutil.run_break_set_by_symbol(
30            self, 'junk', num_expected_locations=0, sym_exact=False)
31        self.assertEquals(bpno, 3, "Third breakpoint number is 3.")
32
33        self.expect(
34            "breakpoint disable 1.1 - 2.2 ",
35            COMMAND_FAILED_AS_EXPECTED,
36            error=True,
37            startstr="error: Invalid range: Ranges that specify particular breakpoint locations must be within the same major breakpoint; you specified two different major breakpoints, 1 and 2.")
38
39        self.expect(
40            "breakpoint disable 2 - 2.2",
41            COMMAND_FAILED_AS_EXPECTED,
42            error=True,
43            startstr="error: Invalid breakpoint id range:  Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.")
44
45        self.expect(
46            "breakpoint disable 2.1 - 2",
47            COMMAND_FAILED_AS_EXPECTED,
48            error=True,
49            startstr="error: Invalid breakpoint id range:  Either both ends of range must specify a breakpoint location, or neither can specify a breakpoint location.")
50
51        self.expect("breakpoint disable 2.1 - 2.2",
52                    startstr="2 breakpoints disabled.")
53
54        self.expect("breakpoint enable 2.*",
55                    patterns=[".* breakpoints enabled."])
56