Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: chrome/test/data/nacl/debug_stub_browser_tests.py

Issue 1153293003: NaCl cleanup: Stop connecting to the SRPC trusted command channel (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove uncalled OnChannelError() Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/nacl/gdb_rsp.py » ('j') | chrome/test/data/nacl/gdb_rsp.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import re 5 import re
6 import sys 6 import sys
7 import xml.etree.ElementTree 7 import xml.etree.ElementTree
8 8
9 import gdb_rsp 9 import gdb_rsp
10 10
11 11
12 def AssertRaises(exc_class, func):
13 try:
14 func()
15 except exc_class:
16 pass
17 else:
18 raise AssertionError('Function did not raise %r' % exc_class)
19
20
12 def GetTargetArch(connection): 21 def GetTargetArch(connection):
13 """Get the CPU architecture of the NaCl application.""" 22 """Get the CPU architecture of the NaCl application."""
14 reply = connection.RspRequest('qXfer:features:read:target.xml:0,fff') 23 reply = connection.RspRequest('qXfer:features:read:target.xml:0,fff')
15 assert reply[0] == 'l', reply 24 assert reply[0] == 'l', reply
16 tree = xml.etree.ElementTree.fromstring(reply[1:]) 25 tree = xml.etree.ElementTree.fromstring(reply[1:])
17 arch_tag = tree.find('architecture') 26 arch_tag = tree.find('architecture')
18 assert arch_tag is not None, reply 27 assert arch_tag is not None, reply
19 return arch_tag.text.strip() 28 return arch_tag.text.strip()
20 29
21 30
(...skipping 17 matching lines...) Expand all
39 if arch == 'i386:x86-64': 48 if arch == 'i386:x86-64':
40 # rip index is 16 49 # rip index is 16
41 return ReverseBytes(registers[16 * 16 : 16 * 16 + 8]) 50 return ReverseBytes(registers[16 * 16 : 16 * 16 + 8])
42 if arch == 'iwmmxt': 51 if arch == 'iwmmxt':
43 # pc index is 15 52 # pc index is 15
44 return ReverseBytes(registers[15 * 8 : 15 * 8 + 8]) 53 return ReverseBytes(registers[15 * 8 : 15 * 8 + 8])
45 raise AssertionError('Unknown architecture: %s' % arch) 54 raise AssertionError('Unknown architecture: %s' % arch)
46 55
47 56
48 def TestContinue(connection): 57 def TestContinue(connection):
49 result = connection.RspRequest('vCont;c')
50 # Once the NaCl test module reports that the test passed, the NaCl <embed> 58 # Once the NaCl test module reports that the test passed, the NaCl <embed>
51 # element is removed from the page and so the NaCl module is killed by 59 # element is removed from the page. The NaCl module will be killed by the
52 # the browser what is reported as exit due to SIGKILL (X09). 60 # browser which will appear as EOF (end-of-file) on the debug stub socket.
53 assert result == 'X09', result 61 AssertRaises(gdb_rsp.EofOnReplyException,
62 lambda: connection.RspRequest('vCont;c'))
54 63
55 64
56 def TestBreakpoint(connection): 65 def TestBreakpoint(connection):
57 # Breakpoints and single-stepping might interfere with Chrome sandbox. So we 66 # Breakpoints and single-stepping might interfere with Chrome sandbox. So we
58 # check that they work properly in this test. 67 # check that they work properly in this test.
59 arch = GetTargetArch(connection) 68 arch = GetTargetArch(connection)
60 registers = connection.RspRequest('g') 69 registers = connection.RspRequest('g')
61 pc = GetProgCtrString(connection, arch) 70 pc = GetProgCtrString(connection, arch)
62 # Set breakpoint 71 # Set breakpoint
63 result = connection.RspRequest('Z0,%s,1' % pc) 72 result = connection.RspRequest('Z0,%s,1' % pc)
64 assert result == 'OK', result 73 assert result == 'OK', result
65 # Check that we stopped at breakpoint 74 # Check that we stopped at breakpoint
66 result = connection.RspRequest('vCont;c') 75 result = connection.RspRequest('vCont;c')
67 stop_reply = re.compile(r'T05thread:(\d+);') 76 stop_reply = re.compile(r'T05thread:(\d+);')
68 assert stop_reply.match(result), result 77 assert stop_reply.match(result), result
69 thread = stop_reply.match(result).group(1) 78 thread = stop_reply.match(result).group(1)
70 # Check that registers haven't changed 79 # Check that registers haven't changed
71 result = connection.RspRequest('g') 80 result = connection.RspRequest('g')
72 assert result == registers, (result, registers) 81 assert result == registers, (result, registers)
73 # Remove breakpoint 82 # Remove breakpoint
74 result = connection.RspRequest('z0,%s,1' % pc) 83 result = connection.RspRequest('z0,%s,1' % pc)
75 assert result == 'OK', result 84 assert result == 'OK', result
76 # Check single stepping 85 # Check single stepping
77 result = connection.RspRequest('vCont;s:%s' % thread) 86 result = connection.RspRequest('vCont;s:%s' % thread)
78 assert result == 'T05thread:%s;' % thread, result 87 assert result == 'T05thread:%s;' % thread, result
79 assert pc != GetProgCtrString(connection, arch) 88 assert pc != GetProgCtrString(connection, arch)
80 # Check that we terminate normally 89 # Check that we terminate normally
81 result = connection.RspRequest('vCont;c') 90 AssertRaises(gdb_rsp.EofOnReplyException,
82 assert result == 'X09', result 91 lambda: connection.RspRequest('vCont;c'))
83 92
84 93
85 def Main(args): 94 def Main(args):
86 port = int(args[0]) 95 port = int(args[0])
87 name = args[1] 96 name = args[1]
88 connection = gdb_rsp.GdbRspConnection(('localhost', port)) 97 connection = gdb_rsp.GdbRspConnection(('localhost', port))
89 if name == 'continue': 98 if name == 'continue':
90 TestContinue(connection) 99 TestContinue(connection)
91 elif name == 'breakpoint': 100 elif name == 'breakpoint':
92 TestBreakpoint(connection) 101 TestBreakpoint(connection)
93 else: 102 else:
94 raise AssertionError('Unknown test name: %r' % name) 103 raise AssertionError('Unknown test name: %r' % name)
95 104
96 105
97 if __name__ == '__main__': 106 if __name__ == '__main__':
98 Main(sys.argv[1:]) 107 Main(sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/nacl/gdb_rsp.py » ('j') | chrome/test/data/nacl/gdb_rsp.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698