]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/memory/cache/TestMemoryCache.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / memory / cache / TestMemoryCache.py
1 """
2 Test the MemoryCache L1 flush.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import re
11 import lldb
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 import lldbsuite.test.lldbutil as lldbutil
15
16
17 class MemoryCacheTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20
21     def setUp(self):
22         # Call super's setUp().
23         TestBase.setUp(self)
24         # Find the line number to break inside main().
25         self.line = line_number('main.cpp', '// Set break point at this line.')
26
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."""
30         self.build()
31         exe = os.path.join(os.getcwd(), "a.out")
32         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
33
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)
37
38         self.runCmd("run", RUN_SUCCEEDED)
39
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'])
43
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'])
47
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
50         # cache is used.
51         self.runCmd('memory read -f d -c 201 `&my_ints - 100`')
52
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))
56
57         # Change the value of my_ints[0] in memory.
58         self.runCmd("memory write -s 4 `&my_ints` AA")
59
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`')
63
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))