OLD | NEW |
---|---|
(Empty) | |
1 # -*- 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('env') | |
7 | |
8 import posixpath | |
9 import sys | |
10 | |
11 # Import decode_dump for small testing. | |
12 sys.path.append(env.Dir('$MAIN_DIR/tests/untrusted_crash_dump').abspath) | |
13 import decode_dump | |
14 | |
15 env.Append(CCFLAGS=['-O0', '-fno-omit-frame-pointer', '-g']) | |
16 env['COMPONENT_STATIC'] = not env.Bit('nacl_glibc') | |
17 | |
18 # Don't build on anything other than x86-32 for now. | |
Mark Seaborn
2012/02/13 19:04:08
Nit: This is one of those comments that just parap
bradn
2012/02/13 23:42:03
Done.
| |
19 if not env.Bit('build_x86_32'): | |
20 Return() | |
21 | |
22 | |
23 def ValidateCrashDump(target=None, source=None, env=None): | |
Mark Seaborn
2012/02/13 19:04:08
Please don't embed non-trivial test cases like thi
bradn
2012/02/13 23:42:03
Done.
| |
24 class Options: | |
25 pass | |
26 options = Options() | |
27 options.addr2line = env.subst('${ADDR2LINE}') | |
28 options.toolchain_libs = env.subst('${NACL_SDK_LIB}') | |
29 options.main_nexe = source[1].abspath | |
30 if len(source) > 2: | |
31 options.nmf = source[2].abspath | |
32 else: | |
33 options.nmf = None | |
34 info = decode_dump.LoadAndDecode(options, source[0].abspath) | |
35 trace = decode_dump.StackTrace(info) | |
36 expected = [ | |
37 ('layer5', 21), | |
38 ('layer4', 26), | |
39 ('CallMe', 9), | |
40 ('layer3', 30), | |
41 ('layer2', 34), | |
42 ('layer1', 40), | |
43 ] | |
44 for i in range(len(expected)): | |
45 actual = (trace[i]['function'], trace[i]['lineno']) | |
46 if expected[i] != actual: | |
47 print >>sys.stderr, '*** EXPECTED %s but got %s' % ( | |
Mark Seaborn
2012/02/13 19:04:08
Why not raise an exception? (Because this is in a
bradn
2012/02/13 23:42:03
Wanted to continue on fail, but yeah moot if not i
| |
48 expected[i], actual) | |
49 return 1 | |
50 # Check CallMe is from the library. | |
51 if i == 2: | |
52 source_file = 'untrusted_crash_dump_lib.c' | |
53 else: | |
54 source_file = 'untrusted_crash_dump_test.c' | |
55 if posixpath.basename(trace[i]['filename']) != source_file: | |
56 print >>sys.stderr, '*** EXPECTED %s but got %s' % ( | |
57 source_file, trace[i]['filename']) | |
58 return 1 | |
59 return 0 | |
60 | |
61 | |
62 # Clone env for inbrowser version. | |
63 env_browser = env.Clone() | |
64 | |
65 | |
66 untrusted_crash_dump_lib = env.ComponentLibrary( | |
67 'untrusted_crash_dump_lib', | |
68 'untrusted_crash_dump_lib.c', | |
69 EXTRA_LIBS=['${PTHREAD_LIBS}', '${NONIRT_LIBS}']) | |
70 | |
71 untrusted_crash_dump_test = env.ComponentProgram( | |
72 'untrusted_crash_dump_test', | |
73 ['untrusted_crash_dump.c', 'untrusted_crash_dump_test.c'], | |
74 EXTRA_LIBS=['untrusted_crash_dump_lib', | |
75 '${PTHREAD_LIBS}', '${NONIRT_LIBS}']) | |
76 | |
77 env['ENV']['NACL_UNTRUSTED_EXCEPTION_HANDLING'] = '1' | |
78 | |
79 dump_file = env.File('untrusted_crash_dump_test_core.json') | |
80 run_test = env.CommandSelLdrTestNacl( | |
81 'untrusted_crash_dump_test_run.out', | |
82 untrusted_crash_dump_test, | |
83 exit_status=166, | |
84 sel_ldr_flags=['-a', '-E', 'NACLCOREFILE=' + dump_file.abspath]) | |
85 env.AlwaysBuild(run_test) | |
86 env.SideEffect(dump_file, run_test) | |
87 node = env.Command('untrusted_crash_dump_test.out', | |
88 [dump_file, untrusted_crash_dump_test], | |
89 Action(ValidateCrashDump)) | |
90 env.Depends(node, run_test) | |
Mark Seaborn
2012/02/13 19:04:08
Is this necessary, if you've declared that node de
bradn
2012/02/13 23:42:03
Indeed, done.
| |
91 env.AddNodeToTestSuite( | |
92 node, ['small_tests', 'exception_tests'], | |
93 'run_untrusted_crash_dump_test') | |
94 | |
95 # | |
96 # Similar stuff, but in the browser. | |
97 # | |
98 | |
99 env_browser.Append(CPPDEFINES=['IN_BROWER=1']) | |
Mark Seaborn
2012/02/13 19:04:08
Typo means this is presumably not needed.
bradn
2012/02/13 23:42:03
Ah yeah, dropped that in the code :-)
| |
100 | |
101 | |
102 untrusted_crash_dump_lib = env_browser.ComponentLibrary( | |
103 'inbrowser_untrusted_crash_dump_lib', | |
104 env_browser.ComponentObject('inbrowser_untrusted_crash_dump_lib', | |
105 'untrusted_crash_dump_lib.c', | |
106 ), | |
107 EXTRA_LIBS=['srpc', 'platform', 'gio', 'imc', 'imc_syscalls', | |
108 '${PTHREAD_LIBS}', '${NON_PPAPI_BROWSER_LIBS}']) | |
109 | |
110 untrusted_crash_dump_test = env_browser.ComponentProgram( | |
111 'inbrowser_untrusted_crash_dump_test', | |
112 [env_browser.ComponentObject( | |
113 'inbrowser_untrusted_crash_dump', | |
114 '${MAIN_DIR}/tests/untrusted_crash_dump/untrusted_crash_dump.c'), | |
115 env_browser.ComponentObject( | |
116 'inbrowser_untrusted_crash_dump_test', | |
117 '${MAIN_DIR}/tests/untrusted_crash_dump/untrusted_crash_dump_test.c')], | |
118 EXTRA_LIBS=['inbrowser_untrusted_crash_dump_lib', | |
119 'srpc', 'platform', 'gio', 'imc', 'imc_syscalls', | |
120 '${PTHREAD_LIBS}', '${NON_PPAPI_BROWSER_LIBS}']) | |
121 | |
122 # Make sure .so is in place for decoding. | |
123 if env_browser.Bit('nacl_glibc'): | |
124 env_browser.Depends(untrusted_crash_dump_test, | |
125 '$STAGING_DIR/libinbrowser_untrusted_crash_dump_lib.so') | |
126 | |
127 env_browser['ENV']['NACL_UNTRUSTED_EXCEPTION_HANDLING'] = '1' | |
128 crash_dump = ('${TARGET_ROOT}/test_results/' | |
129 'inbrowser_untrusted_crash_dump_test.stdout') | |
130 run_test = env_browser.PPAPIBrowserTester( | |
131 'inbrowser_untrusted_crash_dump_test_run.out', | |
132 url='untrusted_crash_dump.html', | |
133 nmfs=['untrusted_crash_dump_test.nmf'], | |
134 nacl_exe_stdout={ | |
135 'file': crash_dump, | |
136 }, | |
137 files=[untrusted_crash_dump_test, | |
138 env_browser.File('untrusted_crash_dump.html')]) | |
139 env.AlwaysBuild(run_test) | |
140 env.SideEffect(crash_dump, run_test) | |
141 node = env_browser.Command( | |
142 'inbrowser_untrusted_crash_dump_test.out', | |
143 [crash_dump, untrusted_crash_dump_test, | |
144 '${STAGING_DIR}/untrusted_crash_dump_test.nmf'], | |
145 Action(ValidateCrashDump)) | |
146 env.Depends(node, run_test) | |
147 env_browser.AddNodeToTestSuite( | |
148 node, ['chrome_browser_tests', 'exception_tests'], | |
Mark Seaborn
2012/02/13 19:04:08
Don't add browser tests to exception_tests, please
bradn
2012/02/13 23:42:03
Done.
| |
149 'run_inbrowser_untrusted_crash_dump_test', | |
150 is_broken=env_browser.PPAPIBrowserTesterIsBroken() or | |
151 env_browser.Bit('running_on_valgrind') or | |
152 env_browser.Bit('disable_dynamic_plugin_loading')) | |
OLD | NEW |