VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/python/tests/tstmem.py

Last change on this file was 105420, checked in by vboxsync, 7 months ago

libxml2-2.12.6: Applied and adjusted our libxml2 changes to 2.12.6. bugref:10730

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