/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 bzrlib/strace.py

  • Committer: Vincent Ladeuil
  • Date: 2007-07-02 11:07:10 UTC
  • mto: (2584.1.1 Aaron's integration)
  • mto: This revision was merged to the branch mainline in revision 2585.
  • Revision ID: v.ladeuil+lp@free.fr-20070702110710-jjzry7iv7hbqinrm
Fix #102019 by not asking strace to follow children forks during tests.

* bzrlib/tests/test_strace.py:
(TestStrace.test_strace_callable_is_called,
TestStrace.test_strace_callable_result,
TestStrace.test_strace_result_has_raw_log): Don't follow childrens
when calling strace to avoid random hanging.

* bzrlib/strace.py:
(strace): Provides a way do disable the strace '-f' option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
"""Support for running strace against the current process."""
19
19
 
33
33
 
34
34
    :return: a tuple: function-result, a StraceResult.
35
35
    """
36
 
    return strace_detailed(function, args, kwargs)
37
 
 
38
 
 
39
 
def strace_detailed(function, args, kwargs, follow_children=True):
40
36
    # FIXME: strace is buggy
41
37
    # (https://bugs.launchpad.net/ubuntu/+source/strace/+bug/103133) and the
42
38
    # test suite hangs if the '-f' is given to strace *and* more than one
43
 
    # thread is running. Using follow_children=False allows the test suite to
44
 
    # disable fork following to work around the bug.
45
 
 
 
39
    # thread is running. The following allows the test suite to disable fork
 
40
    # following to work around the bug.  It's a bit dirty to pollute the kwargs
 
41
    # so we take a likely-to-be-unique name to avoid conflicts (*args and
 
42
    # *kwargs are related to 'function').
 
43
    follow_childrens = kwargs.pop('strace_follow_childrens', True)
46
44
    # capture strace output to a file
47
45
    log_file = tempfile.NamedTemporaryFile()
48
46
    log_file_fd = log_file.fileno()
49
47
    pid = os.getpid()
50
48
    # start strace
51
49
    strace_cmd = ['strace', '-r', '-tt', '-p', str(pid), '-o', log_file.name]
52
 
    if follow_children:
 
50
    if follow_childrens:
53
51
        strace_args.append('-f')
54
52
    proc = subprocess.Popen(strace_cmd,
55
53
                            stdout=subprocess.PIPE,