~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/strace.py

  • Committer: Robert Collins
  • Date: 2007-03-27 07:37:12 UTC
  • mto: (2378.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2379.
  • Revision ID: robertc@robertcollins.net-20070327073712-6v27yeyl9unj6p9o
Review feedback.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
# want to move feature to its own module though.
27
27
from bzrlib.tests import Feature
28
28
 
 
29
 
29
30
def strace(function, *args, **kwargs):
30
31
    """Invoke strace on function.
31
32
 
32
 
    :return: A StraceResult.
 
33
    :return: a tuple: function-result, a StraceResult.
33
34
    """
34
35
    # capture strace output to a file
35
36
    log_file = tempfile.TemporaryFile()
43
44
        stdout=log_file_fd)
44
45
    # TODO? confirm its started (test suite should be sufficient)
45
46
    # (can loop on proc.pid, but that may not indicate started and attached.)
46
 
    function(*args, **kwargs)
 
47
    result = function(*args, **kwargs)
47
48
    # stop strace
48
49
    os.kill(proc.pid, signal.SIGQUIT)
49
50
    proc.communicate()
51
52
    log_file.seek(0)
52
53
    log = log_file.read()
53
54
    log_file.close()
54
 
    return StraceResult(log)
 
55
    return result, StraceResult(log)
55
56
 
56
57
 
57
58
class StraceResult(object):