Rev 2585: Fix #102019 by not asking strace to follow children in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jul 4 15:02:11 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2585
revision-id: pqm at pqm.ubuntu.com-20070704140209-ldl1njlpcclszadu
parent: pqm at pqm.ubuntu.com-20070704095320-41p0gvstimqqzvtx
parent: abentley at panoramicfeedback.com-20070704131450-b3158abbethvwvob
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-07-04 15:02:09 +0100
message:
  Fix #102019 by not asking strace to follow children
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/strace.py               strace.py-20070323001526-6zquhhw8leb9m6j8-1
  bzrlib/tests/test_strace.py    test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
    ------------------------------------------------------------
    revno: 2584.1.1
    merged: abentley at panoramicfeedback.com-20070704131450-b3158abbethvwvob
    parent: pqm at pqm.ubuntu.com-20070704095320-41p0gvstimqqzvtx
    parent: v.ladeuil+lp at free.fr-20070703092859-yl7j53209tfmhf7u
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's integration
    timestamp: Wed 2007-07-04 09:14:50 -0400
    message:
      Fix #102019 by not asking strace to follow children
    ------------------------------------------------------------
    revno: 2566.3.4
    merged: v.ladeuil+lp at free.fr-20070703092859-yl7j53209tfmhf7u
    parent: v.ladeuil+lp at free.fr-20070702152123-hkfs15u2m87nxrcf
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 102019
    timestamp: Tue 2007-07-03 11:28:59 +0200
    message:
      Take Martin and Robert comments into account.
      
      * bzrlib/strace.py:
      (strace): is now a wrapper that calls strace_detailed.
      (strace_detailed): like strace before but with an option to
      disable following forked children without polluting the kwargs
      param.
      
      * bzrlib/tests/test_strace.py:
      (TestStrace.test_strace_callable_is_called,
      TestStrace.test_strace_callable_result,
      TestStrace.test_strace_result_has_raw_log): use strace_detailed
      while disabling following forked children, the syntax is a bit
      uglier but non-test users should never use anyway..
    ------------------------------------------------------------
    revno: 2566.3.3
    merged: v.ladeuil+lp at free.fr-20070702152123-hkfs15u2m87nxrcf
    parent: v.ladeuil+lp at free.fr-20070702140940-oz36hfh6hcihlgbj
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 102019
    timestamp: Mon 2007-07-02 17:21:23 +0200
    message:
      Don't use '_' for unused variable to ease future support pf i18n.
    ------------------------------------------------------------
    revno: 2566.3.2
    merged: v.ladeuil+lp at free.fr-20070702140940-oz36hfh6hcihlgbj
    parent: v.ladeuil+lp at free.fr-20070702110710-jjzry7iv7hbqinrm
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 102019
    timestamp: Mon 2007-07-02 16:09:40 +0200
    message:
      Fix typo, add comment, following Martin's review.
    ------------------------------------------------------------
    revno: 2566.3.1
    merged: 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 file 'NEWS'
--- a/NEWS	2007-07-04 09:21:56 +0000
+++ b/NEWS	2007-07-04 13:14:50 +0000
@@ -27,6 +27,9 @@
     * Don't leave cruft behind when failing to acquire a lockdir.
       (Martin Pool, #109169)
 
+    * 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-03 09:28:59 +0000
@@ -33,16 +33,27 @@
 
     :return: a tuple: function-result, a StraceResult.
     """
+    return strace_detailed(function, args, kwargs)
+
+
+def strace_detailed(function, args, kwargs, follow_children=True):
+    # 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. Using follow_children=False allows the test suite to
+    # disable fork following to work around the bug.
+
     # 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_children:
+        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-03 09:28:59 +0000
@@ -20,7 +20,7 @@
 import errno
 import subprocess
 
-from bzrlib.strace import StraceFeature, strace, StraceResult
+from bzrlib.strace import StraceFeature, strace_detailed, StraceResult
 from bzrlib.tests import TestCaseWithTransport
 
 
@@ -51,13 +51,15 @@
         output = []
         def function(positional, *args, **kwargs):
             output.append((positional, args, kwargs))
-        strace(function, "a", "b", c="c")
+        strace_detailed(function, ["a", "b"], {"c": "c"},
+                        follow_children=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_detailed(function,[], {},
+                                                follow_children=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)
+        unused, result = strace_detailed(function, [], {},
+                                         follow_children=False)
         self.assertContainsRe(result.raw_log, 'myfile')




More information about the bazaar-commits mailing list