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

Side by Side Diff: tests/untrusted_crash_dump/untrusted_crash_dump_test.py

Issue 9316125: Adding untrusted crash dump / stack trace tests. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: code review comments 3 Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2012 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 linecache
7 import os
8 import sys
9
10
11 # Import decode_dump for small testing.
12 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
13 TESTS_DIR = os.path.dirname(SCRIPT_DIR)
14 NACL_DIR = os.path.dirname(TESTS_DIR)
15 CRASH_DUMP_DIR = os.path.join(NACL_DIR, 'src', 'untrusted', 'crash_dump')
16 sys.path.insert(0, CRASH_DUMP_DIR)
17 import decode_dump
18
19
20 def CheckStackTrace(core, main_nexe, nmf, addr2line, nacl_sdk_lib):
21 """Check that a core dump yields an expected stack trace.
22
23 Args:
24 core: the core.json file emitted on crash.
25 main_nexe: the main nexe in question.
26 nmf: the manifest for main_nexe.
27 addr2line: location of addr2line for the relevant toolchain.
28 nacl_sdk_lib: location of the system dylibs for this nexe.
29 """
30 class Options:
Mark Seaborn 2012/02/16 18:42:50 If you change decode_dump to split the the parser
bradn 2012/02/16 20:13:10 Done.
31 pass
32 options = Options()
33 options.addr2line = addr2line
34 options.toolchain_libs = nacl_sdk_lib
35 options.main_nexe = main_nexe
36 if nmf == '-':
37 options.nmf = None
38 else:
39 options.nmf = nmf
40 info = decode_dump.LoadAndDecode(options, core)
41 trace = decode_dump.StackTrace(info)
42 expected = [
43 ('layer5', '*(volatile int *) x = y;'),
44 ('layer4', 'layer5(x, 1);'),
45 ('CallMe', 'func(arg);'),
46 ('layer3', 'CallMe(layer4, a + b + c);'),
47 ('layer2', 'layer3(i, j, 7);'),
48 ('layer1', 'layer2(junk[0], t + 1);'),
49 ]
50 for i in range(len(expected)):
51 scope = trace[i]
52 lineno = int(scope['lineno'])
53 # Line prior to return is more interested in all but the innermost scope.
54 if i != 0:
55 lineno -= 1
Mark Seaborn 2012/02/16 18:42:50 The line textually before isn't necessarily where
bradn 2012/02/16 20:13:10 Done.
56 line = linecache.getline(scope['filename'], lineno).strip()
57 actual = (scope['function'], line)
58 assert expected[i] == actual
59
60
61 if __name__ == '__main__':
62 if len(sys.argv) != 6:
63 print >>sys.stderr, (
Mark Seaborn 2012/02/16 18:42:50 Prefer sys.stderr.write() over print>>
bradn 2012/02/16 20:13:10 Done.
64 'USAGE: %s <core.json> <nexe> <nmf> <addr2line> <nacl_sdk_lib>' %
65 sys.argv[0])
66 sys.exit(1)
67 CheckStackTrace(*sys.argv[1:])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698