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

Side by Side Diff: build/android/pylib/utils/reraiser_thread_unittest.py

Issue 13590002: [Android] Print the stack of deadlocked threads when sharding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: additional '*' * 80 to make frankf happy Created 7 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Unittests for reraiser_thread.py.""" 5 """Unittests for reraiser_thread.py."""
6 6
7 import threading
7 import unittest 8 import unittest
8 9
9 import reraiser_thread 10 import reraiser_thread
11 import watchdog_timer
10 12
11 13
12 class TestException(Exception): 14 class TestException(Exception):
13 pass 15 pass
14 16
15 17
16 class TestReraiserThread(unittest.TestCase): 18 class TestReraiserThread(unittest.TestCase):
17 """Tests for reraiser_thread.ReraiserThread.""" 19 """Tests for reraiser_thread.ReraiserThread."""
18 def testNominal(self): 20 def testNominal(self):
19 result = [None, None] 21 result = [None, None]
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 70
69 def testJoinRaise(self): 71 def testJoinRaise(self):
70 def f(): 72 def f():
71 raise TestException 73 raise TestException
72 group = reraiser_thread.ReraiserThreadGroup( 74 group = reraiser_thread.ReraiserThreadGroup(
73 [reraiser_thread.ReraiserThread(f) for _ in xrange(5)]) 75 [reraiser_thread.ReraiserThread(f) for _ in xrange(5)])
74 group.StartAll() 76 group.StartAll()
75 with self.assertRaises(TestException): 77 with self.assertRaises(TestException):
76 group.JoinAll() 78 group.JoinAll()
77 79
80 def testJoinTimeout(self):
81 def f():
82 pass
83 event = threading.Event()
84 def g():
85 event.wait()
86 group = reraiser_thread.ReraiserThreadGroup(
87 [reraiser_thread.ReraiserThread(g),
88 reraiser_thread.ReraiserThread(f)])
89 group.StartAll()
90 with self.assertRaises(reraiser_thread.TimeoutError):
91 group.JoinAll(watchdog_timer.WatchdogTimer(0.01))
92 event.set()
93
78 94
79 if __name__ == '__main__': 95 if __name__ == '__main__':
80 unittest.main() 96 unittest.main()
OLDNEW
« no previous file with comments | « build/android/pylib/utils/reraiser_thread.py ('k') | build/android/pylib/utils/watchdog_timer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698