No subject
Thu Jun 28 14:57:16 BST 2007
-f Trace child processes as they are created by cur=E2=
=80=90
rently traced processes as a result of the fork(2)
system call.
This is not needed during the tests, so far, so I disabled the
option for them.
Vincent
--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline; filename=102019.patch
# Bazaar revision bundle v0.9
#
# message:
# 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.
#
# committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
# date: Mon 2007-07-02 13:07:10.010999918 +0200
=== modified file NEWS
--- NEWS
+++ NEWS
@@ -9,6 +9,9 @@
a file that is not present in the specified revision.
(James Westby, #122656)
+ * Don't use the '-f' strace option during tests.
+ (Vincent Ladeuil, #102019).
+
IMPROVEMENTS:
* The --lsprof-file option now dumps a text rendering of the profiling
=== modified file bzrlib/strace.py
--- bzrlib/strace.py
+++ bzrlib/strace.py
@@ -33,16 +33,25 @@
:return: a tuple: function-result, a StraceResult.
"""
+ # FIXME: strace is buggy
+ # (https://bugs.launchpad.net/ubuntu/+source/strace/+bug/103133) and the
+ # test suite hangs if the '-f' is given to strace *and* more than one
+ # thread is running. The following allows the test suite to disable fork
+ # following to work around the bug. It's a bit dirty to pollute the kwargs
+ # so we take a likely-to-be-unique name to avoid conflicts (*args and
+ # *kwargs are related to 'function').
+ follow_childrens = kwargs.pop('strace_follow_childrens', True)
# capture strace output to a file
log_file = tempfile.NamedTemporaryFile()
log_file_fd = log_file.fileno()
pid = os.getpid()
# start strace
- proc = subprocess.Popen(['strace',
- '-f', '-r', '-tt', '-p', str(pid), '-o', log_file.name
- ],
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
+ strace_cmd = ['strace', '-r', '-tt', '-p', str(pid), '-o', log_file.name]
+ if follow_childrens:
+ strace_args.append('-f')
+ proc = subprocess.Popen(strace_cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
# Wait for strace to attach
attached_notice = proc.stdout.readline()
# Run the function to strace
=== modified file bzrlib/tests/test_strace.py
--- bzrlib/tests/test_strace.py
+++ bzrlib/tests/test_strace.py
@@ -51,13 +51,15 @@
output = []
def function(positional, *args, **kwargs):
output.append((positional, args, kwargs))
- strace(function, "a", "b", c="c")
+ strace(function, "a", "b", c="c",
+ strace_follow_childrens=False)
self.assertEqual([("a", ("b",), {"c":"c"})], output)
def test_strace_callable_result(self):
def function():
return "foo"
- result, strace_result = strace(function)
+ result, strace_result = strace(function,
+ strace_follow_childrens=False)
self.assertEqual("foo", result)
self.assertIsInstance(strace_result, StraceResult)
@@ -65,5 +67,6 @@
"""Checks that a reasonable raw strace log was found by strace."""
def function():
self.build_tree(['myfile'])
- _, result = strace(function)
+ _, result = strace(function,
+ strace_follow_childrens=False)
self.assertContainsRe(result.raw_log, 'myfile')
=== modified directory // last-changed:v.ladeuil+lp at free.fr-20070702110710-jjz
... ry7iv7hbqinrm
# revision id: v.ladeuil+lp at free.fr-20070702110710-jjzry7iv7hbqinrm
# sha1: 2cf13cab6e7042a7450db3a9a9e40188028d7051
# inventory sha1: c58c35e582f779d2dc56e71b1e6d702cf698119c
# parent ids:
# pqm at pqm.ubuntu.com-20070629150144-xoeghcfb52pit8tv
# base id: pqm at pqm.ubuntu.com-20070629150144-xoeghcfb52pit8tv
# properties:
# branch-nick: 102019
--=-=-=--
More information about the bazaar
mailing list