~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/strace.py

  • Committer: Vincent Ladeuil
  • Date: 2007-06-28 12:26:11 UTC
  • mto: (2581.1.1 cleanup-runbzr)
  • mto: This revision was merged to the branch mainline in revision 2588.
  • Revision ID: v.ladeuil+lp@free.fr-20070628122611-0suhzl7o6aep1ibz
Revert the intrusive run_bzr('commit') rewritings.

* bzrlib/tests/test_smart_add.py:
(TestSmartAdd.test_add_dry_run,
TestSmartAdd.test_returns_and_ignores):  Delete useless import.

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
 
    # FIXME: strace is buggy
41
 
    # (https://bugs.launchpad.net/ubuntu/+source/strace/+bug/103133) and the
42
 
    # 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
 
 
46
36
    # capture strace output to a file
47
37
    log_file = tempfile.NamedTemporaryFile()
48
38
    log_file_fd = log_file.fileno()
49
39
    pid = os.getpid()
50
40
    # start strace
51
 
    strace_cmd = ['strace', '-r', '-tt', '-p', str(pid), '-o', log_file.name]
52
 
    if follow_children:
53
 
        strace_args.append('-f')
54
 
    proc = subprocess.Popen(strace_cmd,
55
 
                            stdout=subprocess.PIPE,
56
 
                            stderr=subprocess.STDOUT)
 
41
    proc = subprocess.Popen(['strace',
 
42
        '-f', '-r', '-tt', '-p', str(pid), '-o', log_file.name
 
43
        ],
 
44
        stdout=subprocess.PIPE,
 
45
        stderr=subprocess.STDOUT)
57
46
    # Wait for strace to attach
58
47
    attached_notice = proc.stdout.readline()
59
48
    # Run the function to strace