mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-14 20:01:04 +03:00
added "relaxng" option to the debugging shell some regression tests for
* debugXML.c: added "relaxng" option to the debugging shell * Makefile.am test/errors/* result/errors/*: some regression tests for some error tests cases. Daniel
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
Sat Feb 21 13:52:30 CET 2004 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* debugXML.c: added "relaxng" option to the debugging shell
|
||||||
|
* Makefile.am test/errors/* result/errors/*: some regression tests
|
||||||
|
for some error tests cases.
|
||||||
|
|
||||||
Fri Feb 20 09:56:47 CET 2004 Daniel Veillard <daniel@veillard.com>
|
Fri Feb 20 09:56:47 CET 2004 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* tree.c: xmlAttrSerializeTxtContent don't segfault if NULL
|
* tree.c: xmlAttrSerializeTxtContent don't segfault if NULL
|
||||||
|
41
Makefile.am
41
Makefile.am
@ -122,7 +122,7 @@ check-local: tests
|
|||||||
|
|
||||||
testall : tests SVGtests SAXtests
|
testall : tests SVGtests SAXtests
|
||||||
|
|
||||||
tests: XMLtests XMLenttests NStests @READER_TEST@ @TEST_SAX@ @TEST_PUSH@ @TEST_HTML@ @TEST_PHTML@ @TEST_VALID@ URItests @TEST_XPATH@ @TEST_XPTR@ @TEST_XINCLUDE@ @TEST_C14N@ @TEST_DEBUG@ @TEST_CATALOG@ @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@ Timingtests @TEST_VTIME@
|
tests: XMLtests XMLenttests NStests Errtests @READER_TEST@ @TEST_SAX@ @TEST_PUSH@ @TEST_HTML@ @TEST_PHTML@ @TEST_VALID@ URItests @TEST_XPATH@ @TEST_XPTR@ @TEST_XINCLUDE@ @TEST_C14N@ @TEST_DEBUG@ @TEST_CATALOG@ @TEST_REGEXPS@ @TEST_SCHEMAS@ @TEST_THREADS@ Timingtests @TEST_VTIME@
|
||||||
@(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; $(MAKE) tests ; fi)
|
@(if [ "@PYTHON_SUBDIR@" != "" ] ; then cd python ; $(MAKE) tests ; fi)
|
||||||
@(cd doc/examples ; $(MAKE) tests)
|
@(cd doc/examples ; $(MAKE) tests)
|
||||||
|
|
||||||
@ -281,6 +281,45 @@ NStests : xmllint$(EXEEXT)
|
|||||||
rm result.$$name error.$$name ; \
|
rm result.$$name error.$$name ; \
|
||||||
fi ; fi ; done)
|
fi ; fi ; done)
|
||||||
|
|
||||||
|
Errtests : xmllint$(EXEEXT)
|
||||||
|
@(echo > .memdump)
|
||||||
|
@echo "## Error cases regression tests"
|
||||||
|
-@(for i in $(srcdir)/test/errors/*.xml ; do \
|
||||||
|
name=`basename $$i`; \
|
||||||
|
if [ ! -d $$i ] ; then \
|
||||||
|
if [ ! -f $(srcdir)/result/errors/$$name ] ; then \
|
||||||
|
echo New test file $$name ; \
|
||||||
|
$(CHECKER) $(top_builddir)/xmllint $$i \
|
||||||
|
2> $(srcdir)/result/errors/$$name.err \
|
||||||
|
> $(srcdir)/result/errors/$$name ; \
|
||||||
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \
|
||||||
|
else \
|
||||||
|
log=`$(CHECKER) $(top_builddir)/xmllint $$i 2> error.$$name > result.$$name ; \
|
||||||
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \
|
||||||
|
diff $(srcdir)/result/errors/$$name result.$$name ; \
|
||||||
|
diff $(srcdir)/result/errors/$$name.err error.$$name` ; \
|
||||||
|
if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
|
||||||
|
rm result.$$name error.$$name ; \
|
||||||
|
fi ; fi ; done)
|
||||||
|
@echo "## Error cases stream regression tests"
|
||||||
|
-@(for i in $(srcdir)/test/errors/*.xml ; do \
|
||||||
|
name=`basename $$i`; \
|
||||||
|
if [ ! -d $$i ] ; then \
|
||||||
|
if [ ! -f $(srcdir)/result/errors/$$name.str ] ; then \
|
||||||
|
echo New test file $$name ; \
|
||||||
|
$(CHECKER) $(top_builddir)/xmllint $$i \
|
||||||
|
2> $(srcdir)/result/errors/$$name.str \
|
||||||
|
> $(srcdir)/result/errors/$$name ; \
|
||||||
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \
|
||||||
|
else \
|
||||||
|
log=`$(CHECKER) $(top_builddir)/xmllint $$i 2> error.$$name > result.$$name ; \
|
||||||
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \
|
||||||
|
diff $(srcdir)/result/errors/$$name result.$$name ; \
|
||||||
|
diff $(srcdir)/result/errors/$$name.str error.$$name` ; \
|
||||||
|
if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
|
||||||
|
rm result.$$name error.$$name ; \
|
||||||
|
fi ; fi ; done)
|
||||||
|
|
||||||
Docbtests : xmllint$(EXEEXT)
|
Docbtests : xmllint$(EXEEXT)
|
||||||
|
|
||||||
XMLenttests : xmllint$(EXEEXT)
|
XMLenttests : xmllint$(EXEEXT)
|
||||||
|
66
debugXML.c
66
debugXML.c
@ -30,6 +30,9 @@
|
|||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
#include <libxml/xpathInternals.h>
|
#include <libxml/xpathInternals.h>
|
||||||
#include <libxml/uri.h>
|
#include <libxml/uri.h>
|
||||||
|
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||||
|
#include <libxml/relaxng.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlDebugDumpString:
|
* xmlDebugDumpString:
|
||||||
@ -1668,6 +1671,62 @@ xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||||
|
/**
|
||||||
|
* xmlShellRNGValidate:
|
||||||
|
* @ctxt: the shell context
|
||||||
|
* @schemas: the path to the Relax-NG schemas
|
||||||
|
* @node: a node
|
||||||
|
* @node2: unused
|
||||||
|
*
|
||||||
|
* Implements the XML shell function "relaxng"
|
||||||
|
* validating the instance against a Relax-NG schemas
|
||||||
|
*
|
||||||
|
* Returns 0
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xmlShellRNGValidate(xmlShellCtxtPtr sctxt, char *schemas,
|
||||||
|
xmlNodePtr node ATTRIBUTE_UNUSED,
|
||||||
|
xmlNodePtr node2 ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
xmlRelaxNGPtr relaxngschemas;
|
||||||
|
xmlRelaxNGParserCtxtPtr ctxt;
|
||||||
|
xmlRelaxNGValidCtxtPtr vctxt;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ctxt = xmlRelaxNGNewParserCtxt(schemas);
|
||||||
|
xmlRelaxNGSetParserErrors(ctxt,
|
||||||
|
(xmlRelaxNGValidityErrorFunc) fprintf,
|
||||||
|
(xmlRelaxNGValidityWarningFunc) fprintf,
|
||||||
|
stderr);
|
||||||
|
relaxngschemas = xmlRelaxNGParse(ctxt);
|
||||||
|
xmlRelaxNGFreeParserCtxt(ctxt);
|
||||||
|
if (relaxngschemas == NULL) {
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Relax-NG schema %s failed to compile\n", schemas);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
vctxt = xmlRelaxNGNewValidCtxt(relaxngschemas);
|
||||||
|
xmlRelaxNGSetValidErrors(vctxt,
|
||||||
|
(xmlRelaxNGValidityErrorFunc) fprintf,
|
||||||
|
(xmlRelaxNGValidityWarningFunc) fprintf,
|
||||||
|
stderr);
|
||||||
|
ret = xmlRelaxNGValidateDoc(vctxt, sctxt->doc);
|
||||||
|
if (ret == 0) {
|
||||||
|
fprintf(stderr, "%s validates\n", sctxt->filename);
|
||||||
|
} else if (ret > 0) {
|
||||||
|
fprintf(stderr, "%s fails to validate\n", sctxt->filename);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s validation generated an internal error\n",
|
||||||
|
sctxt->filename);
|
||||||
|
}
|
||||||
|
xmlRelaxNGFreeValidCtxt(vctxt);
|
||||||
|
if (relaxngschemas != NULL)
|
||||||
|
xmlRelaxNGFree(relaxngschemas);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
/**
|
/**
|
||||||
* xmlShellCat:
|
* xmlShellCat:
|
||||||
@ -2191,11 +2250,18 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
|||||||
fprintf(ctxt->output, "\twrite [name] write the current node to the filename\n");
|
fprintf(ctxt->output, "\twrite [name] write the current node to the filename\n");
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
fprintf(ctxt->output, "\tvalidate check the document for errors\n");
|
fprintf(ctxt->output, "\tvalidate check the document for errors\n");
|
||||||
|
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||||
|
fprintf(ctxt->output, "\trelaxng rng validate the document agaisnt the Relax-NG schemas\n");
|
||||||
|
#endif
|
||||||
fprintf(ctxt->output, "\tgrep string search for a string in the subtree\n");
|
fprintf(ctxt->output, "\tgrep string search for a string in the subtree\n");
|
||||||
} else if (!strcmp(command, "validate")) {
|
} else if (!strcmp(command, "validate")) {
|
||||||
xmlShellValidate(ctxt, arg, NULL, NULL);
|
xmlShellValidate(ctxt, arg, NULL, NULL);
|
||||||
} else if (!strcmp(command, "load")) {
|
} else if (!strcmp(command, "load")) {
|
||||||
xmlShellLoad(ctxt, arg, NULL, NULL);
|
xmlShellLoad(ctxt, arg, NULL, NULL);
|
||||||
|
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||||
|
} else if (!strcmp(command, "relaxng")) {
|
||||||
|
xmlShellRNGValidate(ctxt, arg, NULL, NULL);
|
||||||
|
#endif
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
} else if (!strcmp(command, "save")) {
|
} else if (!strcmp(command, "save")) {
|
||||||
xmlShellSave(ctxt, arg, NULL, NULL);
|
xmlShellSave(ctxt, arg, NULL, NULL);
|
||||||
|
Reference in New Issue
Block a user