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

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: add json escaping to fix windows 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_filename, 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_filename: 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 decoder = decode_dump.CoreDecoder(
31 main_nexe=main_nexe,
32 nmf_filename=nmf_filename,
33 addr2line=addr2line,
34 toolchain_libs=nacl_sdk_lib)
35 info = decoder.LoadAndDecode(core)
36 trace = decoder.StackTrace(info)
37 expected = [
38 ('layer5', '*(volatile int *) x = y;'),
39 ('layer4', 'layer5(x, 1);'),
40 ('CallMe', 'func(arg);'),
41 ('layer3', 'CallMe(layer4, a + b + c);'),
42 ('layer2', 'layer3(i, j, 7);'),
43 ('layer1', 'layer2(junk[0], t + 1);'),
44 ]
45 for i in range(len(expected)):
46 scope = trace[i]
47 lineno = int(scope['lineno'])
48 line = linecache.getline(scope['filename'], lineno).strip()
49 actual = (scope['function'], line)
50 assert expected[i] == actual
51
52
53 if __name__ == '__main__':
54 if len(sys.argv) != 6:
55 sys.stderr.write(
56 'USAGE: %s <core.json> <nexe> <nmf> <addr2line> <nacl_sdk_lib>\n' %
57 sys.argv[0])
58 sys.exit(1)
59 CheckStackTrace(*sys.argv[1:])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698