xref: /llvm-project/lldb/test/API/commands/command/script_alias/TestCommandScriptAlias.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test lldb Python commands.
3"""
4
5
6import lldb
7from lldbsuite.test.lldbtest import *
8
9
10class CommandScriptAliasTestCase(TestBase):
11    NO_DEBUG_INFO_TESTCASE = True
12
13    def test_pycmd(self):
14        self.runCmd("command script import tcsacmd.py")
15        self.runCmd("command script add -f tcsacmd.some_command_here attach")
16
17        # This is the function to remove the custom commands in order to have a
18        # clean slate for the next test case.
19        def cleanup():
20            self.runCmd("command script delete attach", check=False)
21
22        # Execute the cleanup function during test case tear down.
23        self.addTearDownHook(cleanup)
24
25        # We don't want to display the stdout if not in TraceOn() mode.
26        if not self.TraceOn():
27            self.HideStdout()
28
29        self.expect("attach a", substrs=["Victory is mine"])
30        self.runCmd("command script delete attach")
31        # this can't crash but we don't care whether the actual attach works
32        self.runCmd("attach noprocessexistswiththisname", check=False)
33