/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to brzlib/tests/test_strace.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import threading
20
20
 
21
 
from breezy import (
 
21
from brzlib import (
22
22
    strace,
23
23
    tests,
24
24
    )
25
 
from breezy.strace import strace_detailed, StraceResult
26
 
from breezy.tests.features import (
 
25
from brzlib.strace import strace_detailed, StraceResult
 
26
from brzlib.tests.features import (
27
27
    strace_feature,
28
28
    )
29
29
 
49
49
        # strace itself is fixed (bug #103133), we can get rid of the
50
50
        # restriction.
51
51
        active = threading.activeCount()
52
 
        if active > 1:  # There is always the main thread at least
 
52
        if active > 1: # There is always the main thread at least
53
53
            self.knownFailure(
54
54
                '%d active threads, bug #103133 needs to be fixed.' % active)
55
55
 
57
57
        """Run strace, but cope if it's not allowed"""
58
58
        try:
59
59
            return strace_detailed(*args, **kwargs)
60
 
        except strace.StraceError as e:
 
60
        except strace.StraceError, e:
61
61
            if e.err_messages.startswith(
62
62
                    "attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted"):
63
63
                raise tests.TestSkipped("ptrace not permitted")
68
68
        self._check_threads()
69
69
 
70
70
        output = []
71
 
 
72
71
        def function(positional, *args, **kwargs):
73
72
            output.append((positional, args, kwargs))
74
73
        self.strace_detailed_or_skip(
75
74
            function, ["a", "b"], {"c": "c"},
76
75
            follow_children=False)
77
 
        self.assertEqual([("a", ("b",), {"c": "c"})], output)
 
76
        self.assertEqual([("a", ("b",), {"c":"c"})], output)
78
77
 
79
78
    def test_strace_callable_result(self):
80
79
        self._check_threads()
81
80
 
82
81
        def function():
83
82
            return "foo"
84
 
        result, strace_result = self.strace_detailed_or_skip(function, [], {},
85
 
                                                             follow_children=False)
 
83
        result, strace_result = self.strace_detailed_or_skip(function,[], {},
 
84
                                                follow_children=False)
86
85
        self.assertEqual("foo", result)
87
86
        self.assertIsInstance(strace_result, StraceResult)
88
87
 
93
92
        def function():
94
93
            self.build_tree(['myfile'])
95
94
        unused, result = self.strace_detailed_or_skip(function, [], {},
96
 
                                                      follow_children=False)
 
95
                                         follow_children=False)
97
96
        self.assertContainsRe(result.raw_log, 'myfile')