2 Test the MemoryCache L1 flush.
5 from __future__ import print_function
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 import lldbsuite.test.lldbutil as lldbutil
17 class MemoryCacheTestCase(TestBase):
19 mydir = TestBase.compute_mydir(__file__)
22 # Call super's setUp().
24 # Find the line number to break inside main().
25 self.line = line_number('main.cpp', '// Set break point at this line.')
27 @expectedFlakeyOS(oslist=["windows"])
28 def test_memory_cache(self):
29 """Test the MemoryCache class with a sequence of 'memory read' and 'memory write' operations."""
31 exe = os.path.join(os.getcwd(), "a.out")
32 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
34 # Break in main() after the variables are assigned values.
35 lldbutil.run_break_set_by_file_and_line(
36 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
38 self.runCmd("run", RUN_SUCCEEDED)
40 # The stop reason of the thread should be breakpoint.
41 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
42 substrs=['stopped', 'stop reason = breakpoint'])
44 # The breakpoint should have a hit count of 1.
45 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
46 substrs=[' resolved, hit count = 1'])
48 # Read a chunk of memory containing &my_ints[0]. The number of bytes read
49 # must be greater than m_L2_cache_line_byte_size to make sure the L1
51 self.runCmd('memory read -f d -c 201 `&my_ints - 100`')
53 # Check the value of my_ints[0] is the same as set in main.cpp.
54 line = self.res.GetOutput().splitlines()[100]
55 self.assertTrue(0x00000042 == int(line.split(':')[1], 0))
57 # Change the value of my_ints[0] in memory.
58 self.runCmd("memory write -s 4 `&my_ints` AA")
60 # Re-read the chunk of memory. The cache line should have been
61 # flushed because of the 'memory write'.
62 self.runCmd('memory read -f d -c 201 `&my_ints - 100`')
64 # Check the value of my_ints[0] have been updated correctly.
65 line = self.res.GetOutput().splitlines()[100]
66 self.assertTrue(0x000000AA == int(line.split(':')[1], 0))