VirtualBox

source: vbox/trunk/src/libs/libxml2-2.9.14/python/tests/tstmem.py@ 95312

Last change on this file since 95312 was 95312, checked in by vboxsync, 3 years ago

libs/{curl,libxml2}: OSE export fixes, bugref:8515

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 797 bytes
Line 
1#!/usr/bin/python -u
2import libxml2
3
4try:
5 import libxml2mod
6except ModuleNotFoundError:
7 from libxmlmods import libxml2mod
8
9import sys
10
11def error(msg, data):
12 pass
13
14# Memory debug specific
15libxml2.debugMemory(1)
16
17dtd="""<!ELEMENT foo EMPTY>"""
18instance="""<?xml version="1.0"?>
19<foo></foo>"""
20
21dtd = libxml2.parseDTD(None, 'test.dtd')
22ctxt = libxml2.newValidCtxt()
23libxml2mod.xmlSetValidErrors(ctxt._o, error, error)
24doc = libxml2.parseDoc(instance)
25ret = doc.validateDtd(ctxt, dtd)
26if ret != 1:
27 print("error doing DTD validation")
28 sys.exit(1)
29
30doc.freeDoc()
31dtd.freeDtd()
32del dtd
33del ctxt
34
35# Memory debug specific
36libxml2.cleanupParser()
37if libxml2.debugMemory(1) == 0:
38 print("OK")
39else:
40 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
41 libxml2.dumpMemory()
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette