~ed.so/duplicity/reuse-passphrase-for-signing-fix

« back to all changes in this revision

Viewing changes to testing/memcheck.py

  • Committer: bescoto
  • Date: 2002-10-29 01:49:46 UTC
  • Revision ID: vcs-imports@canonical.com-20021029014946-3m4rmm5plom7pl6q
Initial checkin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Check for memory leak in tarfile.py.
 
2
 
 
3
Before somehow reading from a _FileObject as returned by extractfile()
 
4
would cause a memory leak.
 
5
 
 
6
"""
 
7
 
 
8
import sys, gzip, os, random
 
9
sys.path.insert(0, "../src")
 
10
import tarfile
 
11
 
 
12
def main():
 
13
        #gzipfile = gzip.GzipFile("/root/.duplicity/full/duplicity-signatures.2002-08-06T22:07:07-07:00.sigtar.gz", "rb")
 
14
        #gzipfile = os.popen("zcat /root/.duplicity/full/duplicity-signatures.2002-08-06T22:07:07-07:00.sigtar.gz")
 
15
        gzipfile = gzip.GzipFile(None, "r", 9,
 
16
                                                         open("/root/.duplicity/full/duplicity-signatures.2002-08-06T22:07:07-07:00.sigtar.gz", "rb"))
 
17
        tf =  tarfile.TarFile("none", "r", gzipfile)
 
18
        i = 0
 
19
        for tarinfo in tf:
 
20
                print tarinfo.name, i, tarinfo.size
 
21
                i += 1
 
22
                if tarinfo.isreg():
 
23
                        fileobj = tf.extractfile(tarinfo)
 
24
                        #buf = fileobj.read()
 
25
                        buf = tf.fileobj.read(tarinfo.size)
 
26
                        tf.offset += tarinfo.size
 
27
 
 
28
def main2():
 
29
        gzipfile  = gzip.GzipFile("/root/.duplicity/full/duplicity-signatures.2002-08-06T22:07:07-07:00.sigtar.gz", "rb")
 
30
 
 
31
        while 1:
 
32
                buf = gzipfile.read(random.randrange(0, 500000))
 
33
                #buf = gzipfile.read(500000)
 
34
                if not buf: break
 
35
 
 
36
 
 
37
main2()