aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/ambigous_commands/TestAmbiguousCommands.py
blob: 14c66fefea7efda8586dc3ed6f5b04cd5f299a10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Test how lldb reacts to ambiguous commands
"""

import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class AmbiguousCommandTestCase(TestBase):
    @no_debug_info_test
    def test_ambiguous_command_with_alias(self):
        command_interpreter = self.dbg.GetCommandInterpreter()
        self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
        result = lldb.SBCommandReturnObject()

        command_interpreter.HandleCommand(
            "command alias corefile target create -c %0", result
        )
        self.assertTrue(result.Succeeded())

        command_interpreter.ResolveCommand("co", result)
        self.assertFalse(result.Succeeded())
        self.assertEqual(
            result.GetError(),
            "Ambiguous command 'co'. Possible matches:\n\tcommand\n\tcontinue\n\tcorefile\n",
        )

        command_interpreter.HandleCommand("command unalias continue", result)
        self.assertTrue(result.Succeeded())

        command_interpreter.ResolveCommand("co", result)
        self.assertTrue(result.Succeeded())
        self.assertEqual(result.GetOutput(), "target create -c %0")