[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / commands / memory / write / TestMemoryWrite.py
blob45787243a614d1bfdb0c0b9019ead1295c6ce4fc
1 """
2 Test the 'memory write' command.
3 """
5 import lldb
6 import lldbsuite.test.lldbutil as lldbutil
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
12 class MemoryWriteTestCase(TestBase):
13 def setUp(self):
14 # Call super's setUp().
15 TestBase.setUp(self)
16 # Find the line number to break inside main().
17 self.line = line_number("main.c", "// Set break point at this line.")
19 def build_run_stop(self):
20 self.build()
21 exe = self.getBuildArtifact("a.out")
22 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
24 # Break in main() after the variables are assigned values.
25 lldbutil.run_break_set_by_file_and_line(
26 self, "main.c", self.line, num_expected_locations=1, loc_exact=True
29 self.runCmd("run", RUN_SUCCEEDED)
31 # The stop reason of the thread should be breakpoint.
32 self.expect(
33 "thread list",
34 STOPPED_DUE_TO_BREAKPOINT,
35 substrs=["stopped", "stop reason = breakpoint"],
38 # The breakpoint should have a hit count of 1.
39 lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
41 @no_debug_info_test
42 def test_memory_write(self):
43 """Test the 'memory write' command for writing values and file contents."""
44 self.build_run_stop()
46 self.expect(
47 "memory read --format c --size 7 --count 1 `&my_string`",
48 substrs=["abcdefg"],
51 self.expect("memory write --format c --size 7 `&my_string` ABCDEFG")
53 self.expect(
54 "memory read --format c --size 7 --count 1 `&my_string`",
55 substrs=["ABCDEFG"],
58 self.expect(
59 "memory write --infile file.txt --size 7 `&my_string`",
60 substrs=["7 bytes were written"],
63 self.expect(
64 "memory read --format c --size 7 --count 1 `&my_string`",
65 substrs=["abcdefg"],
68 self.expect(
69 "memory write --infile file.txt --size 7 `&my_string` ABCDEFG",
70 error=True,
71 substrs=[
72 "error: memory write takes only a destination address when writing file contents"
76 self.expect(
77 "memory write --infile file.txt --size 7",
78 error=True,
79 substrs=[
80 "error: memory write takes a destination address when writing file contents"
84 @no_debug_info_test
85 def test_memory_write_command_usage_syntax(self):
86 """Test that 'memory write' command usage syntax shows it does not take values when writing file contents."""
87 self.expect(
88 "help memory write",
89 substrs=[
90 "memory write [-f <format>] [-s <byte-size>] <address> <value> [<value> [...]]",
91 "memory write -i <filename> [-s <byte-size>] [-o <offset>] <address>",