xref: /aosp_15_r20/external/libxml2/python/tests/inbuf.py (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1#!/usr/bin/env python3
2import sys
3import setup_test
4import libxml2
5try:
6    import StringIO
7    str_io = StringIO.StringIO
8except:
9    import io
10    str_io = io.StringIO
11
12# Memory debug specific
13libxml2.debugMemory(1)
14
15i = 0
16while i < 5000:
17    f = str_io("foobar")
18    buf = libxml2.inputBuffer(f)
19    i = i + 1
20
21del f
22del buf
23
24# Memory debug specific
25libxml2.cleanupParser()
26if libxml2.debugMemory(1) == 0:
27    print("OK")
28else:
29    print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
30
31