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

Side by Side Diff: tools/perf/core/stacktrace_unittest.py

Issue 1880333002: Use is_valid_dump to check for valid dumps in telemetry exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed old comment Created 4 years, 8 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
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import tempfile 5 import tempfile
6 import os 6 import os
7 7
8 from telemetry.core import exceptions 8 from telemetry.core import exceptions
9 from telemetry import decorators 9 from telemetry import decorators
10 from telemetry.testing import tab_test_case 10 from telemetry.testing import tab_test_case
11 11
12 12
13 class TabStackTraceTest(tab_test_case.TabTestCase): 13 class TabStackTraceTest(tab_test_case.TabTestCase):
14 14
15 # TODO(dyen): For now this doesn't work on Android but continue to
16 # expand this.
17 # TODO(kbr): currently failing on Windows because the symbolized
18 # stack trace format is unexpected. http://crbug.com/561763
19 @decorators.Enabled('mac', 'linux')
20 # Stack traces do not currently work on 10.6, but they are also being 15 # Stack traces do not currently work on 10.6, but they are also being
21 # disabled shortly so just disable it for now. 16 # disabled shortly so just disable it for now.
22 @decorators.Disabled('snowleopard') 17 # All platforms except chromeos should at least have a valid minidump.
23 def testStackTrace(self): 18 @decorators.Disabled('snowleopard', 'chromeos')
19 def testValidDump(self):
24 with self.assertRaises(exceptions.DevtoolsTargetCrashException) as c: 20 with self.assertRaises(exceptions.DevtoolsTargetCrashException) as c:
25 self._tab.Navigate('chrome://crash', timeout=5) 21 self._tab.Navigate('chrome://crash', timeout=5)
26 self.assertIn('Thread 0 (crashed)', '\n'.join(c.exception.stack_trace)) 22 self.assertTrue(c.exception.is_valid_dump)
27 23
28 # Stack traces aren't working on Android yet. 24 # Stack traces aren't working on Android yet.
29 @decorators.Enabled('mac', 'linux', 'win') 25 @decorators.Enabled('mac', 'linux', 'win')
30 @decorators.Disabled('snowleopard') 26 @decorators.Disabled('snowleopard')
31 def testCrashSymbols(self): 27 def testCrashSymbols(self):
32 with self.assertRaises(exceptions.DevtoolsTargetCrashException) as c: 28 with self.assertRaises(exceptions.DevtoolsTargetCrashException) as c:
33 self._tab.Navigate('chrome://crash', timeout=5) 29 self._tab.Navigate('chrome://crash', timeout=5)
34 self.assertIn('CrashIntentionally', '\n'.join(c.exception.stack_trace)) 30 self.assertIn('CrashIntentionally', '\n'.join(c.exception.stack_trace))
35 31
36 # The breakpad file specific test only apply to platforms which use the 32 # The breakpad file specific test only apply to platforms which use the
37 # breakpad symbol format. This also must be tested in isolation because it can 33 # breakpad symbol format. This also must be tested in isolation because it can
38 # potentially interfere with other tests symbol parsing. 34 # potentially interfere with other tests symbol parsing.
39 @decorators.Enabled('mac', 'linux') 35 @decorators.Enabled('mac', 'linux')
40 @decorators.Isolated 36 @decorators.Isolated
41 def testBadBreakpadFileIgnored(self): 37 def testBadBreakpadFileIgnored(self):
42 # pylint: disable=protected-access 38 # pylint: disable=protected-access
43 executable_path = self._browser._browser_backend._executable 39 executable_path = self._browser._browser_backend._executable
44 executable = os.path.basename(executable_path) 40 executable = os.path.basename(executable_path)
45 with tempfile.NamedTemporaryFile(mode='wt', 41 with tempfile.NamedTemporaryFile(mode='wt',
46 dir=os.path.dirname(executable_path), 42 dir=os.path.dirname(executable_path),
47 prefix=executable + '.breakpad', 43 prefix=executable + '.breakpad',
48 delete=True) as f: 44 delete=True) as f:
49 f.write('Garbage Data 012345') 45 garbage_hash = 'ABCDEF1234567'
46 f.write('MODULE PLATFORM ARCH %s %s' % (garbage_hash, executable))
50 f.flush() 47 f.flush()
51 with self.assertRaises(exceptions.DevtoolsTargetCrashException) as c: 48 with self.assertRaises(exceptions.DevtoolsTargetCrashException) as c:
52 self._tab.Navigate('chrome://crash', timeout=5) 49 self._tab.Navigate('chrome://crash', timeout=5)
53 # The symbol directory should now contain our breakpad file. 50 # The symbol directory should now symbols for out executable.
54 tmp_dir = os.path.join(self._browser._browser_backend._tmp_minidump_dir) 51 tmp_dir = os.path.join(self._browser._browser_backend._tmp_minidump_dir)
52 symbol_dir = os.path.join(tmp_dir, 'symbols')
53 self.assertTrue(os.path.isdir(symbol_dir))
55 54
56 # Symbol directory should have been created. 55 # Bad breakpad file should not be in the symbol directory
57 symbol_dir = os.path.join(tmp_dir, 'symbols', executable) 56 garbage_symbol_dir = os.path.join(symbol_dir, executable, garbage_hash)
58 self.assertTrue(os.path.isdir(symbol_dir)) 57 self.assertFalse(os.path.isdir(garbage_symbol_dir))
59 58
60 # A single symbol file should still exist here. 59 # Stack trace should still work.
nednguyen 2016/04/14 00:35:41 This logic is no longer important to test?
David Yen 2016/04/14 00:38:13 This doesn't work on Mac because the binary with s
61 self.assertEqual(1, len(os.listdir(symbol_dir))) 60 self.assertIn('CrashIntentionally', '\n'.join(c.exception.stack_trace))
62
63 # Stack trace should still work.
64 self.assertIn('CrashIntentionally', '\n'.join(c.exception.stack_trace))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698