Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / untrusted_minidump / nacl.scons
1 # -*- python -*-
2 # Copyright (c) 2013 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 os
7 Import('env')
8
9 # Preserve debugging info (which is not ABI-stable under PNaCl).
10 if not env.AllowNonStableBitcode():
11   Return()
12
13 if env.Bit('bitcode'):
14   # With the PNaCl toolchain, special flags are required to get a build ID.
15   env.Append(LINKFLAGS=['--pnacl-allow-nexe-build-id'])
16   if env.Bit('pnacl_generate_pexe'):
17     env.Append(TRANSLATEFLAGS=['--build-id'])
18   else:
19     env.Append(LINKFLAGS=['--pnacl-allow-native', '-Wn,--build-id'])
20
21 env['COMPONENT_STATIC'] = env.Bit('nacl_static_link')
22 env.ComponentLibrary('minidump_test_lib', 'minidump_test_lib.c')
23 nexe = env.ComponentProgram(
24     'minidump_test', 'minidump_test.c',
25     EXTRA_LIBS=['minidump_test_lib', 'minidump_generator',
26                 '${NONIRT_LIBS}', '${EXCEPTION_LIBS}', '${PTHREAD_LIBS}'])
27
28 for crash_in_lib in [0, 1]:
29   for modules_live in [0, 1]:
30     name = 'minidump'
31     if crash_in_lib:
32       name += '_crash_in_lib'
33     if modules_live:
34       name += '_modules_live'
35     name += '_test'
36     output_dump_file = env.File(name + '.dmp')
37     nodes = [
38         env.CommandSelLdrTestNacl(
39             name + '.out', nexe,
40             [output_dump_file.abspath, str(crash_in_lib), str(modules_live)],
41             declares_exit_status=True,
42             sel_ldr_flags=['-e', # Enable exception handling for catching crash
43                            '-a', # Enable file access for writing minidump file
44                           ]),
45     ]
46     env.SideEffect(output_dump_file, nodes[0])
47     breakpad_tools_dir = env.get('BREAKPAD_TOOLS_DIR')
48     if breakpad_tools_dir is not None:
49       # Check that the minidump can be decoded.
50       minidump_dump = breakpad_tools_dir.File('src/processor/minidump_dump')
51       if not os.path.exists(minidump_dump.abspath):
52         raise Exception('minidump_dump not available, '
53             'but breakpad_tools_dir=%s specified' % breakpad_tools_dir)
54       nodes.append(env.AutoDepsCommand(
55           [name + '.dump', name + '.dump_errors'],
56           [minidump_dump, output_dump_file,
57           '>${TARGETS[0]}', '2>${TARGETS[1]}']))
58       # Check that a stack trace can be extracted from the minidump.
59       # TODO(bradnelson): Check the trace is actually right.
60       minidump_stackwalk = breakpad_tools_dir.File(
61           'src/processor/minidump_stackwalk')
62       if not os.path.exists(minidump_dump.abspath):
63         raise Exception('minidump_stackwalk not available, '
64                     'but breakpad_tools_dir=%s specified' % breakpad_tools_dir)
65       nodes.append(env.AutoDepsCommand(
66           [name + '.stackwalk', name + '.stackwalk_errors'],
67           [minidump_stackwalk, output_dump_file,
68           '>${TARGETS[0]}', '2>${TARGETS[1]}']))
69     env.AddNodeToTestSuite(nodes,
70                            ['small_tests', 'exception_tests', 'nonpexe_tests'],
71                            'run_' + name,
72                            # Nexe build IDs are not available under the
73                            # sandboxed PNaCl translator.
74                            is_broken=env.Bit('use_sandboxed_translator'))