Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / gdb / mmap.py
1 # -*- python -*-
2 # Copyright (c) 2013 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import os
7
8 import gdb_test
9
10
11 class MmapTest(gdb_test.GdbTest):
12
13   def setUp(self):
14     os.environ['NACL_FAULT_INJECTION'] = (
15         'MMAP_BYPASS_DESCRIPTOR_SAFETY_CHECK=GF/@')
16     super(MmapTest, self).setUp()
17
18   def test_mmap(self):
19     self.gdb.Command('break mmap_breakpoint')
20     self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
21     self.gdb.ResumeAndExpectStop('finish', 'function-finished')
22     # Check that we can read from memory mapped files.
23     self.assertEquals(gdb_test.ParseNumber(self.gdb.Eval('*file_mapping')), 123)
24     self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
25     self.gdb.ResumeAndExpectStop('finish', 'function-finished')
26     file_mapping_str = self.gdb.Eval('file_mapping')
27     file_mapping = gdb_test.ParseNumber(file_mapping_str)
28     self.gdb.Command('break *' + file_mapping_str)
29     self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
30     # Check that breakpoint in memory mapped code is working.
31     self.assertEquals(self.gdb.GetPC(), file_mapping)
32     self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
33     self.gdb.ResumeAndExpectStop('finish', 'function-finished')
34     file_mapping_str = self.gdb.Eval('file_mapping')
35     file_mapping = gdb_test.ParseNumber(file_mapping_str)
36     self.gdb.Command('break *' + file_mapping_str)
37     self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
38     # Check that breakpoint in memory mapped code is working.
39     self.assertEquals(self.gdb.GetPC(), file_mapping)
40
41
42 if __name__ == '__main__':
43   gdb_test.Main()