Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / gdb / mmap.py
index 2ec3cec..081af36 100644 (file)
@@ -3,36 +3,41 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-from gdb_test import AssertEquals
-import gdb_test
 import os
 
+import gdb_test
+
+
+class MmapTest(gdb_test.GdbTest):
+
+  def setUp(self):
+    os.environ['NACL_FAULT_INJECTION'] = (
+        'MMAP_BYPASS_DESCRIPTOR_SAFETY_CHECK=GF/@')
+    super(MmapTest, self).setUp()
 
-def test(gdb):
-  gdb.Command('break mmap_breakpoint')
-  gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
-  gdb.ResumeAndExpectStop('finish', 'function-finished')
-  # Check that we can read from memory mapped files.
-  AssertEquals(gdb_test.ParseNumber(gdb.Eval('*file_mapping')), 123)
-  gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
-  gdb.ResumeAndExpectStop('finish', 'function-finished')
-  file_mapping_str = gdb.Eval('file_mapping')
-  file_mapping = gdb_test.ParseNumber(file_mapping_str)
-  gdb.Command('break *' + file_mapping_str)
-  gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
-  # Check that breakpoint in memory mapped code is working.
-  AssertEquals(gdb.GetPC(), file_mapping)
-  gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
-  gdb.ResumeAndExpectStop('finish', 'function-finished')
-  file_mapping_str = gdb.Eval('file_mapping')
-  file_mapping = gdb_test.ParseNumber(file_mapping_str)
-  gdb.Command('break *' + file_mapping_str)
-  gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
-  # Check that breakpoint in memory mapped code is working.
-  AssertEquals(gdb.GetPC(), file_mapping)
+  def test_mmap(self):
+    self.gdb.Command('break mmap_breakpoint')
+    self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
+    self.gdb.ResumeAndExpectStop('finish', 'function-finished')
+    # Check that we can read from memory mapped files.
+    self.assertEquals(gdb_test.ParseNumber(self.gdb.Eval('*file_mapping')), 123)
+    self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
+    self.gdb.ResumeAndExpectStop('finish', 'function-finished')
+    file_mapping_str = self.gdb.Eval('file_mapping')
+    file_mapping = gdb_test.ParseNumber(file_mapping_str)
+    self.gdb.Command('break *' + file_mapping_str)
+    self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
+    # Check that breakpoint in memory mapped code is working.
+    self.assertEquals(self.gdb.GetPC(), file_mapping)
+    self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
+    self.gdb.ResumeAndExpectStop('finish', 'function-finished')
+    file_mapping_str = self.gdb.Eval('file_mapping')
+    file_mapping = gdb_test.ParseNumber(file_mapping_str)
+    self.gdb.Command('break *' + file_mapping_str)
+    self.gdb.ResumeAndExpectStop('continue', 'breakpoint-hit')
+    # Check that breakpoint in memory mapped code is working.
+    self.assertEquals(self.gdb.GetPC(), file_mapping)
 
 
 if __name__ == '__main__':
-  os.environ['NACL_FAULT_INJECTION'] = (
-      'MMAP_BYPASS_DESCRIPTOR_SAFETY_CHECK=GF/@')
-  gdb_test.RunTest(test, 'mmap')
\ No newline at end of file
+  gdb_test.Main()