~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_strace.py

  • Committer: Vincent Ladeuil
  • Date: 2008-05-07 13:37:07 UTC
  • mto: This revision was merged to the branch mainline in revision 3417.
  • Revision ID: v.ladeuil+lp@free.fr-20080507133707-hfscqf32riufeqx7
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.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import errno
21
21
import subprocess
 
22
import threading
22
23
 
23
24
from bzrlib import (
24
25
    tests,
52
53
    # If the following tests are activated, selftest may hang (see bug
53
54
    # #226769). This is due to strace strange behavior when required to trace
54
55
    # its own parent in the presence of threads (or something like that). One
55
 
    # strace is fixed, we may want to activate these tests again.
 
56
    # strace is fixed, we may want to activate these tests again. Note: running
 
57
    # these tests in isolation is still possible.
 
58
 
 
59
    def _check_threads(self):
 
60
        active = threading.activeCount()
 
61
        if active > 1: # There is always the main thread at least
 
62
            raise tests.KnownFailure(
 
63
                '%d active threads, bug #103133 needs to be fixed.' % active)
56
64
 
57
65
    def test_strace_callable_is_called(self):
58
 
        raise tests.TestSkipped("bug #103133 needs to be fixed.")
 
66
        self._check_threads()
 
67
 
59
68
        output = []
60
69
        def function(positional, *args, **kwargs):
61
70
            output.append((positional, args, kwargs))
64
73
        self.assertEqual([("a", ("b",), {"c":"c"})], output)
65
74
 
66
75
    def test_strace_callable_result(self):
67
 
        raise tests.TestSkipped("bug #103133 needs to be fixed.")
 
76
        self._check_threads()
68
77
 
69
78
        def function():
70
79
            return "foo"
75
84
 
76
85
    def test_strace_result_has_raw_log(self):
77
86
        """Checks that a reasonable raw strace log was found by strace."""
78
 
        raise tests.TestSkipped("bug #103133 needs to be fixed.")
 
87
        self._check_threads()
 
88
 
79
89
        def function():
80
90
            self.build_tree(['myfile'])
81
91
        unused, result = strace_detailed(function, [], {},