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 *
10import lldbutil
11
12class CommonShortSpellingsTestCase(TestBase):
13
14    mydir = os.path.join("functionalities", "abbreviation")
15
16    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
17    @dsym_test
18    def test_with_dsym (self):
19        self.buildDsym ()
20        self.run_abbrevs2 ()
21
22    @dwarf_test
23    def test_with_dwarf (self):
24        self.buildDwarf ()
25        self.run_abbrevs2 ()
26
27    def run_abbrevs2 (self):
28        exe = os.path.join (os.getcwd(), "a.out")
29        self.expect("file " + exe,
30                    patterns = [ "Current executable set to .*a.out.*" ])
31
32        # br s -> breakpoint set
33
34        match_object = lldbutil.run_break_set_command (self, "br s -n sum")
35        lldbutil.check_breakpoint_result (self, match_object, symbol_name='sum', symbol_match_exact=False, num_locations=1)
36
37        self.runCmd("settings set interpreter.expand-regex-aliases true")
38        self.addTearDownHook(
39            lambda: self.runCmd("settings set interpreter.expand-regex-aliases false"))
40
41        # disp -> display
42        self.expect("disp a",
43            startstr = "target stop-hook add -o")
44        self.expect("disp b",
45            startstr = "target stop-hook add -o")
46
47        # di/dis -> disassemble
48        self.expect("help di",
49            substrs = ["disassemble"])
50        self.expect("help dis",
51            substrs = ["disassemble"])
52
53        # ta st a -> target stop-hook add
54        self.expect("help ta st a",
55            substrs = ["target stop-hook add"])
56
57        # fr v -> frame variable
58        self.expect("help fr v",
59            substrs = ["frame variable"])
60
61        # ta st li -> target stop-hook list
62        self.expect("ta st li",
63            substrs = ["Hook: 1", "Hook: 2"])
64
65
66if __name__ == '__main__':
67    import atexit
68    lldb.SBDebugger.Initialize()
69    atexit.register(lambda: lldb.SBDebugger.Terminate())
70    unittest2.main()
71
72