diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-06-27 20:21:23 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-06-27 20:21:23 +0000 |
commit | 46cedd177d04372e1de7f67759a95c0d19d74ec3 (patch) | |
tree | 7329bcc875a4b1d45361d6bf0acb4fad16f20219 /rdiff-backup/rdiff_backup/librsync_memoryleak2.py | |
parent | 3f44ce4239acd911683f05266934aa136538a3d9 (diff) | |
download | rdiff-backup-46cedd177d04372e1de7f67759a95c0d19d74ec3.tar.gz |
Directly interface to librsync instead of going through rdiff. Added
some supplementary scripts for testing.
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@149 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/librsync_memoryleak2.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/librsync_memoryleak2.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/rdiff-backup/rdiff_backup/librsync_memoryleak2.py b/rdiff-backup/rdiff_backup/librsync_memoryleak2.py new file mode 100644 index 0000000..72400b2 --- /dev/null +++ b/rdiff-backup/rdiff_backup/librsync_memoryleak2.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +"""Demonstrate a memory leak in pysync/librsync""" + +import os, _librsync +from librsync import * + +os.chdir("/tmp") + +# Write 2 1 byte files +afile = open("a", "wb") +afile.write("a") +afile.close() + +efile = open("e", "wb") +efile.write("e") +efile.close() + +def copy(infileobj, outpath): + outfile = open(outpath, "wb") + while 1: + buf = infileobj.read(32768) + if not buf: break + outfile.write(buf) + assert not outfile.close() + assert not infileobj.close() + +def test_cycle(): + for i in xrange(100000): + sm = _librsync.new_sigmaker() + sm.cycle("a") + +def main_test(): + for i in xrange(100000): + # Write signature file + afile = open("a", "rb") + copy(SigFile(afile), "sig") + + # Write delta file + efile = open("e", "r") + sigfile = open("sig", "rb") + copy(DeltaFile(sigfile, efile), "delta") + + # Write patched file + afile = open("e", "rb") + deltafile = open("delta", "rb") + copy(PatchedFile(afile, deltafile), "a.out") + +main_test() |