1# -*- python -*-
2# Copyright (c) 2012 The Chromium 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
6import os
7
8Import('env')
9
10if env.Bit('host_windows') or env.Bit('host_mac'):
11  expected_crash_dumps = 1
12else:
13  # We are also checking that crash dumping does not work
14  # unexpectedly, since that might indicate that Breakpad was enabled
15  # without checking that it works securely.
16  expected_crash_dumps = 0
17
18platform_args = []
19if env.Bit('host_windows') and env.Bit('build_x86_64'):
20  platform_args.append('--win64')
21
22def GetNexeByName(name):
23  return env.File('${STAGING_DIR}/%s${PROGSUFFIX}' %
24                  env.ProgramNameForNmf(name))
25
26
27# This tests that crashes in Chromium's browser process successfully
28# produce crash dumps via Breakpad.
29node = env.PPAPIBrowserTester(
30    'breakpad_browser_process_crash_test.out',
31    python_tester_script=env.File('crash_dump_tester.py'),
32    browser_flags=['--crash-test'], # Tell the browser process to crash.
33    url='browser_process_crash.html',
34    nmf_names=[],
35    files=[env.File('browser_process_crash.html')],
36    args=platform_args + ['--expect_browser_process_crash',
37                          '--expected_crash_dumps=1',
38                          '--expected_process_type=browser'])
39
40# The test is disabled because it is flaky on Linux and Mac.
41# See: https://code.google.com/p/chromium/issues/detail?id=175023
42# Additionally, the test affects crash stats on Mac because it uploads
43# crash dumps on the bots for the Chrome official build.
44# See: https://code.google.com/p/chromium/issues/detail?id=129402
45env.AddNodeToTestSuite(
46    node, ['chrome_browser_tests'], 'run_breakpad_browser_process_crash_test',
47    is_broken=(env.PPAPIBrowserTesterIsBroken() or
48               env.Bit('host_linux') or env.Bit('host_mac') or
49               env.Bit('running_on_valgrind')))
50
51# This crash in trusted code should produce a crash dump.
52# DISABLED due to flakiness (http://crbug.com/247114).
53# crash_test_url = 'trusted_crash_in_startup.html'
54# node = env.PPAPIBrowserTester(
55#     'breakpad_trusted_crash_in_startup_test.out',
56#     python_tester_script=env.File('crash_dump_tester.py'),
57#     url=crash_test_url,
58#     nmf_names=['crash_test'],
59#     files=[GetNexeByName('crash_test'),
60#            env.File('trusted_crash_in_startup.html')],
61#     osenv='NACL_CRASH_TEST=1',
62#     args=platform_args + ['--expected_crash_dumps=%i' % expected_crash_dumps])
63# 
64# env.AddNodeToTestSuite(
65#     node,
66#     ['chrome_browser_tests'],
67#     'run_breakpad_trusted_crash_in_startup_test',
68#     is_broken=env.PPAPIBrowserTesterIsBroken() or
69#                env.Bit('running_on_valgrind'))
70
71# This tests a crash that occurs inside a syscall handler.
72# Ultimately this should be recognised as a crash caused by untrusted code.
73# See http://code.google.com/p/nativeclient/issues/detail?id=579
74# DISABLED due to flakiness (http://crbug.com/332331)
75# node = env.PPAPIBrowserTester(
76#     'breakpad_crash_in_syscall_test.out',
77#     python_tester_script=env.File('crash_dump_tester.py'),
78#     url='crash_in_syscall.html',
79#     nmf_names=['crash_in_syscall'],
80#     files=[GetNexeByName('crash_in_syscall'),
81#            env.File('crash_in_syscall.html')],
82#     args=platform_args + ['--expected_crash_dumps=%i' % expected_crash_dumps])
83# env.AddNodeToTestSuite(
84#     node, ['chrome_browser_tests'], 'run_breakpad_crash_in_syscall_test',
85#     # This test is currently flaky on Win 32 bit on x86, disabling there.
86#     # See bug: https://code.google.com/p/chromium/issues/detail?id=254583
87#     is_broken=env.PPAPIBrowserTesterIsBroken() or
88#                env.Bit('running_on_valgrind') or
89#                (env.Bit('host_windows') and env.Bit('build_x86_32')))
90
91# Crashes in untrusted code should not produce crash dumps.
92node = env.PPAPIBrowserTester(
93    'breakpad_untrusted_crash_test.out',
94    python_tester_script=env.File('crash_dump_tester.py'),
95    url='untrusted_crash.html',
96    nmf_names=['crash_test'],
97    files=[GetNexeByName('crash_test'),
98           env.File('untrusted_crash.html')],
99    args=platform_args + ['--expected_crash_dumps=0'])
100env.AddNodeToTestSuite(
101    node, ['chrome_browser_tests'], 'run_breakpad_untrusted_crash_test',
102    # This currently reliably fails in linux_aura configurations, probably for
103    # the same reasons that the previous test fails.
104    #
105    # See bug: https://code.google.com/p/chromium/issues/detail?id=303342
106    is_broken=env.PPAPIBrowserTesterIsBroken() or
107               env.Bit('running_on_valgrind') or
108               env.Bit('host_linux'))
109