summaryrefslogtreecommitdiff
path: root/python/tests
diff options
context:
space:
mode:
authorMike Hommey <glandium@debian.org>2005-03-27 13:13:58 +0000
committerMike Hommey <glandium@debian.org>2005-03-27 13:13:58 +0000
commit50e5b428562964b1eb2f876370058b34b47c5e90 (patch)
treec66bcae6dbbce07128ee881353ff60090524462c /python/tests
parenta7457388701e6ccba9091ba3ec09505dc903b758 (diff)
downloadlibxml2-50e5b428562964b1eb2f876370058b34b47c5e90.tar.gz
Load /tmp/tmp.XJZ6qc/libxml2-2.6.18 intoupstream/2.6.18
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/Makefile.am6
-rw-r--r--python/tests/Makefile.in8
-rwxr-xr-xpython/tests/readernext.py81
-rwxr-xr-xpython/tests/tstmem.py36
4 files changed, 128 insertions, 3 deletions
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am
index 1ae9b6c..f41cd6d 100644
--- a/python/tests/Makefile.am
+++ b/python/tests/Makefile.am
@@ -28,6 +28,7 @@ PYTESTS= \
reader6.py \
reader7.py \
reader8.py \
+ readernext.py \
walker.py \
ctxterror.py\
readererr.py\
@@ -37,7 +38,8 @@ PYTESTS= \
sync.py \
tstLastError.py \
indexes.py \
- dtdvalid.py
+ dtdvalid.py \
+ tstmem.py
XMLS= \
tst.xml \
@@ -52,6 +54,8 @@ tests: $(PYTESTS)
@echo "## running Python regression tests"
-@(PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH" ; \
export PYTHONPATH; \
+ LD_LIBRARY_PATH="$(top_builddir)/.libs:$$LD_LIBRARY_PATH" ; \
+ export LD_LIBRARY_PATH; \
for test in $(PYTESTS) ; \
do log=`$(PYTHON) $(srcdir)/$$test` ; \
if [ "`echo $$log | grep OK`" = "" ] ; then \
diff --git a/python/tests/Makefile.in b/python/tests/Makefile.in
index d13d845..2184681 100644
--- a/python/tests/Makefile.in
+++ b/python/tests/Makefile.in
@@ -123,7 +123,6 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
-PATTERN_TEST = @PATTERN_TEST@
PERL = @PERL@
PYTHON = @PYTHON@
PYTHON_INCLUDES = @PYTHON_INCLUDES@
@@ -146,6 +145,7 @@ TEST_CATALOG = @TEST_CATALOG@
TEST_DEBUG = @TEST_DEBUG@
TEST_HTML = @TEST_HTML@
TEST_MODULES = @TEST_MODULES@
+TEST_PATTERN = @TEST_PATTERN@
TEST_PHTML = @TEST_PHTML@
TEST_PUSH = @TEST_PUSH@
TEST_REGEXPS = @TEST_REGEXPS@
@@ -284,6 +284,7 @@ PYTESTS = \
reader6.py \
reader7.py \
reader8.py \
+ readernext.py \
walker.py \
ctxterror.py\
readererr.py\
@@ -293,7 +294,8 @@ PYTESTS = \
sync.py \
tstLastError.py \
indexes.py \
- dtdvalid.py
+ dtdvalid.py \
+ tstmem.py
XMLS = \
tst.xml \
@@ -465,6 +467,8 @@ uninstall-am: uninstall-info-am
@WITH_PYTHON_TRUE@ @echo "## running Python regression tests"
@WITH_PYTHON_TRUE@ -@(PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH" ; \
@WITH_PYTHON_TRUE@ export PYTHONPATH; \
+@WITH_PYTHON_TRUE@ LD_LIBRARY_PATH="$(top_builddir)/.libs:$$LD_LIBRARY_PATH" ; \
+@WITH_PYTHON_TRUE@ export LD_LIBRARY_PATH; \
@WITH_PYTHON_TRUE@ for test in $(PYTESTS) ; \
@WITH_PYTHON_TRUE@ do log=`$(PYTHON) $(srcdir)/$$test` ; \
@WITH_PYTHON_TRUE@ if [ "`echo $$log | grep OK`" = "" ] ; then \
diff --git a/python/tests/readernext.py b/python/tests/readernext.py
new file mode 100755
index 0000000..b01a49d
--- /dev/null
+++ b/python/tests/readernext.py
@@ -0,0 +1,81 @@
+#!/usr/bin/python -u
+# -*- coding: ISO-8859-1 -*-
+#
+# this tests the next API of the XmlTextReader interface
+#
+import libxml2
+import StringIO
+import sys
+
+# Memory debug specific
+libxml2.debugMemory(1)
+
+f = StringIO.StringIO("""<a><b><c /></b><d>content of d</d></a>""")
+input = libxml2.inputBuffer(f)
+reader = input.newTextReader("test_next")
+ret = reader.Read()
+if ret != 1:
+ print "test_next: Error reading to first element"
+ sys.exit(1)
+if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
+ reader.NodeType() != 1 or reader.HasAttributes() != 0:
+ print "test_next: Error reading the first element"
+ sys.exit(1)
+ret = reader.Read()
+if ret != 1:
+ print "test_next: Error reading to second element"
+ sys.exit(1)
+if reader.Name() != "b" or reader.IsEmptyElement() != 0 or \
+ reader.NodeType() != 1 or reader.HasAttributes() != 0:
+ print "test_next: Error reading the second element"
+ sys.exit(1)
+ret = reader.Read()
+if ret != 1:
+ print "test_next: Error reading to third element"
+ sys.exit(1)
+if reader.Name() != "c" or reader.NodeType() != 1 or \
+ reader.HasAttributes() != 0:
+ print "test_next: Error reading the third element"
+ sys.exit(1)
+ret = reader.Read()
+if ret != 1:
+ print "test_next: Error reading to end of third element"
+ sys.exit(1)
+if reader.Name() != "b" or reader.NodeType() != 15:
+ print "test_next: Error reading to end of second element"
+ sys.exit(1)
+ret = reader.Next()
+if ret != 1:
+ print "test_next: Error moving to third element"
+ sys.exit(1)
+if reader.Name() != "d" or reader.IsEmptyElement() != 0 or \
+ reader.NodeType() != 1 or reader.HasAttributes() != 0:
+ print "test_next: Error reading third element"
+ sys.exit(1)
+ret = reader.Next()
+if ret != 1:
+ print "test_next: Error reading to end of first element"
+ sys.exit(1)
+if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
+ reader.NodeType() != 15 or reader.HasAttributes() != 0:
+ print "test_next: Error reading the end of first element"
+ sys.exit(1)
+ret = reader.Read()
+if ret != 0:
+ print "test_next: Error reading to end of document"
+ sys.exit(1)
+
+#
+# cleanup for memory allocation counting
+#
+del f
+del input
+del reader
+
+# Memory debug specific
+libxml2.cleanupParser()
+if libxml2.debugMemory(1) == 0:
+ print "OK"
+else:
+ print "Memory leak %d bytes" % (libxml2.debugMemory(1))
+ libxml2.dumpMemory()
diff --git a/python/tests/tstmem.py b/python/tests/tstmem.py
new file mode 100755
index 0000000..553096d
--- /dev/null
+++ b/python/tests/tstmem.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python -u
+import libxml2
+import libxml2mod
+import sys
+
+def error(msg, data):
+ pass
+
+# Memory debug specific
+libxml2.debugMemory(1)
+
+dtd="""<!ELEMENT foo EMPTY>"""
+instance="""<?xml version="1.0"?>
+<foo></foo>"""
+
+dtd = libxml2.parseDTD(None, 'test.dtd')
+ctxt = libxml2.newValidCtxt()
+libxml2mod.xmlSetValidErrors(ctxt._o, error, error)
+doc = libxml2.parseDoc(instance)
+ret = doc.validateDtd(ctxt, dtd)
+if ret != 1:
+ print "error doing DTD validation"
+ sys.exit(1)
+
+doc.freeDoc()
+dtd.freeDtd()
+del dtd
+del ctxt
+
+# Memory debug specific
+libxml2.cleanupParser()
+if libxml2.debugMemory(1) == 0:
+ print "OK"
+else:
+ print "Memory leak %d bytes" % (libxml2.debugMemory(1))
+ libxml2.dumpMemory()