summaryrefslogtreecommitdiff
path: root/python/tests
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2008-09-01 13:38:22 +0000
committerDaniel Veillard <veillard@src.gnome.org>2008-09-01 13:38:22 +0000
commit074f37e7ebd5e76ceb584a89745a9e84df5b3be2 (patch)
tree42c73fde831e9509416729c5f004da54950102b3 /python/tests
parentda3fee406da96c344d7b5f4e0631faee74f7e11d (diff)
downloadlibxml2-074f37e7ebd5e76ceb584a89745a9e84df5b3be2.tar.gz
applied a couple of patches from Martin avoiding some leaks, fixinq QName
* schematron.c xpath.c: applied a couple of patches from Martin avoiding some leaks, fixinq QName checks in XPath, XPath debugging and schematron code cleanups. * python/tests/Makefile.am python/tests/xpathleak.py: add the specific regression tests, just tweak it to avoid output by default Daniel svn path=/trunk/; revision=3791
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/Makefile.am3
-rw-r--r--python/tests/xpathleak.py53
2 files changed, 55 insertions, 1 deletions
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am
index 8a850756..52c89fc3 100644
--- a/python/tests/Makefile.am
+++ b/python/tests/Makefile.am
@@ -46,7 +46,8 @@ PYTESTS= \
validSchemas.py \
validRNG.py \
compareNodes.py \
- xpathns.py
+ xpathns.py \
+ xpathleak.py
XMLS= \
tst.xml \
diff --git a/python/tests/xpathleak.py b/python/tests/xpathleak.py
new file mode 100644
index 00000000..dcc144c1
--- /dev/null
+++ b/python/tests/xpathleak.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+import sys, libxml2
+
+libxml2.debugMemory(True)
+
+expect="""--> Invalid expression
+--> xmlXPathEval: evaluation failed
+--> Invalid expression
+--> xmlXPathEval: evaluation failed
+--> Invalid expression
+--> xmlXPathEval: evaluation failed
+--> Invalid expression
+--> xmlXPathEval: evaluation failed
+--> Invalid expression
+--> xmlXPathEval: evaluation failed
+--> Invalid expression
+--> xmlXPathEval: evaluation failed
+"""
+err=""
+def callback(ctx, str):
+ global err
+
+ err = err + "%s %s" % (ctx, str)
+
+libxml2.registerErrorHandler(callback, "-->")
+
+doc = libxml2.parseDoc("<fish/>")
+ctxt = doc.xpathNewContext()
+ctxt.setContextNode(doc)
+for expr in (":false()","bad:()","bad(:)",":bad(:)","bad:(:)","bad:bad(:)"):
+ try:
+ ctxt.xpathEval(expr)
+ except libxml2.xpathError, e:
+ pass
+ else:
+ print "Unexpectedly legal expression:", expr
+ctxt.xpathFreeContext()
+doc.freeDoc()
+
+if err != expect:
+ print "error"
+ print "received %s" %(err)
+ print "expected %s" %(expect)
+ sys.exit(1)
+
+libxml2.cleanupParser()
+leakedbytes = libxml2.debugMemory(True)
+if leakedbytes == 0:
+ print "OK"
+else:
+ print "Memory leak", leakedbytes, "bytes"
+ # drop file to .memdump file in cwd, but won't work if not compiled in
+ libxml2.dumpMemory()