Commit eb70f93f authored by Daniel Veillard's avatar Daniel Veillard
Browse files

make the push interfaces synchronous added a specific test added the new

* parser.c: make the push interfaces synchronous
* python/tests/sync.py: added a specific test
* python/tests/Makefile.am doc/examples/Makefile.am
  doc/examples/index.py: added the new test, cleaning up
  "make tests" output
Daniel
parent f4b05d0a
Mon Jul 5 18:43:47 CEST 2004 Daniel Veillard <daniel@veillard.com>
* parser.c: make the push interfaces synchronous
* python/tests/sync.py: added a specific test
* python/tests/Makefile.am doc/examples/Makefile.am
doc/examples/index.py: added the new test, cleaning up
"make tests" output
Mon Jul 5 15:09:17 CEST 2004 Daniel Veillard <daniel@veillard.com>
 
* xmlschemas.c: applied patch from Kasimier to fix some Relax-NG
......
......@@ -93,6 +93,7 @@ valgrind:
$(MAKE) CHECKER='valgrind -q' tests
tests: $(noinst_PROGRAMS)
@(echo '## examples regression tests')
@(echo > .memdump)
@($(CHECKER) ././xpath1 test3.xml '//child2' > xpath1.tmp ; diff xpath1.tmp xpath1.res ; rm xpath1.tmp)
@(grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0)
......
This diff is collapsed.
......@@ -251,6 +251,7 @@ install-data-local:
example, example)
Makefile = Makefile + "valgrind: \n\t$(MAKE) CHECKER='valgrind -q' tests\n\n"
Makefile = Makefile + "tests: $(noinst_PROGRAMS)\n"
Makefile = Makefile + "\t@(echo '## examples regression tests')\n"
Makefile = Makefile + "\t@(echo > .memdump)\n"
for test in tests:
Makefile = Makefile + "\t@($(CHECKER) %s)\n" % (test)
......
......@@ -8818,29 +8818,37 @@ xmlParseGetLasts(xmlParserCtxtPtr ctxt, const xmlChar **lastlt,
if ((ctxt->progressive != 0) && (ctxt->inputNr == 1)) {
tmp = ctxt->input->end;
tmp--;
while ((tmp >= ctxt->input->base) && (*tmp != '<') &&
(*tmp != '>')) tmp--;
while ((tmp >= ctxt->input->base) && (*tmp != '<')) tmp--;
if (tmp < ctxt->input->base) {
*lastlt = NULL;
*lastgt = NULL;
} else if (*tmp == '<') {
} else {
*lastlt = tmp;
tmp--;
while ((tmp >= ctxt->input->base) && (*tmp != '>')) tmp--;
if (tmp < ctxt->input->base)
*lastgt = NULL;
else
tmp++;
while ((tmp < ctxt->input->end) && (*tmp != '>')) {
if (*tmp == '\'') {
tmp++;
while ((tmp < ctxt->input->end) && (*tmp != '\'')) tmp++;
if (tmp < ctxt->input->end) tmp++;
} else if (*tmp == '"') {
tmp++;
while ((tmp < ctxt->input->end) && (*tmp != '"')) tmp++;
if (tmp < ctxt->input->end) tmp++;
} else
tmp++;
}
if (tmp < ctxt->input->end)
*lastgt = tmp;
} else {
*lastgt = tmp;
tmp--;
while ((tmp >= ctxt->input->base) && (*tmp != '<')) tmp--;
if (tmp < ctxt->input->base)
*lastlt = NULL;
else
*lastlt = tmp;
else {
tmp = *lastlt;
tmp--;
while ((tmp >= ctxt->input->base) && (*tmp != '>')) tmp--;
if (tmp >= ctxt->input->base)
*lastgt = tmp;
else
*lastgt = NULL;
}
}
} else {
*lastlt = NULL;
*lastgt = NULL;
......@@ -9096,7 +9104,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
if (!terminate) {
if (ctxt->progressive) {
/* > can be found unescaped in attribute values */
if ((lastlt == NULL) || (ctxt->input->cur >= lastlt))
if ((lastgt == NULL) || (ctxt->input->cur >= lastgt))
goto done;
} else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
goto done;
......@@ -9274,7 +9282,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
goto done;
if (!terminate) {
if (ctxt->progressive) {
if ((lastgt == NULL) || (ctxt->input->cur > lastgt))
/* > can be found unescaped in attribute values */
if ((lastgt == NULL) || (ctxt->input->cur >= lastgt))
goto done;
} else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
goto done;
......
......@@ -33,6 +33,7 @@ PYTESTS= \
readererr.py\
relaxng.py \
thread2.py \
sync.py \
tstLastError.py \
indexes.py
......@@ -45,8 +46,13 @@ EXTRA_DIST = $(PYTESTS) $(XMLS)
if WITH_PYTHON
tests: $(PYTESTS)
-@(PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH" ; export PYTHONPATH; \
for test in $(PYTESTS) ; do echo "-- $$test" ; $(PYTHON) $(srcdir)/$$test ; done)
echo "## running Python regression tests"
-@(PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH" ; \
export PYTHONPATH; \
for test in $(PYTESTS) ; \
do log=`$(PYTHON) $(srcdir)/$$test` ; \
if [ "`echo $$log | grep OK`" = "" ] ; then \
echo "-- $$test" ; echo "$$log" ; fi ; done)
else
tests:
endif
......
#!/usr/bin/python -u
import sys
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
log = ""
class callback:
def startDocument(self):
global log
log = log + "startDocument:"
def endDocument(self):
global log
log = log + "endDocument:"
def startElement(self, tag, attrs):
global log
log = log + "startElement %s %s:" % (tag, attrs)
def endElement(self, tag):
global log
log = log + "endElement %s:" % (tag)
def characters(self, data):
global log
log = log + "characters: %s:" % (data)
def warning(self, msg):
global log
log = log + "warning: %s:" % (msg)
def error(self, msg):
global log
log = log + "error: %s:" % (msg)
def fatalError(self, msg):
global log
log = log + "fatalError: %s:" % (msg)
handler = callback()
log=""
chunk="""<foo><bar2/>"""
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
ctxt.parseChunk(chunk, len(chunk), 0)
ctxt=None
reference = "startDocument:startElement foo None:startElement bar2 None:endElement bar2:"
if log != reference:
print "Error got: %s" % log
print "Exprected: %s" % reference
sys.exit(1)
log=""
chunk="""<foo><bar2></bar2>"""
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
ctxt.parseChunk(chunk, len(chunk), 0)
ctxt=None
reference = "startDocument:startElement foo None:startElement bar2 None:endElement bar2:"
if log != reference:
print "Error got: %s" % log
print "Exprected: %s" % reference
sys.exit(1)
log=""
chunk="""<foo><bar2>"""
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
ctxt.parseChunk(chunk, len(chunk), 0)
ctxt=None
reference = "startDocument:startElement foo None:startElement bar2 None:"
if log != reference:
print "Error got: %s" % log
print "Exprected: %s" % reference
sys.exit(1)
log=""
chunk="""<foo><bar2 a="1" b='2' />"""
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
ctxt.parseChunk(chunk, len(chunk), 0)
ctxt=None
reference = "startDocument:startElement foo None:startElement bar2 {'a': '1', 'b': '2'}:endElement bar2:"
if log != reference:
print "Error got: %s" % log
print "Exprected: %s" % reference
sys.exit(1)
log=""
chunk="""<foo><bar2 a="1" b='2' >"""
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
ctxt.parseChunk(chunk, len(chunk), 0)
ctxt=None
reference = "startDocument:startElement foo None:startElement bar2 {'a': '1', 'b': '2'}:"
if log != reference:
print "Error got: %s" % log
print "Exprected: %s" % reference
sys.exit(1)
log=""
chunk="""<foo><bar2 a="1" b='2' ></bar2>"""
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
ctxt.parseChunk(chunk, len(chunk), 0)
ctxt=None
reference = "startDocument:startElement foo None:startElement bar2 {'a': '1', 'b': '2'}:endElement bar2:"
if log != reference:
print "Error got: %s" % log
print "Exprected: %s" % reference
sys.exit(1)
log=""
chunk="""<foo><bar2 a="b='1' />"""
ctxt = libxml2.createPushParser(handler, None, 0, "test.xml")
ctxt.parseChunk(chunk, len(chunk), 0)
ctxt=None
reference = "startDocument:startElement foo None:"
if log != reference:
print "Error got: %s" % log
print "Exprected: %s" % reference
sys.exit(1)
# Memory debug specific
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
print "OK"
else:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment