3 # this test exercise the XPath basic engine, parser, etc, and
4 # allows to detect memory leaks
9 # Memory debug specific
10 libxml2
.debugMemory(1)
12 doc
= libxml2
.parseFile("tst.xml")
13 if doc
.name
!= "tst.xml":
14 print "doc.name error"
17 ctxt
= doc
.xpathNewContext()
18 res
= ctxt
.xpathEval("//*")
20 print "xpath query: wrong node set size"
22 if res
[0].name
!= "doc" or res
[1].name
!= "foo":
23 print "xpath query: wrong node set value"
25 ctxt
.setContextNode(res
[0])
26 res
= ctxt
.xpathEval("foo")
28 print "xpath query: wrong node set size"
30 if res
[0].name
!= "foo":
31 print "xpath query: wrong node set value"
34 ctxt
.xpathFreeContext()
37 doc
= libxml2
.parseFile("tst.xml")
38 ctxt
= doc
.xpathNewContext()
39 res
= ctxt
.xpathEval("//*")
41 ctxt
.xpathFreeContext()
45 # Memory debug specific
46 libxml2
.cleanupParser()
47 if libxml2
.debugMemory(1) == 0:
50 print "Memory leak %d bytes" % (libxml2
.debugMemory(1))