[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / commands / command / nested_alias / TestNestedAlias.py
blob0919caa7d0056dc5cdf6aa02e25b18011bcd4b18
1 """
2 Test that an alias can reference other aliases without crashing.
3 """
6 import lldb
7 from lldbsuite.test.lldbtest import *
8 import lldbsuite.test.lldbutil as lldbutil
11 class NestedAliasTestCase(TestBase):
12 NO_DEBUG_INFO_TESTCASE = True
14 def setUp(self):
15 # Call super's setUp().
16 TestBase.setUp(self)
17 # Find the line number to break inside main().
18 self.line = line_number("main.cpp", "// break here")
20 def test_nested_alias(self):
21 """Test that an alias can reference other aliases without crashing."""
22 self.build()
23 exe = self.getBuildArtifact("a.out")
24 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
26 # Break in main() after the variables are assigned values.
27 lldbutil.run_break_set_by_file_and_line(
28 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True
31 self.runCmd("run", RUN_SUCCEEDED)
33 # The stop reason of the thread should be breakpoint.
34 self.expect(
35 "thread list",
36 STOPPED_DUE_TO_BREAKPOINT,
37 substrs=["stopped", "stop reason = breakpoint"],
40 # The breakpoint should have a hit count of 1.
41 lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
43 # This is the function to remove the custom aliases in order to have a
44 # clean slate for the next test case.
45 def cleanup():
46 self.runCmd("command unalias read", check=False)
47 self.runCmd("command unalias rd", check=False)
48 self.runCmd("command unalias fo", check=False)
49 self.runCmd("command unalias foself", check=False)
50 self.runCmd("command unalias add_two", check=False)
51 self.runCmd("command unalias two", check=False)
53 # Execute the cleanup function during test case tear down.
54 self.addTearDownHook(cleanup)
56 self.runCmd("command alias read memory read -f A")
57 self.runCmd("command alias rd read -c 3")
59 self.expect(
60 "memory read -f A -c 3 `&my_ptr[0]`",
61 substrs=["deadbeef", "main.cpp:", "feedbeef"],
63 self.expect("rd `&my_ptr[0]`", substrs=["deadbeef", "main.cpp:", "feedbeef"])
65 self.expect(
66 "memory read -f A -c 3 `&my_ptr[0]`", substrs=["deadfeed"], matching=False
68 self.expect("rd `&my_ptr[0]`", substrs=["deadfeed"], matching=False)
70 self.runCmd("command alias fo frame variable -O --")
71 self.runCmd("command alias foself fo self")
73 self.expect(
74 "help foself",
75 substrs=["--show-all-children", "--raw-output"],
76 matching=False,
78 self.expect(
79 "help foself",
80 substrs=["Show variables for the current", "stack frame."],
81 matching=True,
84 # Check that foself was resolved and is now independent of 'fo'.
85 self.runCmd("command unalias fo")
86 self.expect(
87 "help foself",
88 substrs=["Show variables for the current", "stack frame."],
89 matching=True,
92 # Check that aliases can be created for raw input commands.
93 self.expect("command alias two expr -- 2")
94 self.expect("command alias add_two two +")
95 self.expect("add_two 3", patterns=[" = 5$"])
96 # Check that aliases to aliases to raw input commands work the second
97 # and subsequent times.
98 self.expect("add_two 3", patterns=[" = 5$"])
99 self.expect("add_two 3", patterns=[" = 5$"])