TestCommonShortSpellings.py revision 473481bea9ca860c37015943ac831bc341557e1f
1"""
2Test some lldb command abbreviations to make sure the common short spellings of
3many commands remain available even after we add/delte commands in the future.
4"""
5
6import os, time
7import unittest2
8import lldb
9from lldbtest import *
10
11class CommonShortSpellingsTestCase(TestBase):
12
13    mydir = os.path.join("functionalities", "abbreviation")
14
15    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
16    @dsym_test
17    def test_with_dsym (self):
18        self.buildDsym ()
19        self.run_abbrevs2 ()
20
21    @dwarf_test
22    def test_with_dwarf (self):
23        self.buildDwarf ()
24        self.run_abbrevs2 ()
25
26    def run_abbrevs2 (self):
27        exe = os.path.join (os.getcwd(), "a.out")
28        self.expect("file " + exe,
29                    patterns = [ "Current executable set to .*a.out.*" ])
30
31        # br s -> breakpoint set
32        self.expect("br s -n sum",
33            startstr = "Breakpoint created: 1: name = 'sum', locations = 1")
34
35        self.runCmd("settings set interpreter.expand-regex-aliases true")
36        self.addTearDownHook(
37            lambda: self.runCmd("settings set interpreter.expand-regex-aliases false"))
38
39        # disp -> display
40        self.expect("disp a",
41            startstr = "target stop-hook add -o")
42        self.expect("disp b",
43            startstr = "target stop-hook add -o")
44
45        # di/dis -> disassemble
46        self.expect("help di",
47            substrs = ["disassemble"])
48        self.expect("help dis",
49            substrs = ["disassemble"])
50
51        # ta st a -> target stop-hook add
52        self.expect("help ta st a",
53            substrs = ["target stop-hook add"])
54
55        # fr v -> frame variable
56        self.expect("help fr v",
57            substrs = ["frame variable"])
58
59        # ta st li -> target stop-hook list
60        self.expect("ta st li",
61            substrs = ["Hook: 1", "Hook: 2"])
62
63
64if __name__ == '__main__':
65    import atexit
66    lldb.SBDebugger.Initialize()
67    atexit.register(lambda: lldb.SBDebugger.Terminate())
68    unittest2.main()
69
70