Rev 2578: (Vincent Ladeuil) Fix bug #102019 by not supplying '-f' to strace during the test suite. in http://bzr.arbash-meinel.com/branches/bzr/jam-integration

John Arbash Meinel john at arbash-meinel.com
Tue Jul 3 14:49:40 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/jam-integration

------------------------------------------------------------
revno: 2578
revision-id: john at arbash-meinel.com-20070703134926-vctz8e21lhsds3qt
parent: pqm at pqm.ubuntu.com-20070703083649-cbfyk0jt0itbktgb
parent: v.ladeuil+lp at free.fr-20070703092859-yl7j53209tfmhf7u
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Tue 2007-07-03 08:49:26 -0500
message:
  (Vincent Ladeuil) Fix bug #102019 by not supplying '-f' to strace during the test suite.
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: 2566.2.4
    revision-id: 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..
    modified:
      bzrlib/strace.py               strace.py-20070323001526-6zquhhw8leb9m6j8-1
      bzrlib/tests/test_strace.py    test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
    ------------------------------------------------------------
    revno: 2566.2.3
    revision-id: 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.
    modified:
      bzrlib/tests/test_strace.py    test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
    ------------------------------------------------------------
    revno: 2566.2.2
    revision-id: 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.
    modified:
      bzrlib/strace.py               strace.py-20070323001526-6zquhhw8leb9m6j8-1
      bzrlib/tests/test_strace.py    test_strace.py-20070323001526-6zquhhw8leb9m6j8-2
    ------------------------------------------------------------
    revno: 2566.2.1
    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-07-03 08:36:49 +0000
+++ b/NEWS	2007-07-03 13:49:26 +0000
@@ -12,6 +12,9 @@
     * Commands that use status flags now have a reference to 'help
       status-flags'.  (Daniel Watkins, #113436)
 
+    * 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