Rev 2567: Fix #102019 by not asking strace to follow children forks during tests. in file:///v/home/vila/src/bugs/102019/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Jul 2 12:07:12 BST 2007


At file:///v/home/vila/src/bugs/102019/

------------------------------------------------------------
revno: 2567
revision-id: v.ladeuil+lp at free.fr-20070702110710-jjzry7iv7hbqinrm
parent: pqm at pqm.ubuntu.com-20070629150144-xoeghcfb52pit8tv
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 102019
timestamp: Mon 2007-07-02 13:07:10 +0200
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.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/strace.py               strace.py-20070323001526-6zquhhw8leb9m6j8-1
  bzrlib/tests/test_strace.py    test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2007-06-28 19:11:00 +0000
+++ b/NEWS	2007-07-02 11:07:10 +0000
@@ -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'
--- a/bzrlib/strace.py	2007-04-04 21:39:03 +0000
+++ b/bzrlib/strace.py	2007-07-02 11:07:10 +0000
@@ -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'
--- a/bzrlib/tests/test_strace.py	2007-04-02 15:50:01 +0000
+++ b/bzrlib/tests/test_strace.py	2007-07-02 11:07:10 +0000
@@ -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')



More information about the bazaar-commits mailing list