Rev 3417: (vila) Fix bug #226769: Don't run strace tests if more than one in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu May 8 15:59:17 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3417
revision-id:pqm at pqm.ubuntu.com-20080508145906-m9o15u3pxuxkc1iu
parent: pqm at pqm.ubuntu.com-20080508082241-zyx68bbzrgnlhw9m
parent: v.ladeuil+lp at free.fr-20080507175404-25btczc2cdbyulfd
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-05-08 15:59:06 +0100
message:
(vila) Fix bug #226769: Don't run strace tests if more than one
thread is active
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/test_strace.py test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
------------------------------------------------------------
revno: 3406.1.3
revision-id:v.ladeuil+lp at free.fr-20080507175404-25btczc2cdbyulfd
parent: v.ladeuil+lp at free.fr-20080507133707-hfscqf32riufeqx7
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 226769-selftest-hanging-with-strace
timestamp: Wed 2008-05-07 19:54:04 +0200
message:
Fixed as par John's review.
* test_strace.py:
(TestStrace): Update comment.
modified:
bzrlib/tests/test_strace.py test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
------------------------------------------------------------
revno: 3406.1.2
revision-id:v.ladeuil+lp at free.fr-20080507133707-hfscqf32riufeqx7
parent: v.ladeuil+lp at free.fr-20080505130727-trhinzsipvucozdu
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 226769-selftest-hanging-with-strace
timestamp: Wed 2008-05-07 15:37:07 +0200
message:
Fix as per Robert's review.
* test_strace.py:
(TestStrace._check_threads): Raise KnownFailure if there is more
than one thread active (to avoid hanging).
* __init__.py:
(TestCase): Detect and report leaked threads.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/test_strace.py test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
------------------------------------------------------------
revno: 3406.1.1
revision-id:v.ladeuil+lp at free.fr-20080505130727-trhinzsipvucozdu
parent: pqm at pqm.ubuntu.com-20080505041432-g51fjlrfth74arug
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 226769-selftest-hanging-with-strace
timestamp: Mon 2008-05-05 15:07:27 +0200
message:
Fix #226769 by disabling some strace tests.
* test_strace.py:
(TestStrace): Disable the tests since they can make selftest hang.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/test_strace.py test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
=== modified file 'NEWS'
--- a/NEWS 2008-05-08 08:22:41 +0000
+++ b/NEWS 2008-05-08 14:59:06 +0000
@@ -51,6 +51,10 @@
* Conversion from non-rich-root to rich-root(-pack) works even when a
parent revision has a different root id. (Aaron Bentley, #177874)
+ * Disable strace testing until strace is fixed (see bug #103133) and emit a
+ warning when selftest ends to remind us of leaking tests.
+ (Vincent Ladeuil, #226769)
+
* Fetching all revisions from a repository does not cause pack collisions.
(Robert Collins, Aaron Bentley, #212908)
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2008-05-07 22:47:56 +0000
+++ b/bzrlib/tests/__init__.py 2008-05-08 14:59:06 +0000
@@ -42,6 +42,7 @@
from subprocess import Popen, PIPE
import sys
import tempfile
+import threading
import time
import unittest
import warnings
@@ -755,6 +756,12 @@
return password
+def _report_leaked_threads():
+ bzrlib.trace.warning('%s is leaking threads among %d leaking tests',
+ TestCase._first_thread_leaker_id,
+ TestCase._leaking_threads_tests)
+
+
class TestCase(unittest.TestCase):
"""Base class for bzr unit tests.
@@ -776,6 +783,9 @@
accidentally overlooked.
"""
+ _active_threads = None
+ _leaking_threads_tests = 0
+ _first_thread_leaker_id = None
_log_file_name = None
_log_contents = ''
_keep_log_file = False
@@ -798,6 +808,21 @@
self._benchtime = None
self._clear_hooks()
self._clear_debug_flags()
+ TestCase._active_threads = threading.activeCount()
+ self.addCleanup(self._check_leaked_threads)
+
+ def _check_leaked_threads(self):
+ active = threading.activeCount()
+ leaked_threads = active - TestCase._active_threads
+ TestCase._active_threads = active
+ if leaked_threads:
+ TestCase._leaking_threads_tests += 1
+ if TestCase._first_thread_leaker_id is None:
+ TestCase._first_thread_leaker_id = self.id()
+ # we're not specifically told when all tests are finished.
+ # This will do. We use a function to avoid keeping a reference
+ # to a TestCase object.
+ atexit.register(_report_leaked_threads)
def _clear_debug_flags(self):
"""Prevent externally set debug flags affecting tests.
=== modified file 'bzrlib/tests/test_strace.py'
--- a/bzrlib/tests/test_strace.py 2007-07-03 09:28:59 +0000
+++ b/bzrlib/tests/test_strace.py 2008-05-07 17:54:04 +0000
@@ -19,12 +19,15 @@
import errno
import subprocess
+import threading
+from bzrlib import (
+ tests,
+ )
from bzrlib.strace import StraceFeature, strace_detailed, StraceResult
-from bzrlib.tests import TestCaseWithTransport
-
-
-class TestStraceFeature(TestCaseWithTransport):
+
+
+class TestStraceFeature(tests.TestCaseWithTransport):
def test_strace_detection(self):
"""Strace is available if its runnable."""
@@ -43,11 +46,24 @@
self.assertEqual(found_strace, StraceFeature.available())
-class TestStrace(TestCaseWithTransport):
+class TestStrace(tests.TestCaseWithTransport):
_test_needs_features = [StraceFeature]
+ def _check_threads(self):
+ # For bug #226769, it was decided that the strace tests should not be
+ # run when more than one thread is active. A lot of tests are currently
+ # leaking threads for good or bad reasons, once they are fixed or
+ # strace itself is fixed (bug #103133), we can get rid of the
+ # restriction.
+ active = threading.activeCount()
+ if active > 1: # There is always the main thread at least
+ raise tests.KnownFailure(
+ '%d active threads, bug #103133 needs to be fixed.' % active)
+
def test_strace_callable_is_called(self):
+ self._check_threads()
+
output = []
def function(positional, *args, **kwargs):
output.append((positional, args, kwargs))
@@ -56,6 +72,8 @@
self.assertEqual([("a", ("b",), {"c":"c"})], output)
def test_strace_callable_result(self):
+ self._check_threads()
+
def function():
return "foo"
result, strace_result = strace_detailed(function,[], {},
@@ -65,6 +83,8 @@
def test_strace_result_has_raw_log(self):
"""Checks that a reasonable raw strace log was found by strace."""
+ self._check_threads()
+
def function():
self.build_tree(['myfile'])
unused, result = strace_detailed(function, [], {},
More information about the bazaar-commits
mailing list