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

Unified Diff: tests/untrusted_crash_dump/nacl.scons

Issue 9316125: Adding untrusted crash dump / stack trace tests. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: taking out of irt tests 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 side-by-side diff with in-line comments
Download patch
Index: tests/untrusted_crash_dump/nacl.scons
diff --git a/tests/untrusted_crash_dump/nacl.scons b/tests/untrusted_crash_dump/nacl.scons
new file mode 100644
index 0000000000000000000000000000000000000000..412fd3292722d5c4d5d8b852743c96ab2255abb6
--- /dev/null
+++ b/tests/untrusted_crash_dump/nacl.scons
@@ -0,0 +1,152 @@
+# -*- python -*-
+# Copyright (c) 2012 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+Import('env')
+
+import posixpath
+import sys
+
+# Import decode_dump for small testing.
+sys.path.append(env.Dir('$MAIN_DIR/tests/untrusted_crash_dump').abspath)
+import decode_dump
+
+env.Append(CCFLAGS=['-O0', '-fno-omit-frame-pointer', '-g'])
+env['COMPONENT_STATIC'] = not env.Bit('nacl_glibc')
+
+# 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.
+if not env.Bit('build_x86_32'):
+ Return()
+
+
+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.
+ class Options:
+ pass
+ options = Options()
+ options.addr2line = env.subst('${ADDR2LINE}')
+ options.toolchain_libs = env.subst('${NACL_SDK_LIB}')
+ options.main_nexe = source[1].abspath
+ if len(source) > 2:
+ options.nmf = source[2].abspath
+ else:
+ options.nmf = None
+ info = decode_dump.LoadAndDecode(options, source[0].abspath)
+ trace = decode_dump.StackTrace(info)
+ expected = [
+ ('layer5', 21),
+ ('layer4', 26),
+ ('CallMe', 9),
+ ('layer3', 30),
+ ('layer2', 34),
+ ('layer1', 40),
+ ]
+ for i in range(len(expected)):
+ actual = (trace[i]['function'], trace[i]['lineno'])
+ if expected[i] != actual:
+ 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
+ expected[i], actual)
+ return 1
+ # Check CallMe is from the library.
+ if i == 2:
+ source_file = 'untrusted_crash_dump_lib.c'
+ else:
+ source_file = 'untrusted_crash_dump_test.c'
+ if posixpath.basename(trace[i]['filename']) != source_file:
+ print >>sys.stderr, '*** EXPECTED %s but got %s' % (
+ source_file, trace[i]['filename'])
+ return 1
+ return 0
+
+
+# Clone env for inbrowser version.
+env_browser = env.Clone()
+
+
+untrusted_crash_dump_lib = env.ComponentLibrary(
+ 'untrusted_crash_dump_lib',
+ 'untrusted_crash_dump_lib.c',
+ EXTRA_LIBS=['${PTHREAD_LIBS}', '${NONIRT_LIBS}'])
+
+untrusted_crash_dump_test = env.ComponentProgram(
+ 'untrusted_crash_dump_test',
+ ['untrusted_crash_dump.c', 'untrusted_crash_dump_test.c'],
+ EXTRA_LIBS=['untrusted_crash_dump_lib',
+ '${PTHREAD_LIBS}', '${NONIRT_LIBS}'])
+
+env['ENV']['NACL_UNTRUSTED_EXCEPTION_HANDLING'] = '1'
+
+dump_file = env.File('untrusted_crash_dump_test_core.json')
+run_test = env.CommandSelLdrTestNacl(
+ 'untrusted_crash_dump_test_run.out',
+ untrusted_crash_dump_test,
+ exit_status=166,
+ sel_ldr_flags=['-a', '-E', 'NACLCOREFILE=' + dump_file.abspath])
+env.AlwaysBuild(run_test)
+env.SideEffect(dump_file, run_test)
+node = env.Command('untrusted_crash_dump_test.out',
+ [dump_file, untrusted_crash_dump_test],
+ Action(ValidateCrashDump))
+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.
+env.AddNodeToTestSuite(
+ node, ['small_tests', 'exception_tests'],
+ 'run_untrusted_crash_dump_test')
+
+#
+# Similar stuff, but in the browser.
+#
+
+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 :-)
+
+
+untrusted_crash_dump_lib = env_browser.ComponentLibrary(
+ 'inbrowser_untrusted_crash_dump_lib',
+ env_browser.ComponentObject('inbrowser_untrusted_crash_dump_lib',
+ 'untrusted_crash_dump_lib.c',
+ ),
+ EXTRA_LIBS=['srpc', 'platform', 'gio', 'imc', 'imc_syscalls',
+ '${PTHREAD_LIBS}', '${NON_PPAPI_BROWSER_LIBS}'])
+
+untrusted_crash_dump_test = env_browser.ComponentProgram(
+ 'inbrowser_untrusted_crash_dump_test',
+ [env_browser.ComponentObject(
+ 'inbrowser_untrusted_crash_dump',
+ '${MAIN_DIR}/tests/untrusted_crash_dump/untrusted_crash_dump.c'),
+ env_browser.ComponentObject(
+ 'inbrowser_untrusted_crash_dump_test',
+ '${MAIN_DIR}/tests/untrusted_crash_dump/untrusted_crash_dump_test.c')],
+ EXTRA_LIBS=['inbrowser_untrusted_crash_dump_lib',
+ 'srpc', 'platform', 'gio', 'imc', 'imc_syscalls',
+ '${PTHREAD_LIBS}', '${NON_PPAPI_BROWSER_LIBS}'])
+
+# Make sure .so is in place for decoding.
+if env_browser.Bit('nacl_glibc'):
+ env_browser.Depends(untrusted_crash_dump_test,
+ '$STAGING_DIR/libinbrowser_untrusted_crash_dump_lib.so')
+
+env_browser['ENV']['NACL_UNTRUSTED_EXCEPTION_HANDLING'] = '1'
+crash_dump = ('${TARGET_ROOT}/test_results/'
+ 'inbrowser_untrusted_crash_dump_test.stdout')
+run_test = env_browser.PPAPIBrowserTester(
+ 'inbrowser_untrusted_crash_dump_test_run.out',
+ url='untrusted_crash_dump.html',
+ nmfs=['untrusted_crash_dump_test.nmf'],
+ nacl_exe_stdout={
+ 'file': crash_dump,
+ },
+ files=[untrusted_crash_dump_test,
+ env_browser.File('untrusted_crash_dump.html')])
+env.AlwaysBuild(run_test)
+env.SideEffect(crash_dump, run_test)
+node = env_browser.Command(
+ 'inbrowser_untrusted_crash_dump_test.out',
+ [crash_dump, untrusted_crash_dump_test,
+ '${STAGING_DIR}/untrusted_crash_dump_test.nmf'],
+ Action(ValidateCrashDump))
+env.Depends(node, run_test)
+env_browser.AddNodeToTestSuite(
+ 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.
+ 'run_inbrowser_untrusted_crash_dump_test',
+ is_broken=env_browser.PPAPIBrowserTesterIsBroken() or
+ env_browser.Bit('running_on_valgrind') or
+ env_browser.Bit('disable_dynamic_plugin_loading'))

Powered by Google App Engine
This is Rietveld 408576698