blob: d4049b8699dfa6d00dcf33f7ed04577a3caf4e3c [file] [log] [blame]
Daniel Veillard850ce9b2004-11-10 11:55:47 +00001#!/usr/bin/python -u
2import libxml2
3import sys
4
5# Memory debug specific
6libxml2.debugMemory(1)
7
8dtd="""<!ELEMENT foo EMPTY>"""
9instance="""<?xml version="1.0"?>
10<foo></foo>"""
11
12dtd = libxml2.parseDTD(None, 'test.dtd')
13ctxt = libxml2.newValidCtxt()
14doc = libxml2.parseDoc(instance)
15ret = doc.validateDtd(ctxt, dtd)
16if ret != 1:
Daniel Veillard2cb6bf82013-03-30 21:38:20 +080017 print("error doing DTD validation")
Daniel Veillard850ce9b2004-11-10 11:55:47 +000018 sys.exit(1)
19
20doc.freeDoc()
21dtd.freeDtd()
22del dtd
23del ctxt
24
25# Memory debug specific
26libxml2.cleanupParser()
27if libxml2.debugMemory(1) == 0:
Daniel Veillard2cb6bf82013-03-30 21:38:20 +080028 print("OK")
Daniel Veillard850ce9b2004-11-10 11:55:47 +000029else:
Daniel Veillard2cb6bf82013-03-30 21:38:20 +080030 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
Daniel Veillard850ce9b2004-11-10 11:55:47 +000031 libxml2.dumpMemory()
32