xref: /llvm-project/lldb/test/API/commands/command/script_alias/TestCommandScriptAlias.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
199451b44SJordan Rupprecht"""
299451b44SJordan RupprechtTest lldb Python commands.
399451b44SJordan Rupprecht"""
499451b44SJordan Rupprecht
599451b44SJordan Rupprecht
699451b44SJordan Rupprechtimport lldb
799451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
899451b44SJordan Rupprecht
999451b44SJordan Rupprecht
1099451b44SJordan Rupprechtclass CommandScriptAliasTestCase(TestBase):
1199451b44SJordan Rupprecht    NO_DEBUG_INFO_TESTCASE = True
1299451b44SJordan Rupprecht
1399451b44SJordan Rupprecht    def test_pycmd(self):
1499451b44SJordan Rupprecht        self.runCmd("command script import tcsacmd.py")
1599451b44SJordan Rupprecht        self.runCmd("command script add -f tcsacmd.some_command_here attach")
1699451b44SJordan Rupprecht
1799451b44SJordan Rupprecht        # This is the function to remove the custom commands in order to have a
1899451b44SJordan Rupprecht        # clean slate for the next test case.
1999451b44SJordan Rupprecht        def cleanup():
20*2238dcc3SJonas Devlieghere            self.runCmd("command script delete attach", check=False)
2199451b44SJordan Rupprecht
2299451b44SJordan Rupprecht        # Execute the cleanup function during test case tear down.
2399451b44SJordan Rupprecht        self.addTearDownHook(cleanup)
2499451b44SJordan Rupprecht
2599451b44SJordan Rupprecht        # We don't want to display the stdout if not in TraceOn() mode.
2699451b44SJordan Rupprecht        if not self.TraceOn():
2799451b44SJordan Rupprecht            self.HideStdout()
2899451b44SJordan Rupprecht
29*2238dcc3SJonas Devlieghere        self.expect("attach a", substrs=["Victory is mine"])
3099451b44SJordan Rupprecht        self.runCmd("command script delete attach")
3199451b44SJordan Rupprecht        # this can't crash but we don't care whether the actual attach works
32*2238dcc3SJonas Devlieghere        self.runCmd("attach noprocessexistswiththisname", check=False)
33