[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / commands / command / source / TestCommandSource.py
bloba65c3b80e3f498ffd69013058ffd2c7c4c999a9f
1 """
2 Test that lldb command "command source" works correctly.
3 """
6 import lldb
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
12 class CommandSourceTestCase(TestBase):
13 @no_debug_info_test
14 def test_command_source(self):
15 """Test that lldb command "command source" works correctly."""
17 # Sourcing .lldb in the current working directory, which in turn imports
18 # the "my" package that defines the date() function.
19 self.runCmd("command source .lldb")
20 self.check_results()
22 @no_debug_info_test
23 def test_command_source_relative(self):
24 """Test that lldb command "command source" works correctly with relative paths."""
26 # Sourcing .lldb in the current working directory, which in turn imports
27 # the "my" package that defines the date() function.
28 self.runCmd("command source commands2.txt")
29 self.check_results()
31 def check_results(self, failure=False):
32 # Python should evaluate "my.date()" successfully.
33 command_interpreter = self.dbg.GetCommandInterpreter()
34 self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
35 result = lldb.SBCommandReturnObject()
36 command_interpreter.HandleCommand("script my.date()", result)
38 import datetime
40 if failure:
41 self.expect(
42 result.GetOutput(),
43 "script my.date() runs successfully",
44 exe=False,
45 error=True,
47 else:
48 self.expect(
49 result.GetOutput(),
50 "script my.date() runs successfully",
51 exe=False,
52 substrs=[str(datetime.date.today())],
55 @no_debug_info_test
56 def test_command_source_relative_error(self):
57 """Test that 'command source -C' gives an error for a relative path"""
58 source_dir = self.getSourceDir()
59 result = lldb.SBCommandReturnObject()
60 self.runCmd("command source --stop-on-error 1 not-relative.txt")
61 self.check_results(failure=True)