diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-04-03 20:36:38 +0200 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-04-04 04:14:55 +0200 |
commit | 48b03c847972659bf2d4451cd77f7288ad61ebf6 (patch) | |
tree | 4518e5d6e30b41e6f8dd4ce62fb59fc92f0e51ab | |
parent | 0d467de29994f222f8faeb991539da31e5ab68ab (diff) | |
download | libxml2-48b03c847972659bf2d4451cd77f7288ad61ebf6.tar.gz |
Remove major parts of old test suite
Remove all the parts of the old test suite which are covered by
runtest.c for quite some time.
The following test programs are removed:
- testC14N
- testHTML
- testReader
- testRelax
- testSAX
- testSchemas
- testURI
- testXPath
This also removes a few results of unimportant tests only run by the old
test suite.
121 files changed, 17 insertions, 4233 deletions
@@ -97,17 +97,9 @@ stamp-h1 tags test.out testAutomata -testC14N -testHTML testModule -testReader testRegexp -testRelax -testSAX -testSchemas testThreads -testURI -testXPath testapi testapi.c.new testchar diff --git a/CMakeLists.txt b/CMakeLists.txt index 161f2ca7..7fbec6d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -506,20 +506,12 @@ if(LIBXML2_WITH_TESTS) runsuite testapi testAutomata - testC14N testchar testdict - testHTML testModule testlimits - testReader testrecurse testRegexp - testRelax - testSAX - testSchemas - testURI - testXPath ) foreach(TEST ${TESTS}) add_executable(${TEST} ${TEST}.c) diff --git a/Makefile.am b/Makefile.am index 3eb2505e..e1844b46 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,10 +13,19 @@ AM_CPPFLAGS = -I$(top_builddir)/include -I$(srcdir)/include -DSYSCONFDIR='"$(sys AM_CFLAGS = $(EXTRA_CFLAGS) -check_PROGRAMS=testSchemas testRelax testSAX testHTML testXPath testURI \ - testThreads testC14N testAutomata testRegexp \ - testReader testapi testModule runtest runsuite testchar \ - testdict runxmlconf testrecurse testlimits +check_PROGRAMS = \ + runsuite \ + runtest \ + runxmlconf \ + testAutomata \ + testRegexp \ + testModule \ + testThreads \ + testapi \ + testchar \ + testdict \ + testlimits \ + testrecurse bin_PROGRAMS = xmllint xmlcatalog @@ -97,42 +106,17 @@ xmllint_LDFLAGS = xmllint_DEPENDENCIES = $(DEPS) xmllint_LDADD= $(RDL_LIBS) $(LDADDS) -testSAX_SOURCES=testSAX.c -testSAX_LDFLAGS = -testSAX_DEPENDENCIES = $(DEPS) -testSAX_LDADD= $(LDADDS) - -testHTML_SOURCES=testHTML.c -testHTML_LDFLAGS = -testHTML_DEPENDENCIES = $(DEPS) -testHTML_LDADD= $(LDADDS) - xmlcatalog_SOURCES=xmlcatalog.c xmlcatalog_LDFLAGS = xmlcatalog_DEPENDENCIES = $(DEPS) xmlcatalog_LDADD = $(RDL_LIBS) $(LDADDS) -testXPath_SOURCES=testXPath.c -testXPath_LDFLAGS = -testXPath_DEPENDENCIES = $(DEPS) -testXPath_LDADD= $(LDADDS) - -testC14N_SOURCES=testC14N.c -testC14N_LDFLAGS = -testC14N_DEPENDENCIES = $(DEPS) -testC14N_LDADD= $(LDADDS) - testThreads_SOURCES = testThreads.c testThreads_CFLAGS = $(EXTRA_CFLAGS) $(THREAD_CFLAGS) testThreads_LDFLAGS = testThreads_DEPENDENCIES = $(DEPS) testThreads_LDADD= $(BASE_THREAD_LIBS) $(THREAD_LIBS) $(LDADDS) -testURI_SOURCES=testURI.c -testURI_LDFLAGS = -testURI_DEPENDENCIES = $(DEPS) -testURI_LDADD= $(LDADDS) - testRegexp_SOURCES=testRegexp.c testRegexp_LDFLAGS = testRegexp_DEPENDENCIES = $(DEPS) @@ -143,21 +127,6 @@ testAutomata_LDFLAGS = testAutomata_DEPENDENCIES = $(DEPS) testAutomata_LDADD= $(LDADDS) -testSchemas_SOURCES=testSchemas.c -testSchemas_LDFLAGS = -testSchemas_DEPENDENCIES = $(DEPS) -testSchemas_LDADD= $(LDADDS) - -testRelax_SOURCES=testRelax.c -testRelax_LDFLAGS = -testRelax_DEPENDENCIES = $(DEPS) -testRelax_LDADD= $(LDADDS) - -testReader_SOURCES=testReader.c -testReader_LDFLAGS = -testReader_DEPENDENCIES = $(DEPS) -testReader_LDADD= $(LDADDS) - testModule_SOURCES=testModule.c testModule_LDFLAGS = testModule_DEPENDENCIES = $(DEPS) @@ -221,425 +190,13 @@ asan: @echo '## rebuilding for ASAN' ./configure CFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security -Werror=array-bounds -g" CXXFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security -Werror=array-bounds -g" LDFLAGS="-fsanitize=address,undefined" CC="clang" CXX="clang++" --disable-shared ; OptimOff ; $(MAKE) clean ; $(MAKE) -testall : tests SVGtests SAXtests +testall : tests SVGtests -tests: XMLtests XMLenttests NStests IDtests Errtests APItests $(READER_TEST) $(TEST_SAX) $(TEST_PUSH) $(TEST_HTML) $(TEST_PHTML) $(TEST_VALID) URItests $(TEST_PATTERN) $(TEST_XPATH) $(TEST_XPTR) $(TEST_XINCLUDE) $(TEST_C14N) $(TEST_DEBUG) $(TEST_CATALOG) $(TEST_REGEXPS) $(TEST_SCHEMAS) $(TEST_SCHEMATRON) $(TEST_THREADS) Timingtests $(TEST_VTIME) $(PYTHON_TESTS) $(TEST_MODULES) +tests: $(TEST_DEBUG) $(TEST_CATALOG) $(TEST_REGEXPS) $(TEST_SCHEMATRON) $(TEST_THREADS) Timingtests $(TEST_VTIME) $(PYTHON_TESTS) $(TEST_MODULES) @(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; \ $(MAKE) -s tests ; fi) @(cd doc/examples ; $(MAKE) -s tests) -APItests: testapi$(EXEEXT) - @echo "## Running the API regression tests this may take a little while" - -@(ASAN_OPTIONS="$$ASAN_OPTIONS:detect_leaks=0" $(CHECKER) $(top_builddir)/testapi -q) - -HTMLtests : testHTML$(EXEEXT) - @(echo > .memdump) - @echo "## HTML regression tests" - -@(for i in $(srcdir)/test/HTML/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \ - else \ - log=`$(CHECKER) $(top_builddir)/testHTML $$i > result.$$name 2> error.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/HTML/$$name result.$$name ; \ - diff -b $(srcdir)/result/HTML/$$name.err error.$$name ; \ - $(CHECKER) $(top_builddir)/testHTML result.$$name > result2.$$name 2>error.$$name ; \ - diff result.$$name result2.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name result2.$$name error.$$name ; \ - fi ; fi ; done) - -HTMLPushtests : testHTML$(EXEEXT) - @echo "## Push HTML regression tests" - -@(for i in $(srcdir)/test/HTML/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testHTML --push $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \ - else \ - log=`$(CHECKER) $(top_builddir)/testHTML --push $$i > result.$$name 2> error.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/HTML/$$name result.$$name ; \ - cut -b 1-15 $(srcdir)/result/HTML/$$name.err > errorcut.$$name; \ - cut -b 1-15 error.$$name > errorcut2.$$name; \ - diff -b errorcut.$$name errorcut2.$$name ; \ - $(CHECKER) $(top_builddir)/testHTML --push result.$$name > result2.$$name 2>error.$$name ; \ - diff result.$$name result2.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name result2.$$name error.$$name errorcut.$$name errorcut2.$$name ; \ - fi ; fi ; done) - @echo "## HTML SAX regression tests" - -@(for i in $(srcdir)/test/HTML/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/HTML/$$name.sax ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \ - else \ - log=`$(CHECKER) $(top_builddir)/testHTML --sax $$i > result.$$name.sax ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name.sax ; \ - fi ; fi ; done) - @echo "## Push HTML SAX regression tests" - -@(for i in $(srcdir)/test/HTML/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testHTML --push --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \ - else \ - log=`$(CHECKER) $(top_builddir)/testHTML --push --sax $$i 2>&1 > result.$$name.sax ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name.sax ; \ - fi ; fi ; done) - -XMLtests : xmllint$(EXEEXT) - @(echo > .memdump) - @echo "## XML regression tests" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint $$i > $(srcdir)/result/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint $$i 2>&1 > result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - diff $(srcdir)/result/$$name result.$$name ; \ - $(CHECKER) $(top_builddir)/xmllint result.$$name 2>&1 > result2.$$name | grep -v 'failed to load external entity' ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - diff result.$$name result2.$$name` ;\ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name result2.$$name ; \ - fi ; fi ; done) - @echo "## XML regression tests on memory" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --memory $$i > $(srcdir)/result/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --memory $$i 2>&1 > result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/$$name result.$$name ; \ - $(CHECKER) $(top_builddir)/xmllint --memory result.$$name 2>&1 > result2.$$name | grep -v 'failed to load external entity' ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"`; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - diff result.$$name result2.$$name ; \ - rm result.$$name result2.$$name ; \ - fi ; fi ; done) - -XMLPushtests: xmllint$(EXEEXT) - @(echo > .memdump) - @echo "## XML push regression tests" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --push $$i > $(srcdir)/result/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --push $$i 2>&1 > result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - diff $(srcdir)/result/$$name result.$$name ; \ - $(CHECKER) $(top_builddir)/xmllint --push result.$$name 2>&1 > result2.$$name | grep -v 'failed to load external entity' ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - diff result.$$name result2.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name result2.$$name ; \ - fi ; fi ; done) - -NStests : xmllint$(EXEEXT) - @(echo > .memdump) - @echo "## XML Namespaces regression tests" - -@(for i in $(srcdir)/test/namespaces/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/namespaces/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint $$i \ - 2> $(srcdir)/result/namespaces/$$name.err \ - > $(srcdir)/result/namespaces/$$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/namespaces/$$name result.$$name ; \ - diff $(srcdir)/result/namespaces/$$name.err error.$$name`; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name error.$$name ; \ - fi ; fi ; done) - -IDtests : xmllint$(EXEEXT) testXPath$(EXEEXT) - @(echo > .memdump) - @echo "## xml:id regression tests" - -@(for i in $(srcdir)/test/xmlid/id_*.xml ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/xmlid/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testXPath -i $$i "id('bar')" \ - 2> $(srcdir)/result/xmlid/$$name.err \ - > $(srcdir)/result/xmlid/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/testXPath -i $$i "id('bar')" 2> error.$$name > result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - diff $(srcdir)/result/xmlid/$$name result.$$name ; \ - diff $(srcdir)/result/xmlid/$$name.err error.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name error.$$name ; \ - 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 regression tests (old 1.0)" - -@(for i in $(srcdir)/test/errors10/*.xml ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/errors10/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --oldxml10 $$i \ - 2> $(srcdir)/result/errors10/$$name.err \ - > $(srcdir)/result/errors10/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --oldxml10 $$i 2> error.$$name > result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - diff $(srcdir)/result/errors10/$$name result.$$name ; \ - diff $(srcdir)/result/errors10/$$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 --stream $$i \ - 2> $(srcdir)/result/errors/$$name.str \ - > /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --stream $$i 2> error.$$name > /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - diff $(srcdir)/result/errors/$$name.str error.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm error.$$name ; \ - fi ; fi ; done) - -XMLenttests : xmllint$(EXEEXT) - @(echo > .memdump) - @echo "## XML entity subst regression tests" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/noent/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --noent $$i > $(srcdir)/result/noent/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --noent $$i 2>&1 > result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - diff $(srcdir)/result/noent/$$name result.$$name ; \ - $(CHECKER) $(top_builddir)/xmllint --noent result.$$name 2>&1 > result2.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - diff result.$$name result2.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name result2.$$name ; \ - fi ; fi ; done) - -URItests : testURI$(EXEEXT) - @(echo > .memdump) - @echo "## URI module regression tests" - -@(for i in $(srcdir)/test/URI/*.data ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/URI/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testURI -base 'http://foo.com/path/to/index.html?orig#help' < $$i > $(srcdir)/result/URI/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/testURI -base 'http://foo.com/path/to/index.html?orig#help' < $$i 2>&1 > result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/URI/$$name result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - -@(for i in $(srcdir)/test/URI/*.uri ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/URI/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testURI < $$i > $(srcdir)/result/URI/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/testURI < $$i 2>&1 > result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/URI/$$name result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - -XPathtests : testXPath$(EXEEXT) - @(echo > .memdump) - @echo "## XPath regression tests" - -@(if [ "`$(top_builddir)/testXPath | grep 'support not compiled in'`" != "" ] ; \ - then echo Skipping debug not compiled in ; exit 0 ; fi ; \ - for i in $(srcdir)/test/XPath/expr/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/XPath/expr/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testXPath -f --expr $$i > $(srcdir)/result/XPath/expr/$$name 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/testXPath -f --expr $$i > result.$$name 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/XPath/expr/$$name result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done ; \ - for i in $(srcdir)/test/XPath/docs/* ; do \ - if [ ! -d $$i ] ; then \ - doc=`basename $$i`; \ - for j in $(srcdir)/test/XPath/tests/$$doc* ; do \ - if [ ! -f $$j ] ; then continue ; fi ; \ - name=`basename $$j`; \ - if [ ! -d $$j ] ; then \ - if [ ! -f $(srcdir)/result/XPath/tests/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testXPath -f -i $$i $$j > $(srcdir)/result/XPath/tests/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/testXPath -f -i $$i $$j > result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/XPath/tests/$$name result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done ; fi ; done) - -XPtrtests : testXPath$(EXEEXT) - @(echo > .memdump) - @echo "## XPointer regression tests" - -@(if [ "`$(top_builddir)/testXPath | grep 'support not compiled in'`" != "" ] ; \ - then echo Skipping debug not compiled in ; exit 0 ; fi ; \ - for i in $(srcdir)/test/XPath/docs/* ; do \ - if [ ! -d $$i ] ; then \ - doc=`basename $$i`; \ - for j in $(srcdir)/test/XPath/xptr/$$doc* ; do \ - if [ ! -f $$j ] ; then continue ; fi ; \ - name=`basename $$j`; \ - if [ ! -d $$j ] ; then \ - if [ ! -f $(srcdir)/result/XPath/xptr/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testXPath -xptr -f -i $$i $$j > $(srcdir)/result/XPath/xptr/$$name 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ - else \ - log=`$(CHECKER) $(top_builddir)/testXPath -xptr -f -i $$i $$j > result.$$name 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/XPath/xptr/$$name result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done ; fi ; done) - -XIncludetests : xmllint$(EXEEXT) - @(echo > .memdump) - @echo "## XInclude regression tests" - -@(for i in $(srcdir)/test/XInclude/docs/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/XInclude/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude $$i > $(srcdir)/result/XInclude/$$name 2> $(srcdir)/result/XInclude/$$name.err ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude $$i > result.$$name 2>error.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/XInclude/$$name result.$$name ; \ - diff $(srcdir)/result/XInclude/$$name.err error.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name error.$$name ; \ - fi ; fi ; done) - -@(for i in $(srcdir)/test/XInclude/docs/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/XInclude/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --nowarning --noxincludenode $$i > $(srcdir)/result/XInclude/$$name 2> $(srcdir)/result/XInclude/$$name.err ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --noxincludenode $$i > result.$$name 2>error.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/XInclude/$$name result.$$name ; \ - diff $(srcdir)/result/XInclude/$$name.err error.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name error.$$name ; \ - fi ; fi ; done) - @(echo > .memdump) - @echo "## XInclude xmlReader regression tests" - -@(for i in $(srcdir)/test/XInclude/docs/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/XInclude/$$name.rdr ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > $(srcdir)/result/XInclude/$$name.rdr ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > result.$$name 2>error.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/XInclude/$$name.err error.$$name ; \ - diff $(srcdir)/result/XInclude/$$name.rdr result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name error.$$name ; \ - fi ; fi ; done) - -@(for i in $(srcdir)/test/XInclude/docs/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/XInclude/$$name.rdr ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --nowarning --noxincludenode --stream --debug $$i > $(srcdir)/result/XInclude/$$name.rdr ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > result.$$name 2>error.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/XInclude/$$name.err error.$$name ; \ - diff $(srcdir)/result/XInclude/$$name.rdr result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name error.$$name ; \ - fi ; fi ; done) - Scripttests : xmllint$(EXEEXT) @(echo > .memdump) @echo "## Scripts regression tests" @@ -741,160 +298,6 @@ Threadtests : testThreads$(EXEEXT) grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \ exit 0) -Readertests : xmllint$(EXEEXT) - @(echo > .memdump) - @echo "## Reader regression tests" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/$$name.rdr ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --nonet --debug --stream $$i > $(srcdir)/result/$$name.rdr 2>/dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --nonet --debug --stream $$i > result.$$name 2>/dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/$$name.rdr result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - @echo "## Reader on memory regression tests" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/$$name.rdr ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --memory --nonet --debug --stream $$i > $(srcdir)/result/$$name.rdr 2>/dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --memory --nonet --debug --stream $$i > result.$$name 2>/dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/$$name.rdr result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - @(echo > .memdump) - @echo "## Walker regression tests" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/$$name.rdr ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --nonet --debug --walker $$i > $(srcdir)/result/$$name.rdr 2>/dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --nonet --debug --walker $$i > result.$$name 2>/dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/$$name.rdr result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - @echo "## Reader entities substitution regression tests" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/$$name.rde ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --noent --nonet --debug --stream $$i > $(srcdir)/result/$$name.rde 2>/dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --noent --nonet --debug --stream $$i > result.$$name 2>/dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/$$name.rde result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - -SAXtests : testSAX$(EXEEXT) - @(echo > .memdump) - @echo "## SAX1 callbacks regression tests" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/$$name.sax ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testSAX $$i > $(srcdir)/result/$$name.sax 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/testSAX $$i > result.$$name 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/$$name.sax result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - @echo "## SAX2 callbacks regression tests" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/$$name.sax2 ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testSAX --sax2 $$i > $(srcdir)/result/$$name.sax2 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/testSAX --sax2 $$i > result.$$name 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/$$name.sax2 result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - @echo "## SAX2 callbacks regression tests with entity substitution" - -@(for i in $(srcdir)/test/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/noent/$$name.sax2 ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/testSAX --sax2 --noent $$i > $(srcdir)/result/noent/$$name.sax2 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/testSAX --sax2 --noent $$i > result.$$name 2> /dev/null ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/noent/$$name.sax2 result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - -Validtests : xmllint$(EXEEXT) - @(echo > .memdump) - @echo "## Valid documents regression tests" - -@(for i in $(srcdir)/test/VCM/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - log=`$(CHECKER) $(top_builddir)/xmllint --valid --noout --nowarning $$i ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"`;\ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - fi ; done ; exit 0) - @echo "## Validity checking regression tests" - -@(for i in $(srcdir)/test/VC/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/VC/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --noout --valid $$i 2> $(srcdir)/result/VC/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --noout --valid $$i 2> result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/VC/$$name result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done) - @echo "## General documents valid regression tests" - -@(for i in $(srcdir)/test/valid/* ; do \ - name=`basename $$i`; \ - if [ ! -d $$i ] ; then \ - if [ ! -f $(srcdir)/result/valid/$$name ] ; then \ - echo New test file $$name ; \ - $(CHECKER) $(top_builddir)/xmllint --valid $$i > $(srcdir)/result/valid/$$name 2>$(srcdir)/result/valid/$$name.err ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint --valid $$i > result.$$name 2>error.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/valid/$$name result.$$name ; \ - diff $(srcdir)/result/valid/$$name.err error.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name error.$$name ; \ - fi ; fi ; done) - Regexptests: testRegexp$(EXEEXT) @(echo > .memdump) @echo "## Regexp regression tests" @@ -985,138 +388,6 @@ VTimingtests: xmllint$(EXEEXT) grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ exit 0) -C14Ntests : testC14N$(EXEEXT) - @echo "## C14N and XPath regression tests" - -@(for m in with-comments without-comments 1-1-without-comments exc-without-comments ; do \ - for i in $(srcdir)/test/c14n/$$m/*.xml ; do \ - if [ ! -d $$i ] ; then \ - name=`basename $$i .xml`; \ - cmdline="$(CHECKER) $(top_builddir)/testC14N --$$m $$i"; \ - if [ -f $(srcdir)/test/c14n/$$m/$$name.xpath ] ; then \ - cmdline="$$cmdline $(srcdir)/test/c14n/$$m/$$name.xpath"; \ - if [ -f $(srcdir)/test/c14n/$$m/$$name.ns ] ; then \ - cmdline="$$cmdline '`cat $(srcdir)/test/c14n/$$m/$$name.ns`'"; \ - fi; \ - fi; \ - $$cmdline > $(srcdir)/test/c14n/test.tmp 2> /dev/null; \ - if [ $$? -eq 0 ]; then \ - diff $(srcdir)/result/c14n/$$m/$$name $(srcdir)/test/c14n/test.tmp; \ - if [ $$? -ne 0 ]; then \ - echo "Test $$m/$$name failed"; \ - cat $(srcdir)/test/c14n/test.tmp; \ - fi; \ - else \ - echo "C14N failed"; \ - fi; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - fi; \ - rm -f $(srcdir)/test/c14n/test.tmp; \ - done; \ - done) - -Schemastests: testSchemas$(EXEEXT) - @(echo > .memdump) - @echo "## Schemas regression tests" - -@(for i in $(srcdir)/test/schemas/*_*.xsd ; do \ - name=`basename $$i | sed 's+_.*++'`; \ - sno=`basename $$i | sed 's+.*_\(.*\).xsd+\1+'`; \ - for j in $(srcdir)/test/schemas/"$$name"_*.xml ; do \ - if [ -f $$j ] ; then \ - xno=`basename $$j | sed 's+.*_\(.*\).xml+\1+'`; \ - if [ ! -f $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno" ]; \ - then \ - echo New test file "$$name"_"$$sno"_"$$xno" ; \ - $(CHECKER) $(top_builddir)/testSchemas $$i $$j \ - > $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno" \ - 2> $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno".err; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/testSchemas $$i $$j \ - > res.$$name 2> err.$$name;\ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno" \ - res.$$name;\ - diff $(srcdir)/result/schemas/"$$name"_"$$sno"_"$$xno".err \ - err.$$name;\ - grep Unimplemented err.$$name`; \ - if [ -n "$$log" ] ; then echo "$$name"_"$$sno"_"$$xno" result ; echo "$$log" ; fi ; \ - rm res.$$name err.$$name ; \ - fi ; fi ;\ - done; done) - -Relaxtests: xmllint$(EXEEXT) - @(echo > .memdump) - @echo "## Relax-NG regression tests" - -@(for i in $(srcdir)/test/relaxng/*.rng ; do \ - name=`basename $$i | sed 's+\.rng++'`; \ - if [ ! -f $(srcdir)/result/relaxng/"$$name"_valid ] ; then \ - echo New schemas $$name ; \ - $(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $(srcdir)/test/relaxng/tutorA.rng $$i \ - > $(srcdir)/result/relaxng/"$$name"_valid \ - 2> $(srcdir)/result/relaxng/"$$name"_err; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $(srcdir)/test/relaxng/tutorA.rng $$i \ - > res.$$name 2> err.$$name;\ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/relaxng/"$$name"_valid \ - res.$$name;\ - diff $(srcdir)/result/relaxng/"$$name"_err \ - err.$$name | grep -v "error detected at";\ - grep Unimplemented err.$$name`; \ - if [ -n "$$log" ] ; then echo schemas $$name result ; echo "$$log" ; fi ; \ - rm res.$$name err.$$name ; \ - fi; \ - for j in $(srcdir)/test/relaxng/"$$name"_*.xml ; do \ - if [ -f $$j ] ; then \ - xno=`basename $$j | sed 's+.*_\(.*\).xml+\1+'`; \ - if [ ! -f $(srcdir)/result/relaxng/"$$name"_"$$xno" ]; \ - then \ - echo New test file "$$name"_"$$xno" ; \ - $(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $$i $$j \ - > $(srcdir)/result/relaxng/"$$name"_"$$xno" \ - 2> $(srcdir)/result/relaxng/"$$name"_"$$xno".err; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $$i $$j \ - > res.$$name 2> err.$$name;\ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/relaxng/"$$name"_"$$xno" \ - res.$$name;\ - diff $(srcdir)/result/relaxng/"$$name"_"$$xno".err \ - err.$$name | grep -v "error detected at";\ - grep Unimplemented err.$$name`; \ - if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo "$$log" ; fi ; \ - rm res.$$name err.$$name ; \ - fi ; fi ; \ - done; done) - @echo "## Relax-NG streaming regression tests" - -@(for i in $(srcdir)/test/relaxng/*.rng ; do \ - name=`basename $$i | sed 's+\.rng++'`; \ - for j in $(srcdir)/test/relaxng/"$$name"_*.xml ; do \ - if [ -f $$j ] ; then \ - xno=`basename $$j | sed 's+.*_\(.*\).xml+\1+'`; \ - if [ ! -f $(srcdir)/result/relaxng/"$$name"_"$$xno" ]; \ - then \ - echo New test file "$$name"_"$$xno" ; \ - $(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --relaxng $$i $$j \ - > $(srcdir)/result/relaxng/"$$name"_"$$xno" \ - 2> $(srcdir)/result/relaxng/"$$name"_"$$xno".err; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - else \ - log=`$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --noout --stream --relaxng $$i $$j \ - > res.$$name 2> err.$$name;\ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - diff $(srcdir)/result/relaxng/"$$name"_"$$xno" res.$$name;\ - if [ "$$name" != "tutor10_1" -a "$$name" != "tutor10_2" -a "$$name" != "tutor3_2" -a "$$name" != "307377" -a "$$name" != "tutor8_2" ] ; then \ - diff $(srcdir)/result/relaxng/"$$name"_"$$xno".err \ - err.$$name | grep -v "error detected at";\ - fi ; grep Unimplemented err.$$name`; \ - if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo "$$log" ; fi ; \ - rm res.$$name err.$$name ; \ - fi ; fi ; \ - done; done) - Schematrontests: xmllint$(EXEEXT) @(echo > .memdump) @echo "## Schematron regression tests" @@ -1170,30 +441,6 @@ SchemasPythonTests: fi) @(if [ -x $(PYTHON) -a -d xstc ] ; then cd xstc ; $(MAKE) CHECKER="$(CHECKER)" pytests ; fi) -Patterntests: xmllint$(EXEEXT) - @(echo > .memdump) - @echo "## Pattern regression tests" - -@(for i in $(srcdir)/test/pattern/*.pat ; do \ - name=`basename $$i .pat`; \ - if [ -f $(srcdir)/test/pattern/$$name.xml ] ; then \ - if [ ! -f $(srcdir)/result/pattern/$$name ] ; then \ - rm -f result.$$name ; \ - echo New test file $$name ; \ - for pat in `cat $$i` ; do \ - $(CHECKER) $(top_builddir)/xmllint --walker --pattern $$pat $(srcdir)/test/pattern/$$name.xml >> $(srcdir)/result/pattern/$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - done ;\ - else \ - rm -f result.$$name ; \ - lst=`cat $$i` ; \ - log=`for pat in $$lst ; do $(CHECKER) $(top_builddir)/xmllint --walker --pattern $$pat $(srcdir)/test/pattern/$$name.xml 2>&1 >> result.$$name ; \ - grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ - done ;\ - diff $(srcdir)/result/pattern/$$name result.$$name` ; \ - if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \ - rm result.$$name ; \ - fi ; fi ; done ;) - ModuleTests: testModule$(EXEEXT) testdso.la @echo "## Module tests" @(./testModule$(EXEEXT)) @@ -1251,7 +498,7 @@ cmake_DATA = libxml2-config.cmake # Install the tests program sources as examples # examplesdir = $(docdir)/examples -examples_DATA = xmllint.c testSAX.c testHTML.c testXPath.c +examples_DATA = xmllint.c tst: tst.c $(CC) $(CFLAGS) -Iinclude -o tst tst.c .libs/libxml2.a -lpthread -lm -lz -llzma diff --git a/configure.ac b/configure.ac index 3166e6f9..1ffc34c3 100644 --- a/configure.ac +++ b/configure.ac @@ -988,17 +988,14 @@ AC_SUBST(WITH_LEGACY) if test "$with_reader" = "no" ; then echo Disabling the xmlReader parsing interface WITH_READER=0 - READER_TEST= else WITH_READER=1 - READER_TEST=Readertests if test "$with_push" = "no" ; then echo xmlReader requires Push interface - enabling it with_push=yes fi fi AC_SUBST(WITH_READER) -AC_SUBST(READER_TEST) if test "$with_writer" = "no" ; then echo Disabling the xmlWriter saving interface @@ -1022,64 +1019,44 @@ AC_SUBST(WITH_WRITER) if test "$with_pattern" = "no" ; then echo Disabling the xmlPattern parsing interface WITH_PATTERN=0 - TEST_PATTERN= else WITH_PATTERN=1 - TEST_PATTERN=Patterntests fi AC_SUBST(WITH_PATTERN) -AC_SUBST(TEST_PATTERN) if test "$with_sax1" = "no" ; then echo Disabling the older SAX1 interface WITH_SAX1=0 - TEST_SAX= else WITH_SAX1=1 - TEST_SAX=SAXtests fi AC_SUBST(WITH_SAX1) -AC_SUBST(TEST_SAX) if test "$with_push" = "no" ; then echo Disabling the PUSH parser interfaces WITH_PUSH=0 - TEST_PUSH= else WITH_PUSH=1 - TEST_PUSH="XMLPushtests" fi AC_SUBST(WITH_PUSH) -AC_SUBST(TEST_PUSH) if test "$with_html" = "no" ; then echo Disabling HTML support WITH_HTML=0 HTML_OBJ= - TEST_HTML= else WITH_HTML=1 HTML_OBJ="HTMLparser.o HTMLtree.o" - TEST_HTML=HTMLtests - if test "$with_push" != "no" ; then - TEST_PHTML=HTMLPushtests - else - TEST_PHTML= - fi fi AC_SUBST(WITH_HTML) AC_SUBST(HTML_OBJ) -AC_SUBST(TEST_HTML) -AC_SUBST(TEST_PHTML) if test "$with_valid" = "no" ; then echo Disabling DTD validation support WITH_VALID=0 - TEST_VALID= TEST_VTIME= else WITH_VALID=1 - TEST_VALID=Validtests TEST_VTIME=VTimingtests fi AC_SUBST(WITH_VALID) @@ -1104,11 +1081,9 @@ if test "$with_xptr" = "no" ; then echo Disabling XPointer support WITH_XPTR=0 XPTR_OBJ= - TEST_XPTR= else WITH_XPTR=1 XPTR_OBJ=xpointer.o - TEST_XPTR=XPtrtests if test "$with_xpath" = "no" ; then echo XPointer requires XPath support - enabling it with_xpath=yes @@ -1116,17 +1091,14 @@ else fi AC_SUBST(WITH_XPTR) AC_SUBST(XPTR_OBJ) -AC_SUBST(TEST_XPTR) if test "$with_c14n" = "no" ; then echo Disabling C14N support WITH_C14N=0 C14N_OBJ= - TEST_C14N= else WITH_C14N=1 C14N_OBJ="c14n.c" - TEST_C14N=C14Ntests if test "$with_xpath" = "no" ; then echo C14N requires XPath support - enabling it with_xpath=yes @@ -1134,18 +1106,15 @@ else fi AC_SUBST(WITH_C14N) AC_SUBST(C14N_OBJ) -AC_SUBST(TEST_C14N) if test "$with_xinclude" = "no" ; then echo Disabling XInclude support WITH_XINCLUDE=0 XINCLUDE_OBJ= with_xinclude="no" - TEST_XINCLUDE= else WITH_XINCLUDE=1 XINCLUDE_OBJ=xinclude.o - TEST_XINCLUDE=XIncludetests if test "$with_xpath" = "no" ; then echo XInclude requires XPath support - enabling it with_xpath=yes @@ -1153,7 +1122,6 @@ else fi AC_SUBST(WITH_XINCLUDE) AC_SUBST(XINCLUDE_OBJ) -AC_SUBST(TEST_XINCLUDE) if test "$with_xptr" = "" && test "$with_xpath" = "no" ; then with_xptr=no @@ -1182,15 +1150,12 @@ if test "$with_xpath" = "no" ; then echo Disabling XPATH support WITH_XPATH=0 XPATH_OBJ= - TEST_XPATH= else WITH_XPATH=1 XPATH_OBJ=xpath.o - TEST_XPATH=XPathtests fi AC_SUBST(WITH_XPATH) AC_SUBST(XPATH_OBJ) -AC_SUBST(TEST_XPATH) dnl dnl output functions @@ -1327,18 +1292,15 @@ AC_SUBST(WITH_ISO8859X) if test "$with_schemas" = "no" ; then echo "Disabling Schemas/Relax-NG support" WITH_SCHEMAS=0 - TEST_SCHEMAS= else echo "Enabled Schemas/Relax-NG support" WITH_SCHEMAS=1 - TEST_SCHEMAS="Schemastests Relaxtests" AS_IF([test "x$with_python" != "xno"], [ PYTHON_TESTS="$PYTHON_TESTS RelaxNGPythonTests SchemasPythonTests" ]) with_regexps=yes fi AC_SUBST(WITH_SCHEMAS) -AC_SUBST(TEST_SCHEMAS) if test "$with_regexps" = "no" ; then echo Disabling Regexps support diff --git a/doc/apibuild.py b/doc/apibuild.py index 2fbe11a9..18ac9417 100755 --- a/doc/apibuild.py +++ b/doc/apibuild.py @@ -31,18 +31,10 @@ ignored_files = { "testOOMlib.c": "out of memory tester", "rngparser.c": "not yet integrated", "rngparser.h": "not yet integrated", - "testHTML.c": "test tool", - "testReader.c": "test tool", - "testSchemas.c": "test tool", - "testXPath.c": "test tool", "testAutomata.c": "test tool", "testModule.c": "test tool", "testRegexp.c": "test tool", "testThreads.c": "test tool", - "testC14N.c": "test tool", - "testRelax.c": "test tool", - "testSAX.c": "test tool", - "testURI.c": "test tool", "testapi.c": "generated regression tests", "runtest.c": "regression tests program", "runsuite.c": "regression tests program", diff --git a/result/relaxng/302836_err b/result/relaxng/302836_err deleted file mode 100644 index fab2d78d..00000000 --- a/result/relaxng/302836_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/302836.rng validates diff --git a/result/relaxng/307377_err b/result/relaxng/307377_err deleted file mode 100644 index 5705eab7..00000000 --- a/result/relaxng/307377_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/307377.rng validates diff --git a/result/relaxng/492317_err b/result/relaxng/492317_err deleted file mode 100644 index 1f075391..00000000 --- a/result/relaxng/492317_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/492317.rng validates diff --git a/result/relaxng/558452_err b/result/relaxng/558452_err deleted file mode 100644 index b1628461..00000000 --- a/result/relaxng/558452_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/558452.rng validates diff --git a/result/relaxng/565219_err b/result/relaxng/565219_err deleted file mode 100644 index c43e67cf..00000000 --- a/result/relaxng/565219_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/565219.rng validates diff --git a/result/relaxng/595792-ext_err b/result/relaxng/595792-ext_err deleted file mode 100644 index 092fdbd1..00000000 --- a/result/relaxng/595792-ext_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/595792-ext.rng validates diff --git a/result/relaxng/595792_err b/result/relaxng/595792_err deleted file mode 100644 index e9f3192e..00000000 --- a/result/relaxng/595792_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/595792.rng validates diff --git a/result/relaxng/710744_err b/result/relaxng/710744_err deleted file mode 100644 index 54f02261..00000000 --- a/result/relaxng/710744_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/710744.rng validates diff --git a/result/relaxng/OpenDocumentSub_err b/result/relaxng/OpenDocumentSub_err deleted file mode 100644 index 941d6c45..00000000 --- a/result/relaxng/OpenDocumentSub_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/OpenDocumentSub.rng validates diff --git a/result/relaxng/addressBook_err b/result/relaxng/addressBook_err deleted file mode 100644 index 584d55ab..00000000 --- a/result/relaxng/addressBook_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/addressBook.rng validates diff --git a/result/relaxng/ambig_name-class2_err b/result/relaxng/ambig_name-class2_err deleted file mode 100644 index 2c1ba8d3..00000000 --- a/result/relaxng/ambig_name-class2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/ambig_name-class2.rng validates diff --git a/result/relaxng/ambig_name-class_err b/result/relaxng/ambig_name-class_err deleted file mode 100644 index 0afe5cd6..00000000 --- a/result/relaxng/ambig_name-class_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/ambig_name-class.rng validates diff --git a/result/relaxng/anyName0_err b/result/relaxng/anyName0_err deleted file mode 100644 index ab6f08da..00000000 --- a/result/relaxng/anyName0_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/anyName0.rng validates diff --git a/result/relaxng/choice0_err b/result/relaxng/choice0_err deleted file mode 100644 index cf124310..00000000 --- a/result/relaxng/choice0_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/choice0.rng validates diff --git a/result/relaxng/compare0_err b/result/relaxng/compare0_err deleted file mode 100644 index 543d7349..00000000 --- a/result/relaxng/compare0_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/compare0.rng validates diff --git a/result/relaxng/comps_err b/result/relaxng/comps_err deleted file mode 100644 index 67dd4027..00000000 --- a/result/relaxng/comps_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/comps.rng validates diff --git a/result/relaxng/demo2_err b/result/relaxng/demo2_err deleted file mode 100644 index 9bdaeb97..00000000 --- a/result/relaxng/demo2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/demo2.rng validates diff --git a/result/relaxng/demo3_err b/result/relaxng/demo3_err deleted file mode 100644 index ccced98b..00000000 --- a/result/relaxng/demo3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/demo3.rng validates diff --git a/result/relaxng/demo_err b/result/relaxng/demo_err deleted file mode 100644 index 4f397f8c..00000000 --- a/result/relaxng/demo_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/demo.rng validates diff --git a/result/relaxng/docbook_err b/result/relaxng/docbook_err deleted file mode 100644 index 81240128..00000000 --- a/result/relaxng/docbook_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/docbook.rng validates diff --git a/result/relaxng/empty0_err b/result/relaxng/empty0_err deleted file mode 100644 index c4060cfe..00000000 --- a/result/relaxng/empty0_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/empty0.rng validates diff --git a/result/relaxng/empty1_err b/result/relaxng/empty1_err deleted file mode 100644 index f52d95ce..00000000 --- a/result/relaxng/empty1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/empty1.rng validates diff --git a/result/relaxng/include0_err b/result/relaxng/include0_err deleted file mode 100644 index cd16cbe2..00000000 --- a/result/relaxng/include0_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/include0.rng validates diff --git a/result/relaxng/include1_err b/result/relaxng/include1_err deleted file mode 100644 index ad4850b0..00000000 --- a/result/relaxng/include1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/include1.rng validates diff --git a/result/relaxng/inline2_err b/result/relaxng/inline2_err deleted file mode 100644 index 027408e2..00000000 --- a/result/relaxng/inline2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/inline2.rng validates diff --git a/result/relaxng/inline3_err b/result/relaxng/inline3_err deleted file mode 100644 index 1ceccb83..00000000 --- a/result/relaxng/inline3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/inline3.rng validates diff --git a/result/relaxng/inline_err b/result/relaxng/inline_err deleted file mode 100644 index 8ba0e5cf..00000000 --- a/result/relaxng/inline_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/inline.rng validates diff --git a/result/relaxng/interleave0_0_err b/result/relaxng/interleave0_0_err deleted file mode 100644 index 0d865ec2..00000000 --- a/result/relaxng/interleave0_0_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/interleave0_0.rng validates diff --git a/result/relaxng/interleave1_0_err b/result/relaxng/interleave1_0_err deleted file mode 100644 index 48023528..00000000 --- a/result/relaxng/interleave1_0_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/interleave1_0.rng validates diff --git a/result/relaxng/libvirt_err b/result/relaxng/libvirt_err deleted file mode 100644 index 4acf3edf..00000000 --- a/result/relaxng/libvirt_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/libvirt.rng validates diff --git a/result/relaxng/list_err b/result/relaxng/list_err deleted file mode 100644 index 748e21b0..00000000 --- a/result/relaxng/list_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/list.rng validates diff --git a/result/relaxng/pattern1_err b/result/relaxng/pattern1_err deleted file mode 100644 index 88564462..00000000 --- a/result/relaxng/pattern1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/pattern1.rng validates diff --git a/result/relaxng/pattern2_err b/result/relaxng/pattern2_err deleted file mode 100644 index acccc55b..00000000 --- a/result/relaxng/pattern2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/pattern2.rng validates diff --git a/result/relaxng/pattern3_err b/result/relaxng/pattern3_err deleted file mode 100644 index a7a1f463..00000000 --- a/result/relaxng/pattern3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/pattern3.rng validates diff --git a/result/relaxng/proofsystem_err b/result/relaxng/proofsystem_err deleted file mode 100644 index 9fbcfdc9..00000000 --- a/result/relaxng/proofsystem_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/proofsystem.rng validates diff --git a/result/relaxng/rngbug-001_err b/result/relaxng/rngbug-001_err deleted file mode 100644 index 4c301538..00000000 --- a/result/relaxng/rngbug-001_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/rngbug-001.rng validates diff --git a/result/relaxng/spec1_err b/result/relaxng/spec1_err deleted file mode 100644 index 8551c1e1..00000000 --- a/result/relaxng/spec1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/spec1.rng validates diff --git a/result/relaxng/spec_err b/result/relaxng/spec_err deleted file mode 100644 index 27336e13..00000000 --- a/result/relaxng/spec_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/spec.rng validates diff --git a/result/relaxng/table_err b/result/relaxng/table_err deleted file mode 100644 index 47e79962..00000000 --- a/result/relaxng/table_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/table.rng validates diff --git a/result/relaxng/tutor10_10_err b/result/relaxng/tutor10_10_err deleted file mode 100644 index 24a5f7e5..00000000 --- a/result/relaxng/tutor10_10_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_10.rng validates diff --git a/result/relaxng/tutor10_1_err b/result/relaxng/tutor10_1_err deleted file mode 100644 index 85be3be0..00000000 --- a/result/relaxng/tutor10_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_1.rng validates diff --git a/result/relaxng/tutor10_2_err b/result/relaxng/tutor10_2_err deleted file mode 100644 index b3e32a63..00000000 --- a/result/relaxng/tutor10_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_2.rng validates diff --git a/result/relaxng/tutor10_3_err b/result/relaxng/tutor10_3_err deleted file mode 100644 index 3c714aac..00000000 --- a/result/relaxng/tutor10_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_3.rng validates diff --git a/result/relaxng/tutor10_4_err b/result/relaxng/tutor10_4_err deleted file mode 100644 index 32081376..00000000 --- a/result/relaxng/tutor10_4_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_4.rng validates diff --git a/result/relaxng/tutor10_5_err b/result/relaxng/tutor10_5_err deleted file mode 100644 index 49808cfe..00000000 --- a/result/relaxng/tutor10_5_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_5.rng validates diff --git a/result/relaxng/tutor10_6_err b/result/relaxng/tutor10_6_err deleted file mode 100644 index 09368c1b..00000000 --- a/result/relaxng/tutor10_6_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_6.rng validates diff --git a/result/relaxng/tutor10_7_err b/result/relaxng/tutor10_7_err deleted file mode 100644 index 081a2302..00000000 --- a/result/relaxng/tutor10_7_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_7.rng validates diff --git a/result/relaxng/tutor10_8_err b/result/relaxng/tutor10_8_err deleted file mode 100644 index 1a864cc0..00000000 --- a/result/relaxng/tutor10_8_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_8.rng validates diff --git a/result/relaxng/tutor10_9_err b/result/relaxng/tutor10_9_err deleted file mode 100644 index 942058e9..00000000 --- a/result/relaxng/tutor10_9_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor10_9.rng validates diff --git a/result/relaxng/tutor11_1_err b/result/relaxng/tutor11_1_err deleted file mode 100644 index 88347feb..00000000 --- a/result/relaxng/tutor11_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor11_1.rng validates diff --git a/result/relaxng/tutor11_2_err b/result/relaxng/tutor11_2_err deleted file mode 100644 index 3294c13b..00000000 --- a/result/relaxng/tutor11_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor11_2.rng validates diff --git a/result/relaxng/tutor11_3_err b/result/relaxng/tutor11_3_err deleted file mode 100644 index 14d9d447..00000000 --- a/result/relaxng/tutor11_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor11_3.rng validates diff --git a/result/relaxng/tutor11_4_err b/result/relaxng/tutor11_4_err deleted file mode 100644 index f0a83393..00000000 --- a/result/relaxng/tutor11_4_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor11_4.rng validates diff --git a/result/relaxng/tutor12_1_err b/result/relaxng/tutor12_1_err deleted file mode 100644 index a02fb415..00000000 --- a/result/relaxng/tutor12_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor12_1.rng validates diff --git a/result/relaxng/tutor13_1_err b/result/relaxng/tutor13_1_err deleted file mode 100644 index ccd11ad1..00000000 --- a/result/relaxng/tutor13_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor13_1.rng validates diff --git a/result/relaxng/tutor14_1_err b/result/relaxng/tutor14_1_err deleted file mode 100644 index 191ec3d5..00000000 --- a/result/relaxng/tutor14_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor14_1.rng validates diff --git a/result/relaxng/tutor1_1_err b/result/relaxng/tutor1_1_err deleted file mode 100644 index d7cbfe85..00000000 --- a/result/relaxng/tutor1_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor1_1.rng validates diff --git a/result/relaxng/tutor1_2_err b/result/relaxng/tutor1_2_err deleted file mode 100644 index 97d32b2f..00000000 --- a/result/relaxng/tutor1_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor1_2.rng validates diff --git a/result/relaxng/tutor1_3_err b/result/relaxng/tutor1_3_err deleted file mode 100644 index 4941f8fb..00000000 --- a/result/relaxng/tutor1_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor1_3.rng validates diff --git a/result/relaxng/tutor1_4_err b/result/relaxng/tutor1_4_err deleted file mode 100644 index a1fd60cf..00000000 --- a/result/relaxng/tutor1_4_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor1_4.rng validates diff --git a/result/relaxng/tutor2_1_err b/result/relaxng/tutor2_1_err deleted file mode 100644 index df4778eb..00000000 --- a/result/relaxng/tutor2_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor2_1.rng validates diff --git a/result/relaxng/tutor3_1_err b/result/relaxng/tutor3_1_err deleted file mode 100644 index 949ef9ac..00000000 --- a/result/relaxng/tutor3_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor3_1.rng validates diff --git a/result/relaxng/tutor3_2_err b/result/relaxng/tutor3_2_err deleted file mode 100644 index b6cb1ad8..00000000 --- a/result/relaxng/tutor3_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor3_2.rng validates diff --git a/result/relaxng/tutor3_3_err b/result/relaxng/tutor3_3_err deleted file mode 100644 index 92e83b68..00000000 --- a/result/relaxng/tutor3_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor3_3.rng validates diff --git a/result/relaxng/tutor3_4_err b/result/relaxng/tutor3_4_err deleted file mode 100644 index 61ef41f9..00000000 --- a/result/relaxng/tutor3_4_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor3_4.rng validates diff --git a/result/relaxng/tutor3_5_err b/result/relaxng/tutor3_5_err deleted file mode 100644 index 2e368687..00000000 --- a/result/relaxng/tutor3_5_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor3_5.rng validates diff --git a/result/relaxng/tutor3_6_err b/result/relaxng/tutor3_6_err deleted file mode 100644 index 8479bea9..00000000 --- a/result/relaxng/tutor3_6_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor3_6.rng validates diff --git a/result/relaxng/tutor3_7_err b/result/relaxng/tutor3_7_err deleted file mode 100644 index 25461320..00000000 --- a/result/relaxng/tutor3_7_err +++ /dev/null @@ -1,4 +0,0 @@ -./test/relaxng/tutor3_7.rng:1: element element: Relax-NG validity error : Expecting an element , got nothing -./test/relaxng/tutor3_7.rng:1: element element: Relax-NG validity error : Invalid sequence in interleave -./test/relaxng/tutor3_7.rng:1: element element: Relax-NG validity error : Element element failed to validate content -./test/relaxng/tutor3_7.rng fails to validate diff --git a/result/relaxng/tutor3_8_err b/result/relaxng/tutor3_8_err deleted file mode 100644 index 44fe75d5..00000000 --- a/result/relaxng/tutor3_8_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor3_8.rng validates diff --git a/result/relaxng/tutor3_9_err b/result/relaxng/tutor3_9_err deleted file mode 100644 index d54fbe0d..00000000 --- a/result/relaxng/tutor3_9_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor3_9.rng validates diff --git a/result/relaxng/tutor4_1_err b/result/relaxng/tutor4_1_err deleted file mode 100644 index 94f0289b..00000000 --- a/result/relaxng/tutor4_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor4_1.rng validates diff --git a/result/relaxng/tutor4_2_err b/result/relaxng/tutor4_2_err deleted file mode 100644 index 82085d0a..00000000 --- a/result/relaxng/tutor4_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor4_2.rng validates diff --git a/result/relaxng/tutor4_3_err b/result/relaxng/tutor4_3_err deleted file mode 100644 index 74eb8b2f..00000000 --- a/result/relaxng/tutor4_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor4_3.rng validates diff --git a/result/relaxng/tutor4_4_err b/result/relaxng/tutor4_4_err deleted file mode 100644 index 641ee87c..00000000 --- a/result/relaxng/tutor4_4_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor4_4.rng validates diff --git a/result/relaxng/tutor5_1_err b/result/relaxng/tutor5_1_err deleted file mode 100644 index 586fd985..00000000 --- a/result/relaxng/tutor5_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor5_1.rng validates diff --git a/result/relaxng/tutor5_2_err b/result/relaxng/tutor5_2_err deleted file mode 100644 index de8f4236..00000000 --- a/result/relaxng/tutor5_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor5_2.rng validates diff --git a/result/relaxng/tutor5_3_err b/result/relaxng/tutor5_3_err deleted file mode 100644 index f00a5436..00000000 --- a/result/relaxng/tutor5_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor5_3.rng validates diff --git a/result/relaxng/tutor5_4_err b/result/relaxng/tutor5_4_err deleted file mode 100644 index 669b41d4..00000000 --- a/result/relaxng/tutor5_4_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor5_4.rng validates diff --git a/result/relaxng/tutor5_5_err b/result/relaxng/tutor5_5_err deleted file mode 100644 index 4f9f0f55..00000000 --- a/result/relaxng/tutor5_5_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor5_5.rng validates diff --git a/result/relaxng/tutor6_1_err b/result/relaxng/tutor6_1_err deleted file mode 100644 index 7440829a..00000000 --- a/result/relaxng/tutor6_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor6_1.rng validates diff --git a/result/relaxng/tutor6_2_err b/result/relaxng/tutor6_2_err deleted file mode 100644 index ba78ec98..00000000 --- a/result/relaxng/tutor6_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor6_2.rng validates diff --git a/result/relaxng/tutor6_3_err b/result/relaxng/tutor6_3_err deleted file mode 100644 index 35dbe510..00000000 --- a/result/relaxng/tutor6_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor6_3.rng validates diff --git a/result/relaxng/tutor7_1_err b/result/relaxng/tutor7_1_err deleted file mode 100644 index 03d273f0..00000000 --- a/result/relaxng/tutor7_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor7_1.rng validates diff --git a/result/relaxng/tutor7_2_err b/result/relaxng/tutor7_2_err deleted file mode 100644 index cec5245f..00000000 --- a/result/relaxng/tutor7_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor7_2.rng validates diff --git a/result/relaxng/tutor7_3_err b/result/relaxng/tutor7_3_err deleted file mode 100644 index 9f1c5a38..00000000 --- a/result/relaxng/tutor7_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor7_3.rng validates diff --git a/result/relaxng/tutor8_1_err b/result/relaxng/tutor8_1_err deleted file mode 100644 index a4f6ce54..00000000 --- a/result/relaxng/tutor8_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor8_1.rng validates diff --git a/result/relaxng/tutor8_2_err b/result/relaxng/tutor8_2_err deleted file mode 100644 index fa3dcb22..00000000 --- a/result/relaxng/tutor8_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor8_2.rng validates diff --git a/result/relaxng/tutor8_3_err b/result/relaxng/tutor8_3_err deleted file mode 100644 index 01c6184d..00000000 --- a/result/relaxng/tutor8_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor8_3.rng validates diff --git a/result/relaxng/tutor9_10_err b/result/relaxng/tutor9_10_err deleted file mode 100644 index a8a7cb6a..00000000 --- a/result/relaxng/tutor9_10_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_10.rng validates diff --git a/result/relaxng/tutor9_11_err b/result/relaxng/tutor9_11_err deleted file mode 100644 index edd98bfa..00000000 --- a/result/relaxng/tutor9_11_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_11.rng validates diff --git a/result/relaxng/tutor9_12_err b/result/relaxng/tutor9_12_err deleted file mode 100644 index 8881730d..00000000 --- a/result/relaxng/tutor9_12_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_12.rng validates diff --git a/result/relaxng/tutor9_1_err b/result/relaxng/tutor9_1_err deleted file mode 100644 index 22c5f370..00000000 --- a/result/relaxng/tutor9_1_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_1.rng validates diff --git a/result/relaxng/tutor9_2_err b/result/relaxng/tutor9_2_err deleted file mode 100644 index 83c34ff7..00000000 --- a/result/relaxng/tutor9_2_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_2.rng validates diff --git a/result/relaxng/tutor9_3_err b/result/relaxng/tutor9_3_err deleted file mode 100644 index 0a82f8eb..00000000 --- a/result/relaxng/tutor9_3_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_3.rng validates diff --git a/result/relaxng/tutor9_4_err b/result/relaxng/tutor9_4_err deleted file mode 100644 index 42d087f3..00000000 --- a/result/relaxng/tutor9_4_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_4.rng validates diff --git a/result/relaxng/tutor9_5_err b/result/relaxng/tutor9_5_err deleted file mode 100644 index e6ddd7a3..00000000 --- a/result/relaxng/tutor9_5_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_5.rng validates diff --git a/result/relaxng/tutor9_6_err b/result/relaxng/tutor9_6_err deleted file mode 100644 index 897a0929..00000000 --- a/result/relaxng/tutor9_6_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_6.rng validates diff --git a/result/relaxng/tutor9_7_err b/result/relaxng/tutor9_7_err deleted file mode 100644 index e171320b..00000000 --- a/result/relaxng/tutor9_7_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_7.rng validates diff --git a/result/relaxng/tutor9_8_err b/result/relaxng/tutor9_8_err deleted file mode 100644 index 41a926c7..00000000 --- a/result/relaxng/tutor9_8_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_8.rng validates diff --git a/result/relaxng/tutor9_9_err b/result/relaxng/tutor9_9_err deleted file mode 100644 index c4a95fd1..00000000 --- a/result/relaxng/tutor9_9_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutor9_9.rng validates diff --git a/result/relaxng/tutorA_err b/result/relaxng/tutorA_err deleted file mode 100644 index b4ab892f..00000000 --- a/result/relaxng/tutorA_err +++ /dev/null @@ -1 +0,0 @@ -./test/relaxng/tutorA.rng validates diff --git a/result/valid/t4.dtd.err.rdr b/result/valid/t4.dtd.err.rdr deleted file mode 100644 index 23a32588..00000000 --- a/result/valid/t4.dtd.err.rdr +++ /dev/null @@ -1,6 +0,0 @@ -./test/valid/t4.dtd:1: parser error : StartTag: invalid element name -<!ENTITY % percent "%"> - ^ -./test/valid/t4.dtd:1: parser error : Extra content at the end of the document -<!ENTITY % percent "%"> - ^ diff --git a/result/valid/t4a.dtd.err.rdr b/result/valid/t4a.dtd.err.rdr deleted file mode 100644 index 48cdd5f9..00000000 --- a/result/valid/t4a.dtd.err.rdr +++ /dev/null @@ -1,6 +0,0 @@ -./test/valid/t4a.dtd:1: parser error : StartTag: invalid element name -<!ENTITY % percent "%"> - ^ -./test/valid/t4a.dtd:1: parser error : Extra content at the end of the document -<!ENTITY % percent "%"> - ^ diff --git a/result/valid/t6.dtd.err.rdr b/result/valid/t6.dtd.err.rdr deleted file mode 100644 index 6e84d68a..00000000 --- a/result/valid/t6.dtd.err.rdr +++ /dev/null @@ -1,6 +0,0 @@ -./test/valid/t6.dtd:1: parser error : StartTag: invalid element name -<!ENTITY % xdef "def"> - ^ -./test/valid/t6.dtd:1: parser error : Extra content at the end of the document -<!ENTITY % xdef "def"> - ^ diff --git a/testC14N.c b/testC14N.c deleted file mode 100644 index ebd9fe01..00000000 --- a/testC14N.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Canonical XML implementation test program - * (http://www.w3.org/TR/2001/REC-xml-c14n-20010315) - * - * See Copyright for the status of this software. - * - * Author: Aleksey Sanin <aleksey@aleksey.com> - */ -#include "libxml.h" -#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED) - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#ifndef STDOUT_FILENO -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#else -#define STDOUT_FILENO fileno(stdout) -#endif /* HAVE_UNISTD_H */ -#endif -#ifdef _WIN32 -#include <io.h> -#endif - -#include <libxml/xmlmemory.h> -#include <libxml/parser.h> -#include <libxml/xpath.h> -#include <libxml/xpathInternals.h> - -#include <libxml/c14n.h> - - -static void usage(const char *name) { - fprintf(stderr, - "Usage: %s <mode> <xml-file> [<xpath-expr>] [<inclusive-ns-list>]\n", - name); - fprintf(stderr, "where <mode> is one of following:\n"); - fprintf(stderr, - "--with-comments \t XML file canonicalization v1.0 w comments \n"); - fprintf(stderr, - "--without-comments \t XML file canonicalization v1.0 w/o comments\n"); - fprintf(stderr, - "--1-1-with-comments \t XML file canonicalization v1.1 w comments\n"); - fprintf(stderr, - "--1-1-without-comments \t XML file canonicalization v1.1 w/o comments\n"); - fprintf(stderr, - "--exc-with-comments \t Exclusive XML file canonicalization v1.0 w comments\n"); - fprintf(stderr, - "--exc-without-comments\t Exclusive XML file canonicalization v1.0 w/o comments\n"); -} - -static xmlXPathObjectPtr -load_xpath_expr (xmlDocPtr parent_doc, const char* filename); - -static xmlChar **parse_list(xmlChar *str); - -/* static void print_xpath_nodes(xmlNodeSetPtr nodes); */ - -static int -test_c14n(const char* xml_filename, int with_comments, int mode, - const char* xpath_filename, xmlChar **inclusive_namespaces) { - xmlDocPtr doc; - xmlXPathObjectPtr xpath = NULL; - xmlChar *result = NULL; - int ret; - - /* - * build an XML tree from a the file; we need to add default - * attributes and resolve all character and entities references - */ - xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; - xmlSubstituteEntitiesDefault(1); - - doc = xmlReadFile(xml_filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); - if (doc == NULL) { - fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename); - return(-1); - } - - /* - * Check the document is of the right kind - */ - if(xmlDocGetRootElement(doc) == NULL) { - fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename); - xmlFreeDoc(doc); - return(-1); - } - - /* - * load xpath file if specified - */ - if(xpath_filename) { - xpath = load_xpath_expr(doc, xpath_filename); - if(xpath == NULL) { - fprintf(stderr,"Error: unable to evaluate xpath expression\n"); - xmlFreeDoc(doc); - return(-1); - } - } - - /* - * Canonical form - */ - /* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */ - ret = xmlC14NDocDumpMemory(doc, - (xpath) ? xpath->nodesetval : NULL, - mode, inclusive_namespaces, - with_comments, &result); - if(ret >= 0) { - if(result != NULL) { - if (write(STDOUT_FILENO, result, ret) == -1) { - fprintf(stderr, "Can't write data\n"); - } - xmlFree(result); - } - } else { - fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret); - if(result != NULL) xmlFree(result); - xmlFreeDoc(doc); - return(-1); - } - - /* - * Cleanup - */ - if(xpath != NULL) xmlXPathFreeObject(xpath); - xmlFreeDoc(doc); - - return(ret); -} - -int main(int argc, char **argv) { - int ret = -1; - - /* - * Init libxml - */ - xmlInitParser(); - LIBXML_TEST_VERSION - - /* - * Parse command line and process file - */ - if( argc < 3 ) { - fprintf(stderr, "Error: wrong number of arguments.\n"); - usage(argv[0]); - } else if(strcmp(argv[1], "--with-comments") == 0) { - ret = test_c14n(argv[2], 1, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL); - } else if(strcmp(argv[1], "--without-comments") == 0) { - ret = test_c14n(argv[2], 0, XML_C14N_1_0, (argc > 3) ? argv[3] : NULL, NULL); - } else if(strcmp(argv[1], "--1-1-with-comments") == 0) { - ret = test_c14n(argv[2], 1, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL); - } else if(strcmp(argv[1], "--1-1-without-comments") == 0) { - ret = test_c14n(argv[2], 0, XML_C14N_1_1, (argc > 3) ? argv[3] : NULL, NULL); - } else if(strcmp(argv[1], "--exc-with-comments") == 0) { - xmlChar **list; - - /* load exclusive namespace from command line */ - list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL; - ret = test_c14n(argv[2], 1, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list); - if(list != NULL) xmlFree(list); - } else if(strcmp(argv[1], "--exc-without-comments") == 0) { - xmlChar **list; - - /* load exclusive namespace from command line */ - list = (argc > 4) ? parse_list((xmlChar *)argv[4]) : NULL; - ret = test_c14n(argv[2], 0, XML_C14N_EXCLUSIVE_1_0, (argc > 3) ? argv[3] : NULL, list); - if(list != NULL) xmlFree(list); - } else { - fprintf(stderr, "Error: bad option.\n"); - usage(argv[0]); - } - - /* - * Shutdown libxml - */ - xmlCleanupParser(); - xmlMemoryDump(); - - return((ret >= 0) ? 0 : 1); -} - -/* - * Macro used to grow the current buffer. - */ -#define growBufferReentrant() { \ - buffer_size *= 2; \ - buffer = (xmlChar **) \ - xmlRealloc(buffer, buffer_size * sizeof(xmlChar*)); \ - if (buffer == NULL) { \ - perror("realloc failed"); \ - return(NULL); \ - } \ -} - -static xmlChar ** -parse_list(xmlChar *str) { - xmlChar **buffer; - xmlChar **out = NULL; - int buffer_size = 0; - int len; - - if(str == NULL) { - return(NULL); - } - - len = xmlStrlen(str); - if((str[0] == '\'') && (str[len - 1] == '\'')) { - str[len - 1] = '\0'; - str++; - } - /* - * allocate an translation buffer. - */ - buffer_size = 1000; - buffer = (xmlChar **) xmlMalloc(buffer_size * sizeof(xmlChar*)); - if (buffer == NULL) { - perror("malloc failed"); - return(NULL); - } - out = buffer; - - while(*str != '\0') { - if (out - buffer > buffer_size - 10) { - int indx = out - buffer; - - growBufferReentrant(); - out = &buffer[indx]; - } - (*out++) = str; - while(*str != ',' && *str != '\0') ++str; - if(*str == ',') *(str++) = '\0'; - } - (*out) = NULL; - return buffer; -} - -static xmlXPathObjectPtr -load_xpath_expr (xmlDocPtr parent_doc, const char* filename) { - xmlXPathObjectPtr xpath; - xmlDocPtr doc; - xmlChar *expr; - xmlXPathContextPtr ctx; - xmlNodePtr node; - xmlNsPtr ns; - - /* - * load XPath expr as a file - */ - xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; - xmlSubstituteEntitiesDefault(1); - - doc = xmlReadFile(filename, NULL, XML_PARSE_DTDATTR | XML_PARSE_NOENT); - if (doc == NULL) { - fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename); - return(NULL); - } - - /* - * Check the document is of the right kind - */ - if(xmlDocGetRootElement(doc) == NULL) { - fprintf(stderr,"Error: empty document for file \"%s\"\n", filename); - xmlFreeDoc(doc); - return(NULL); - } - - node = doc->children; - while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) { - node = node->next; - } - - if(node == NULL) { - fprintf(stderr,"Error: XPath element expected in the file \"%s\"\n", filename); - xmlFreeDoc(doc); - return(NULL); - } - - expr = xmlNodeGetContent(node); - if(expr == NULL) { - fprintf(stderr,"Error: XPath content element is NULL \"%s\"\n", filename); - xmlFreeDoc(doc); - return(NULL); - } - - ctx = xmlXPathNewContext(parent_doc); - if(ctx == NULL) { - fprintf(stderr,"Error: unable to create new context\n"); - xmlFree(expr); - xmlFreeDoc(doc); - return(NULL); - } - - /* - * Register namespaces - */ - ns = node->nsDef; - while(ns != NULL) { - if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) { - fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href); - xmlFree(expr); - xmlXPathFreeContext(ctx); - xmlFreeDoc(doc); - return(NULL); - } - ns = ns->next; - } - - /* - * Evaluate xpath - */ - xpath = xmlXPathEvalExpression(expr, ctx); - if(xpath == NULL) { - fprintf(stderr,"Error: unable to evaluate xpath expression\n"); - xmlFree(expr); - xmlXPathFreeContext(ctx); - xmlFreeDoc(doc); - return(NULL); - } - - /* print_xpath_nodes(xpath->nodesetval); */ - - xmlFree(expr); - xmlXPathFreeContext(ctx); - xmlFreeDoc(doc); - return(xpath); -} - -/* -static void -print_xpath_nodes(xmlNodeSetPtr nodes) { - xmlNodePtr cur; - int i; - - if(nodes == NULL ){ - fprintf(stderr, "Error: no nodes set defined\n"); - return; - } - - fprintf(stderr, "Nodes Set:\n-----\n"); - for(i = 0; i < nodes->nodeNr; ++i) { - if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) { - xmlNsPtr ns; - - ns = (xmlNsPtr)nodes->nodeTab[i]; - cur = (xmlNodePtr)ns->next; - fprintf(stderr, "namespace \"%s\"=\"%s\" for node %s:%s\n", - ns->prefix, ns->href, - (cur->ns) ? cur->ns->prefix : BAD_CAST "", cur->name); - } else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) { - cur = nodes->nodeTab[i]; - fprintf(stderr, "element node \"%s:%s\"\n", - (cur->ns) ? cur->ns->prefix : BAD_CAST "", cur->name); - } else { - cur = nodes->nodeTab[i]; - fprintf(stderr, "node \"%s\": type %d\n", cur->name, cur->type); - } - } -} -*/ - -#else -#include <stdio.h> -int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { - printf("%s : XPath/Canonicalization and output support not compiled in\n", argv[0]); - return(0); -} -#endif /* LIBXML_C14N_ENABLED */ - - diff --git a/testHTML.c b/testHTML.c deleted file mode 100644 index 359fba47..00000000 --- a/testHTML.c +++ /dev/null @@ -1,852 +0,0 @@ -/* - * testHTML.c : a small tester program for HTML input. - * - * See Copyright for the status of this software. - * - * daniel@veillard.com - */ - -#include "libxml.h" - -#ifdef LIBXML_HTML_ENABLED - -#include <string.h> -#include <stdarg.h> -#include <stdlib.h> - -#include <libxml/xmlmemory.h> -#include <libxml/HTMLparser.h> -#include <libxml/HTMLtree.h> -#include <libxml/debugXML.h> -#include <libxml/xmlerror.h> -#include <libxml/globals.h> - -#ifdef LIBXML_DEBUG_ENABLED -static int debug = 0; -#endif -static int copy = 0; -static int sax = 0; -static int repeat = 0; -static int noout = 0; -#ifdef LIBXML_PUSH_ENABLED -static int push = 0; -#endif /* LIBXML_PUSH_ENABLED */ -static char *encoding = NULL; -static int options = 0; - -static xmlSAXHandler emptySAXHandlerStruct = { - NULL, /* internalSubset */ - NULL, /* isStandalone */ - NULL, /* hasInternalSubset */ - NULL, /* hasExternalSubset */ - NULL, /* resolveEntity */ - NULL, /* getEntity */ - NULL, /* entityDecl */ - NULL, /* notationDecl */ - NULL, /* attributeDecl */ - NULL, /* elementDecl */ - NULL, /* unparsedEntityDecl */ - NULL, /* setDocumentLocator */ - NULL, /* startDocument */ - NULL, /* endDocument */ - NULL, /* startElement */ - NULL, /* endElement */ - NULL, /* reference */ - NULL, /* characters */ - NULL, /* ignorableWhitespace */ - NULL, /* processingInstruction */ - NULL, /* comment */ - NULL, /* xmlParserWarning */ - NULL, /* xmlParserError */ - NULL, /* xmlParserError */ - NULL, /* getParameterEntity */ - NULL, /* cdataBlock */ - NULL, /* externalSubset */ - 1, /* initialized */ - NULL, /* private */ - NULL, /* startElementNsSAX2Func */ - NULL, /* endElementNsSAX2Func */ - NULL /* xmlStructuredErrorFunc */ -}; - -static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; -extern xmlSAXHandlerPtr debugSAXHandler; - -/************************************************************************ - * * - * Debug Handlers * - * * - ************************************************************************/ - -/** - * isStandaloneDebug: - * @ctxt: An XML parser context - * - * Is this document tagged standalone ? - * - * Returns 1 if true - */ -static int -isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED) -{ - fprintf(stdout, "SAX.isStandalone()\n"); - return(0); -} - -/** - * hasInternalSubsetDebug: - * @ctxt: An XML parser context - * - * Does this document has an internal subset - * - * Returns 1 if true - */ -static int -hasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) -{ - fprintf(stdout, "SAX.hasInternalSubset()\n"); - return(0); -} - -/** - * hasExternalSubsetDebug: - * @ctxt: An XML parser context - * - * Does this document has an external subset - * - * Returns 1 if true - */ -static int -hasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) -{ - fprintf(stdout, "SAX.hasExternalSubset()\n"); - return(0); -} - -/** - * hasInternalSubsetDebug: - * @ctxt: An XML parser context - * - * Does this document has an internal subset - */ -static void -internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, - const xmlChar *ExternalID, const xmlChar *SystemID) -{ - fprintf(stdout, "SAX.internalSubset(%s,", name); - if (ExternalID == NULL) - fprintf(stdout, " ,"); - else - fprintf(stdout, " %s,", ExternalID); - if (SystemID == NULL) - fprintf(stdout, " )\n"); - else - fprintf(stdout, " %s)\n", SystemID); -} - -/** - * resolveEntityDebug: - * @ctxt: An XML parser context - * @publicId: The public ID of the entity - * @systemId: The system ID of the entity - * - * Special entity resolver, better left to the parser, it has - * more context than the application layer. - * The default behaviour is to NOT resolve the entities, in that case - * the ENTITY_REF nodes are built in the structure (and the parameter - * values). - * - * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. - */ -static xmlParserInputPtr -resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId) -{ - /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ - - - fprintf(stdout, "SAX.resolveEntity("); - if (publicId != NULL) - fprintf(stdout, "%s", (char *)publicId); - else - fprintf(stdout, " "); - if (systemId != NULL) - fprintf(stdout, ", %s)\n", (char *)systemId); - else - fprintf(stdout, ", )\n"); -/********* - if (systemId != NULL) { - return(xmlNewInputFromFile(ctxt, (char *) systemId)); - } - *********/ - return(NULL); -} - -/** - * getEntityDebug: - * @ctxt: An XML parser context - * @name: The entity name - * - * Get an entity by name - * - * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. - */ -static xmlEntityPtr -getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) -{ - fprintf(stdout, "SAX.getEntity(%s)\n", name); - return(NULL); -} - -/** - * getParameterEntityDebug: - * @ctxt: An XML parser context - * @name: The entity name - * - * Get a parameter entity by name - * - * Returns the xmlParserInputPtr - */ -static xmlEntityPtr -getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) -{ - fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); - return(NULL); -} - - -/** - * entityDeclDebug: - * @ctxt: An XML parser context - * @name: the entity name - * @type: the entity type - * @publicId: The public ID of the entity - * @systemId: The system ID of the entity - * @content: the entity value (without processing). - * - * An entity definition has been parsed - */ -static void -entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, - const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) -{ - fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", - name, type, publicId, systemId, content); -} - -/** - * attributeDeclDebug: - * @ctxt: An XML parser context - * @name: the attribute name - * @type: the attribute type - * - * An attribute definition has been parsed - */ -static void -attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *elem, const xmlChar *name, - int type, int def, const xmlChar *defaultValue, - xmlEnumerationPtr tree ATTRIBUTE_UNUSED) -{ - fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", - elem, name, type, def, defaultValue); -} - -/** - * elementDeclDebug: - * @ctxt: An XML parser context - * @name: the element name - * @type: the element type - * @content: the element value (without processing). - * - * An element definition has been parsed - */ -static void -elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, - xmlElementContentPtr content ATTRIBUTE_UNUSED) -{ - fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n", - name, type); -} - -/** - * notationDeclDebug: - * @ctxt: An XML parser context - * @name: The name of the notation - * @publicId: The public ID of the entity - * @systemId: The system ID of the entity - * - * What to do when a notation declaration has been parsed. - */ -static void -notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, - const xmlChar *publicId, const xmlChar *systemId) -{ - fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n", - (char *) name, (char *) publicId, (char *) systemId); -} - -/** - * unparsedEntityDeclDebug: - * @ctxt: An XML parser context - * @name: The name of the entity - * @publicId: The public ID of the entity - * @systemId: The system ID of the entity - * @notationName: the name of the notation - * - * What to do when an unparsed entity declaration is parsed - */ -static void -unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, - const xmlChar *publicId, const xmlChar *systemId, - const xmlChar *notationName) -{ - fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", - (char *) name, (char *) publicId, (char *) systemId, - (char *) notationName); -} - -/** - * setDocumentLocatorDebug: - * @ctxt: An XML parser context - * @loc: A SAX Locator - * - * Receive the document locator at startup, actually xmlDefaultSAXLocator - * Everything is available on the context, so this is useless in our case. - */ -static void -setDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED) -{ - fprintf(stdout, "SAX.setDocumentLocator()\n"); -} - -/** - * startDocumentDebug: - * @ctxt: An XML parser context - * - * called when the document start being processed. - */ -static void -startDocumentDebug(void *ctx ATTRIBUTE_UNUSED) -{ - fprintf(stdout, "SAX.startDocument()\n"); -} - -/** - * endDocumentDebug: - * @ctxt: An XML parser context - * - * called when the document end has been detected. - */ -static void -endDocumentDebug(void *ctx ATTRIBUTE_UNUSED) -{ - fprintf(stdout, "SAX.endDocument()\n"); -} - -/** - * startElementDebug: - * @ctxt: An XML parser context - * @name: The element name - * - * called when an opening tag has been processed. - */ -static void -startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts) -{ - int i; - - fprintf(stdout, "SAX.startElement(%s", (char *) name); - if (atts != NULL) { - for (i = 0;(atts[i] != NULL);i++) { - fprintf(stdout, ", %s", atts[i++]); - if (atts[i] != NULL) { - unsigned char output[40]; - const unsigned char *att = atts[i]; - int outlen, attlen; - fprintf(stdout, "='"); - while ((attlen = strlen((char*)att)) > 0) { - outlen = sizeof output - 1; - htmlEncodeEntities(output, &outlen, att, &attlen, '\''); - output[outlen] = 0; - fprintf(stdout, "%s", (char *) output); - att += attlen; - } - fprintf(stdout, "'"); - } - } - } - fprintf(stdout, ")\n"); -} - -/** - * endElementDebug: - * @ctxt: An XML parser context - * @name: The element name - * - * called when the end of an element has been detected. - */ -static void -endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) -{ - fprintf(stdout, "SAX.endElement(%s)\n", (char *) name); -} - -/** - * charactersDebug: - * @ctxt: An XML parser context - * @ch: a xmlChar string - * @len: the number of xmlChar - * - * receiving some chars from the parser. - * Question: how much at a time ??? - */ -static void -charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) -{ - unsigned char output[40]; - int inlen = len, outlen = 30; - - htmlEncodeEntities(output, &outlen, ch, &inlen, 0); - output[outlen] = 0; - - fprintf(stdout, "SAX.characters(%s, %d)\n", output, len); -} - -/** - * cdataDebug: - * @ctxt: An XML parser context - * @ch: a xmlChar string - * @len: the number of xmlChar - * - * receiving some cdata chars from the parser. - * Question: how much at a time ??? - */ -static void -cdataDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) -{ - unsigned char output[40]; - int inlen = len, outlen = 30; - - htmlEncodeEntities(output, &outlen, ch, &inlen, 0); - output[outlen] = 0; - - fprintf(stdout, "SAX.cdata(%s, %d)\n", output, len); -} - -/** - * referenceDebug: - * @ctxt: An XML parser context - * @name: The entity name - * - * called when an entity reference is detected. - */ -static void -referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) -{ - fprintf(stdout, "SAX.reference(%s)\n", name); -} - -/** - * ignorableWhitespaceDebug: - * @ctxt: An XML parser context - * @ch: a xmlChar string - * @start: the first char in the string - * @len: the number of xmlChar - * - * receiving some ignorable whitespaces from the parser. - * Question: how much at a time ??? - */ -static void -ignorableWhitespaceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) -{ - char output[40]; - int i; - - for (i = 0;(i<len) && (i < 30);i++) - output[i] = ch[i]; - output[i] = 0; - - fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", output, len); -} - -/** - * processingInstructionDebug: - * @ctxt: An XML parser context - * @target: the target name - * @data: the PI data's - * @len: the number of xmlChar - * - * A processing instruction has been parsed. - */ -static void -processingInstructionDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *target, - const xmlChar *data) -{ - fprintf(stdout, "SAX.processingInstruction(%s, %s)\n", - (char *) target, (char *) data); -} - -/** - * commentDebug: - * @ctxt: An XML parser context - * @value: the comment content - * - * A comment has been parsed. - */ -static void -commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value) -{ - fprintf(stdout, "SAX.comment(%s)\n", value); -} - -/** - * warningDebug: - * @ctxt: An XML parser context - * @msg: the message to display/transmit - * @...: extra parameters for the message display - * - * Display and format a warning messages, gives file, line, position and - * extra parameters. - */ -static void XMLCDECL -warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) -{ - va_list args; - - va_start(args, msg); - fprintf(stdout, "SAX.warning: "); - vfprintf(stdout, msg, args); - va_end(args); -} - -/** - * errorDebug: - * @ctxt: An XML parser context - * @msg: the message to display/transmit - * @...: extra parameters for the message display - * - * Display and format a error messages, gives file, line, position and - * extra parameters. - */ -static void XMLCDECL -errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) -{ - va_list args; - - va_start(args, msg); - fprintf(stdout, "SAX.error: "); - vfprintf(stdout, msg, args); - va_end(args); -} - -/** - * fatalErrorDebug: - * @ctxt: An XML parser context - * @msg: the message to display/transmit - * @...: extra parameters for the message display - * - * Display and format a fatalError messages, gives file, line, position and - * extra parameters. - */ -static void XMLCDECL -fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) -{ - va_list args; - - va_start(args, msg); - fprintf(stdout, "SAX.fatalError: "); - vfprintf(stdout, msg, args); - va_end(args); -} - -static xmlSAXHandler debugSAXHandlerStruct = { - internalSubsetDebug, - isStandaloneDebug, - hasInternalSubsetDebug, - hasExternalSubsetDebug, - resolveEntityDebug, - getEntityDebug, - entityDeclDebug, - notationDeclDebug, - attributeDeclDebug, - elementDeclDebug, - unparsedEntityDeclDebug, - setDocumentLocatorDebug, - startDocumentDebug, - endDocumentDebug, - startElementDebug, - endElementDebug, - referenceDebug, - charactersDebug, - ignorableWhitespaceDebug, - processingInstructionDebug, - commentDebug, - warningDebug, - errorDebug, - fatalErrorDebug, - getParameterEntityDebug, - cdataDebug, - NULL, - 1, - NULL, - NULL, - NULL, - NULL -}; - -xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct; -/************************************************************************ - * * - * Debug * - * * - ************************************************************************/ - -static void -parseSAXFile(char *filename) { - htmlDocPtr doc = NULL; - - /* - * Empty callbacks for checking - */ -#ifdef LIBXML_PUSH_ENABLED - if (push) { - FILE *f; - - f = fopen(filename, "rb"); - if (f != NULL) { - int res, size = 3; - char chars[4096]; - htmlParserCtxtPtr ctxt; - - /* if (repeat) */ - size = 4096; - res = fread(chars, 1, 4, f); - if (res > 0) { - ctxt = htmlCreatePushParserCtxt(emptySAXHandler, NULL, - chars, res, filename, XML_CHAR_ENCODING_NONE); - while ((res = fread(chars, 1, size, f)) > 0) { - htmlParseChunk(ctxt, chars, res, 0); - } - htmlParseChunk(ctxt, chars, 0, 1); - doc = ctxt->myDoc; - htmlFreeParserCtxt(ctxt); - } - if (doc != NULL) { - fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); - xmlFreeDoc(doc); - } - fclose(f); - } - if (!noout) { - f = fopen(filename, "rb"); - if (f != NULL) { - int res, size = 3; - char chars[4096]; - htmlParserCtxtPtr ctxt; - - /* if (repeat) */ - size = 4096; - res = fread(chars, 1, 4, f); - if (res > 0) { - ctxt = htmlCreatePushParserCtxt(debugSAXHandler, NULL, - chars, res, filename, XML_CHAR_ENCODING_NONE); - while ((res = fread(chars, 1, size, f)) > 0) { - htmlParseChunk(ctxt, chars, res, 0); - } - htmlParseChunk(ctxt, chars, 0, 1); - doc = ctxt->myDoc; - htmlFreeParserCtxt(ctxt); - } - if (doc != NULL) { - fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); - xmlFreeDoc(doc); - } - fclose(f); - } - } - } else { -#endif /* LIBXML_PUSH_ENABLED */ - doc = htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL); - if (doc != NULL) { - fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); - xmlFreeDoc(doc); - } - - if (!noout) { - /* - * Debug callback - */ - doc = htmlSAXParseFile(filename, NULL, debugSAXHandler, NULL); - if (doc != NULL) { - fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); - xmlFreeDoc(doc); - } - } -#ifdef LIBXML_PUSH_ENABLED - } -#endif /* LIBXML_PUSH_ENABLED */ -} - -static void -parseAndPrintFile(char *filename) { - htmlDocPtr doc = NULL; - - /* - * build an HTML tree from a string; - */ -#ifdef LIBXML_PUSH_ENABLED - if (push) { - FILE *f; - - f = fopen(filename, "rb"); - if (f != NULL) { - int res, size = 3; - char chars[4096]; - htmlParserCtxtPtr ctxt; - - /* if (repeat) */ - size = 4096; - res = fread(chars, 1, 4, f); - if (res > 0) { - ctxt = htmlCreatePushParserCtxt(NULL, NULL, - chars, res, filename, XML_CHAR_ENCODING_NONE); - while ((res = fread(chars, 1, size, f)) > 0) { - htmlParseChunk(ctxt, chars, res, 0); - } - htmlParseChunk(ctxt, chars, 0, 1); - doc = ctxt->myDoc; - htmlFreeParserCtxt(ctxt); - } - fclose(f); - } - } else { - doc = htmlReadFile(filename, NULL, options); - } -#else - doc = htmlReadFile(filename,NULL,options); -#endif - if (doc == NULL) { - xmlGenericError(xmlGenericErrorContext, - "Could not parse %s\n", filename); - } - -#ifdef LIBXML_TREE_ENABLED - /* - * test intermediate copy if needed. - */ - if (copy) { - htmlDocPtr tmp; - - tmp = doc; - doc = xmlCopyDoc(doc, 1); - xmlFreeDoc(tmp); - } -#endif - -#ifdef LIBXML_OUTPUT_ENABLED - /* - * print it. - */ - if (!noout) { -#ifdef LIBXML_DEBUG_ENABLED - if (!debug) { - if (encoding) - htmlSaveFileEnc("-", doc, encoding); - else - htmlDocDump(stdout, doc); - } else - xmlDebugDumpDocument(stdout, doc); -#else - if (encoding) - htmlSaveFileEnc("-", doc, encoding); - else - htmlDocDump(stdout, doc); -#endif - } -#endif /* LIBXML_OUTPUT_ENABLED */ - - /* - * free it. - */ - xmlFreeDoc(doc); -} - -int main(int argc, char **argv) { - int i, count; - int files = 0; - - for (i = 1; i < argc ; i++) { -#ifdef LIBXML_DEBUG_ENABLED - if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) - debug++; - else -#endif - if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) - copy++; -#ifdef LIBXML_PUSH_ENABLED - else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push"))) - push++; -#endif /* LIBXML_PUSH_ENABLED */ - else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax"))) - sax++; - else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) - noout++; - else if ((!strcmp(argv[i], "-repeat")) || - (!strcmp(argv[i], "--repeat"))) - repeat++; - else if ((!strcmp(argv[i], "-encode")) || - (!strcmp(argv[i], "--encode"))) { - i++; - encoding = argv[i]; - } - } - for (i = 1; i < argc ; i++) { - if ((!strcmp(argv[i], "-encode")) || - (!strcmp(argv[i], "--encode"))) { - i++; - continue; - } - if (argv[i][0] != '-') { - if (repeat) { - for (count = 0;count < 100 * repeat;count++) { - if (sax) - parseSAXFile(argv[i]); - else - parseAndPrintFile(argv[i]); - } - } else { - if (sax) - parseSAXFile(argv[i]); - else - parseAndPrintFile(argv[i]); - } - files ++; - } - } - if (files == 0) { - printf("Usage : %s [--debug] [--copy] [--copy] HTMLfiles ...\n", - argv[0]); - printf("\tParse the HTML files and output the result of the parsing\n"); -#ifdef LIBXML_DEBUG_ENABLED - printf("\t--debug : dump a debug tree of the in-memory document\n"); -#endif - printf("\t--copy : used to test the internal copy implementation\n"); - printf("\t--sax : debug the sequence of SAX callbacks\n"); - printf("\t--repeat : parse the file 100 times, for timing\n"); - printf("\t--noout : do not print the result\n"); -#ifdef LIBXML_PUSH_ENABLED - printf("\t--push : use the push mode parser\n"); -#endif /* LIBXML_PUSH_ENABLED */ - printf("\t--encode encoding : output in the given encoding\n"); - } - xmlCleanupParser(); - xmlMemoryDump(); - - return(0); -} -#else /* !LIBXML_HTML_ENABLED */ -#include <stdio.h> -int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { - printf("%s : HTML support not compiled in\n", argv[0]); - return(0); -} -#endif diff --git a/testReader.c b/testReader.c deleted file mode 100644 index c4848fc5..00000000 --- a/testReader.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * testReader.c : a small tester program for parsing using the xmlReader - * - * See Copyright for the status of this software. - * - * daniel@veillard.com - */ - -#include "libxml.h" - -#ifdef LIBXML_READER_ENABLED -#include <string.h> -#include <stdarg.h> -#include <stdlib.h> - -#include <libxml/xmlreader.h> - -static int debug = 0; -static int dump = 0; -static int noent = 0; -static int count = 0; -static int valid = 0; -static int consumed = 0; - -static void usage(const char *progname) { - printf("Usage : %s [options] XMLfiles ...\n", progname); - printf("\tParse the XML files using the xmlTextReader API\n"); - printf("\t --count: count the number of attribute and elements\n"); - printf("\t --valid: validate the document\n"); - printf("\t --consumed: count the number of bytes consumed\n"); - exit(1); -} -static int elem, attrs; - -static void processNode(xmlTextReaderPtr reader) { - int type; - - type = xmlTextReaderNodeType(reader); - if (count) { - if (type == 1) { - elem++; - attrs += xmlTextReaderAttributeCount(reader); - } - } -} - -static void handleFile(const char *filename) { - xmlTextReaderPtr reader; - int ret; - - if (count) { - elem = 0; - attrs = 0; - } - - reader = xmlNewTextReaderFilename(filename); - if (reader != NULL) { - if (valid) - xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); - - /* - * Process all nodes in sequence - */ - ret = xmlTextReaderRead(reader); - while (ret == 1) { - processNode(reader); - ret = xmlTextReaderRead(reader); - } - - /* - * Done, cleanup and status - */ - if (consumed) - printf("%ld bytes consumed by parser\n", xmlTextReaderByteConsumed(reader)); - xmlFreeTextReader(reader); - if (ret != 0) { - printf("%s : failed to parse\n", filename); - } else if (count) - printf("%s : %d elements, %d attributes\n", filename, elem, attrs); - } else { - fprintf(stderr, "Unable to open %s\n", filename); - } -} - -int main(int argc, char **argv) { - int i; - int files = 0; - - if (argc <= 1) { - usage(argv[0]); - return(1); - } - LIBXML_TEST_VERSION - for (i = 1; i < argc ; i++) { - if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) - debug++; - else if ((!strcmp(argv[i], "-dump")) || (!strcmp(argv[i], "--dump"))) - dump++; - else if ((!strcmp(argv[i], "-count")) || (!strcmp(argv[i], "--count"))) - count++; - else if ((!strcmp(argv[i], "-consumed")) || (!strcmp(argv[i], "--consumed"))) - consumed++; - else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid"))) - valid++; - else if ((!strcmp(argv[i], "-noent")) || - (!strcmp(argv[i], "--noent"))) - noent++; - } - if (noent != 0) xmlSubstituteEntitiesDefault(1); - for (i = 1; i < argc ; i++) { - if (argv[i][0] != '-') { - handleFile(argv[i]); - files ++; - } - } - xmlCleanupParser(); - xmlMemoryDump(); - - return(0); -} -#else -int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { - printf("%s : xmlReader parser support not compiled in\n", argv[0]); - return(0); -} -#endif /* LIBXML_READER_ENABLED */ diff --git a/testRelax.c b/testRelax.c deleted file mode 100644 index b1701606..00000000 --- a/testRelax.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * testRelax.c : a small tester program for RelaxNG validation - * - * See Copyright for the status of this software. - * - * Daniel.Veillard@w3.org - */ - -#include "libxml.h" -#ifdef LIBXML_SCHEMAS_ENABLED - -#include <libxml/xmlversion.h> -#include <libxml/parser.h> - -#include <stdio.h> -#include <string.h> -#include <stdarg.h> -#include <stdlib.h> - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -/* seems needed for Solaris */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *) -1) -#endif -#endif - -#include <libxml/xmlmemory.h> -#include <libxml/debugXML.h> -#include <libxml/relaxng.h> - -#ifdef LIBXML_DEBUG_ENABLED -static int debug = 0; -#endif -static int noout = 0; -static int tree = 0; -#ifdef HAVE_MMAP -static int memory = 0; -#endif - - -int main(int argc, char **argv) { - int i; - int files = 0; - xmlRelaxNGPtr schema = NULL; - - for (i = 1; i < argc ; i++) { -#ifdef LIBXML_DEBUG_ENABLED - if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) - debug++; - else -#endif -#ifdef HAVE_MMAP - if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) { - memory++; - } else -#endif - if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) { - noout++; - } else - if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree"))) { - tree++; - } - } - xmlLineNumbersDefault(1); - xmlSubstituteEntitiesDefault(1); - for (i = 1; i < argc ; i++) { - if (argv[i][0] != '-') { - if (schema == NULL) { - xmlRelaxNGParserCtxtPtr ctxt; - -#ifdef HAVE_MMAP - if (memory) { - int fd; - struct stat info; - const char *base; - if (stat(argv[i], &info) < 0) - break; - if ((fd = open(argv[i], O_RDONLY)) < 0) - break; - base = mmap(NULL, info.st_size, PROT_READ, - MAP_SHARED, fd, 0) ; - if (base == (void *) MAP_FAILED) - break; - - ctxt = xmlRelaxNGNewMemParserCtxt((char *)base,info.st_size); - - xmlRelaxNGSetParserErrors(ctxt, - xmlGenericError, xmlGenericError, NULL); - schema = xmlRelaxNGParse(ctxt); - xmlRelaxNGFreeParserCtxt(ctxt); - munmap((char *) base, info.st_size); - } else -#endif - { - ctxt = xmlRelaxNGNewParserCtxt(argv[i]); - xmlRelaxNGSetParserErrors(ctxt, - xmlGenericError, xmlGenericError, NULL); - schema = xmlRelaxNGParse(ctxt); - xmlRelaxNGFreeParserCtxt(ctxt); - } - if (schema == NULL) { - printf("Relax-NG schema %s failed to compile\n", argv[i]); - files = -1; - break; - } -#ifdef LIBXML_OUTPUT_ENABLED -#ifdef LIBXML_DEBUG_ENABLED - if (debug) - xmlRelaxNGDump(stdout, schema); -#endif - if (tree) - xmlRelaxNGDumpTree(stdout, schema); -#endif /* LIBXML_OUTPUT_ENABLED */ - } else { - xmlDocPtr doc; - - doc = xmlReadFile(argv[i],NULL,0); - - if (doc == NULL) { - fprintf(stderr, "Could not parse %s\n", argv[i]); - } else { - xmlRelaxNGValidCtxtPtr ctxt; - int ret; - - ctxt = xmlRelaxNGNewValidCtxt(schema); - xmlRelaxNGSetValidErrors(ctxt, - xmlGenericError, xmlGenericError, NULL); - ret = xmlRelaxNGValidateDoc(ctxt, doc); - if (ret == 0) { - printf("%s validates\n", argv[i]); - } else if (ret > 0) { - printf("%s fails to validate\n", argv[i]); - } else { - printf("%s validation generated an internal error\n", - argv[i]); - } - xmlRelaxNGFreeValidCtxt(ctxt); - xmlFreeDoc(doc); - } - } - files ++; - } - } - if (schema != NULL) - xmlRelaxNGFree(schema); - if (files == 0) { - printf("Usage : %s [--debug] [--noout] schemas XMLfiles ...\n", - argv[0]); - printf("\tParse the HTML files and output the result of the parsing\n"); -#ifdef LIBXML_DEBUG_ENABLED - printf("\t--debug : dump a debug tree of the in-memory document\n"); -#endif - printf("\t--noout : do not print the result\n"); - printf("\t--tree : print the intermediate Relax-NG document tree\n"); -#ifdef HAVE_MMAP - printf("\t--memory : test the schemas in memory parsing\n"); -#endif - } - xmlCleanupParser(); - xmlMemoryDump(); - - return(0); -} - -#else -#include <stdio.h> -int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { - printf("%s : RelaxNG support not compiled in\n", argv[0]); - return(0); -} -#endif /* LIBXML_SCHEMAS_ENABLED */ diff --git a/testSAX.c b/testSAX.c deleted file mode 100644 index 8faa5880..00000000 --- a/testSAX.c +++ /dev/null @@ -1,1136 +0,0 @@ -/* - * testSAX.c : a small tester program for parsing using the SAX API. - * - * See Copyright for the status of this software. - * - * daniel@veillard.com - */ - -#include "libxml.h" - -#ifdef LIBXML_SAX1_ENABLED - -#include <string.h> -#include <stdarg.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#endif -#ifdef HAVE_SYS_TIMEB_H -#include <sys/timeb.h> -#endif - -#include <libxml/globals.h> -#include <libxml/xmlerror.h> -#include <libxml/parser.h> -#include <libxml/parserInternals.h> /* only for xmlNewInputFromFile() */ -#include <libxml/tree.h> -#include <libxml/debugXML.h> -#include <libxml/xmlmemory.h> - -static int debug = 0; -static int copy = 0; -static int recovery = 0; -static int push = 0; -static int speed = 0; -static int noent = 0; -static int quiet = 0; -static int nonull = 0; -static int sax2 = 0; -static int repeat = 0; -static int callbacks = 0; -static int timing = 0; - -/* - * Timing routines. - */ -/* - * Internal timing routines to remove the necessity to have unix-specific - * function calls - */ - -#ifndef HAVE_GETTIMEOFDAY -#ifdef HAVE_SYS_TIMEB_H -#ifdef HAVE_SYS_TIME_H -#ifdef HAVE_FTIME - -static int -my_gettimeofday(struct timeval *tvp, void *tzp) -{ - struct timeb timebuffer; - - ftime(&timebuffer); - if (tvp) { - tvp->tv_sec = timebuffer.time; - tvp->tv_usec = timebuffer.millitm * 1000L; - } - return (0); -} -#define HAVE_GETTIMEOFDAY 1 -#define gettimeofday my_gettimeofday - -#endif /* HAVE_FTIME */ -#endif /* HAVE_SYS_TIME_H */ -#endif /* HAVE_SYS_TIMEB_H */ -#endif /* !HAVE_GETTIMEOFDAY */ - -#if defined(HAVE_GETTIMEOFDAY) -static struct timeval begin, end; - -/* - * startTimer: call where you want to start timing - */ -static void -startTimer(void) -{ - gettimeofday(&begin, NULL); -} - -/* - * endTimer: call where you want to stop timing and to print out a - * message about the timing performed; format is a printf - * type argument - */ -static void XMLCDECL -endTimer(const char *fmt, ...) -{ - long msec; - va_list ap; - - gettimeofday(&end, NULL); - msec = end.tv_sec - begin.tv_sec; - msec *= 1000; - msec += (end.tv_usec - begin.tv_usec) / 1000; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - - fprintf(stderr, " took %ld ms\n", msec); -} -#else -/* - * No gettimeofday function, so we have to make do with calling clock. - * This is obviously less accurate, but there's little we can do about - * that. - */ -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 100 -#endif - -static clock_t begin, end; -static void -startTimer(void) -{ - begin = clock(); -} -static void XMLCDECL -endTimer(const char *fmt, ...) -{ - long msec; - va_list ap; - - end = clock(); - msec = ((end - begin) * 1000) / CLOCKS_PER_SEC; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, " took %ld ms\n", msec); -} -#endif - -/* - * empty SAX block - */ -static xmlSAXHandler emptySAXHandlerStruct = { - NULL, /* internalSubset */ - NULL, /* isStandalone */ - NULL, /* hasInternalSubset */ - NULL, /* hasExternalSubset */ - NULL, /* resolveEntity */ - NULL, /* getEntity */ - NULL, /* entityDecl */ - NULL, /* notationDecl */ - NULL, /* attributeDecl */ - NULL, /* elementDecl */ - NULL, /* unparsedEntityDecl */ - NULL, /* setDocumentLocator */ - NULL, /* startDocument */ - NULL, /* endDocument */ - NULL, /* startElement */ - NULL, /* endElement */ - NULL, /* reference */ - NULL, /* characters */ - NULL, /* ignorableWhitespace */ - NULL, /* processingInstruction */ - NULL, /* comment */ - NULL, /* xmlParserWarning */ - NULL, /* xmlParserError */ - NULL, /* xmlParserError */ - NULL, /* getParameterEntity */ - NULL, /* cdataBlock; */ - NULL, /* externalSubset; */ - 1, - NULL, - NULL, /* startElementNs */ - NULL, /* endElementNs */ - NULL /* xmlStructuredErrorFunc */ -}; - -static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; -extern xmlSAXHandlerPtr debugSAXHandler; - -/************************************************************************ - * * - * Debug Handlers * - * * - ************************************************************************/ - -/** - * isStandaloneDebug: - * @ctxt: An XML parser context - * - * Is this document tagged standalone ? - * - * Returns 1 if true - */ -static int -isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED) -{ - callbacks++; - if (quiet) - return(0); - fprintf(stdout, "SAX.isStandalone()\n"); - return(0); -} - -/** - * hasInternalSubsetDebug: - * @ctxt: An XML parser context - * - * Does this document has an internal subset - * - * Returns 1 if true - */ -static int -hasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) -{ - callbacks++; - if (quiet) - return(0); - fprintf(stdout, "SAX.hasInternalSubset()\n"); - return(0); -} - -/** - * hasExternalSubsetDebug: - * @ctxt: An XML parser context - * - * Does this document has an external subset - * - * Returns 1 if true - */ -static int -hasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED) -{ - callbacks++; - if (quiet) - return(0); - fprintf(stdout, "SAX.hasExternalSubset()\n"); - return(0); -} - -/** - * internalSubsetDebug: - * @ctxt: An XML parser context - * - * Does this document has an internal subset - */ -static void -internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, - const xmlChar *ExternalID, const xmlChar *SystemID) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.internalSubset(%s,", name); - if (ExternalID == NULL) - fprintf(stdout, " ,"); - else - fprintf(stdout, " %s,", ExternalID); - if (SystemID == NULL) - fprintf(stdout, " )\n"); - else - fprintf(stdout, " %s)\n", SystemID); -} - -/** - * externalSubsetDebug: - * @ctxt: An XML parser context - * - * Does this document has an external subset - */ -static void -externalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, - const xmlChar *ExternalID, const xmlChar *SystemID) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.externalSubset(%s,", name); - if (ExternalID == NULL) - fprintf(stdout, " ,"); - else - fprintf(stdout, " %s,", ExternalID); - if (SystemID == NULL) - fprintf(stdout, " )\n"); - else - fprintf(stdout, " %s)\n", SystemID); -} - -/** - * resolveEntityDebug: - * @ctxt: An XML parser context - * @publicId: The public ID of the entity - * @systemId: The system ID of the entity - * - * Special entity resolver, better left to the parser, it has - * more context than the application layer. - * The default behaviour is to NOT resolve the entities, in that case - * the ENTITY_REF nodes are built in the structure (and the parameter - * values). - * - * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. - */ -static xmlParserInputPtr -resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId) -{ - callbacks++; - if (quiet) - return(NULL); - /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ - - - fprintf(stdout, "SAX.resolveEntity("); - if (publicId != NULL) - fprintf(stdout, "%s", (char *)publicId); - else - fprintf(stdout, " "); - if (systemId != NULL) - fprintf(stdout, ", %s)\n", (char *)systemId); - else - fprintf(stdout, ", )\n"); -/********* - if (systemId != NULL) { - return(xmlNewInputFromFile(ctxt, (char *) systemId)); - } - *********/ - return(NULL); -} - -/** - * getEntityDebug: - * @ctxt: An XML parser context - * @name: The entity name - * - * Get an entity by name - * - * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. - */ -static xmlEntityPtr -getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) -{ - callbacks++; - if (quiet) - return(NULL); - fprintf(stdout, "SAX.getEntity(%s)\n", name); - return(NULL); -} - -/** - * getParameterEntityDebug: - * @ctxt: An XML parser context - * @name: The entity name - * - * Get a parameter entity by name - * - * Returns the xmlParserInputPtr - */ -static xmlEntityPtr -getParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) -{ - callbacks++; - if (quiet) - return(NULL); - fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); - return(NULL); -} - - -/** - * entityDeclDebug: - * @ctxt: An XML parser context - * @name: the entity name - * @type: the entity type - * @publicId: The public ID of the entity - * @systemId: The system ID of the entity - * @content: the entity value (without processing). - * - * An entity definition has been parsed - */ -static void -entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, - const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) -{ -const xmlChar *nullstr = BAD_CAST "(null)"; - /* not all libraries handle printing null pointers nicely */ - if (publicId == NULL) - publicId = nullstr; - if (systemId == NULL) - systemId = nullstr; - if (content == NULL) - content = (xmlChar *)nullstr; - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", - name, type, publicId, systemId, content); -} - -/** - * attributeDeclDebug: - * @ctxt: An XML parser context - * @name: the attribute name - * @type: the attribute type - * - * An attribute definition has been parsed - */ -static void -attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar * elem, - const xmlChar * name, int type, int def, - const xmlChar * defaultValue, xmlEnumerationPtr tree) -{ - callbacks++; - if (quiet) - return; - if (defaultValue == NULL) - fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n", - elem, name, type, def); - else - fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", - elem, name, type, def, defaultValue); - xmlFreeEnumeration(tree); -} - -/** - * elementDeclDebug: - * @ctxt: An XML parser context - * @name: the element name - * @type: the element type - * @content: the element value (without processing). - * - * An element definition has been parsed - */ -static void -elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, - xmlElementContentPtr content ATTRIBUTE_UNUSED) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n", - name, type); -} - -/** - * notationDeclDebug: - * @ctxt: An XML parser context - * @name: The name of the notation - * @publicId: The public ID of the entity - * @systemId: The system ID of the entity - * - * What to do when a notation declaration has been parsed. - */ -static void -notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, - const xmlChar *publicId, const xmlChar *systemId) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n", - (char *) name, (char *) publicId, (char *) systemId); -} - -/** - * unparsedEntityDeclDebug: - * @ctxt: An XML parser context - * @name: The name of the entity - * @publicId: The public ID of the entity - * @systemId: The system ID of the entity - * @notationName: the name of the notation - * - * What to do when an unparsed entity declaration is parsed - */ -static void -unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, - const xmlChar *publicId, const xmlChar *systemId, - const xmlChar *notationName) -{ -const xmlChar *nullstr = BAD_CAST "(null)"; - - if (publicId == NULL) - publicId = nullstr; - if (systemId == NULL) - systemId = nullstr; - if (notationName == NULL) - notationName = nullstr; - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", - (char *) name, (char *) publicId, (char *) systemId, - (char *) notationName); -} - -/** - * setDocumentLocatorDebug: - * @ctxt: An XML parser context - * @loc: A SAX Locator - * - * Receive the document locator at startup, actually xmlDefaultSAXLocator - * Everything is available on the context, so this is useless in our case. - */ -static void -setDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.setDocumentLocator()\n"); -} - -/** - * startDocumentDebug: - * @ctxt: An XML parser context - * - * called when the document start being processed. - */ -static void -startDocumentDebug(void *ctx ATTRIBUTE_UNUSED) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.startDocument()\n"); -} - -/** - * endDocumentDebug: - * @ctxt: An XML parser context - * - * called when the document end has been detected. - */ -static void -endDocumentDebug(void *ctx ATTRIBUTE_UNUSED) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.endDocument()\n"); -} - -/** - * startElementDebug: - * @ctxt: An XML parser context - * @name: The element name - * - * called when an opening tag has been processed. - */ -static void -startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts) -{ - int i; - - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.startElement(%s", (char *) name); - if (atts != NULL) { - for (i = 0;(atts[i] != NULL);i++) { - fprintf(stdout, ", %s='", atts[i++]); - if (atts[i] != NULL) - fprintf(stdout, "%s'", atts[i]); - } - } - fprintf(stdout, ")\n"); -} - -/** - * endElementDebug: - * @ctxt: An XML parser context - * @name: The element name - * - * called when the end of an element has been detected. - */ -static void -endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.endElement(%s)\n", (char *) name); -} - -/** - * charactersDebug: - * @ctxt: An XML parser context - * @ch: a xmlChar string - * @len: the number of xmlChar - * - * receiving some chars from the parser. - * Question: how much at a time ??? - */ -static void -charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) -{ - char output[40]; - int i; - - callbacks++; - if (quiet) - return; - for (i = 0;(i<len) && (i < 30);i++) - output[i] = ch[i]; - output[i] = 0; - - fprintf(stdout, "SAX.characters(%s, %d)\n", output, len); -} - -/** - * referenceDebug: - * @ctxt: An XML parser context - * @name: The entity name - * - * called when an entity reference is detected. - */ -static void -referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.reference(%s)\n", name); -} - -/** - * ignorableWhitespaceDebug: - * @ctxt: An XML parser context - * @ch: a xmlChar string - * @start: the first char in the string - * @len: the number of xmlChar - * - * receiving some ignorable whitespaces from the parser. - * Question: how much at a time ??? - */ -static void -ignorableWhitespaceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) -{ - char output[40]; - int i; - - callbacks++; - if (quiet) - return; - for (i = 0;(i<len) && (i < 30);i++) - output[i] = ch[i]; - output[i] = 0; - fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", output, len); -} - -/** - * processingInstructionDebug: - * @ctxt: An XML parser context - * @target: the target name - * @data: the PI data's - * @len: the number of xmlChar - * - * A processing instruction has been parsed. - */ -static void -processingInstructionDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *target, - const xmlChar *data) -{ - callbacks++; - if (quiet) - return; - if (data != NULL) - fprintf(stdout, "SAX.processingInstruction(%s, %s)\n", - (char *) target, (char *) data); - else - fprintf(stdout, "SAX.processingInstruction(%s, NULL)\n", - (char *) target); -} - -/** - * cdataBlockDebug: - * @ctx: the user data (XML parser context) - * @value: The pcdata content - * @len: the block length - * - * called when a pcdata block has been parsed - */ -static void -cdataBlockDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value, int len) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.pcdata(%.20s, %d)\n", - (char *) value, len); -} - -/** - * commentDebug: - * @ctxt: An XML parser context - * @value: the comment content - * - * A comment has been parsed. - */ -static void -commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.comment(%s)\n", value); -} - -/** - * warningDebug: - * @ctxt: An XML parser context - * @msg: the message to display/transmit - * @...: extra parameters for the message display - * - * Display and format a warning messages, gives file, line, position and - * extra parameters. - */ -static void XMLCDECL -warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) -{ - va_list args; - - callbacks++; - if (quiet) - return; - va_start(args, msg); - fprintf(stdout, "SAX.warning: "); - vfprintf(stdout, msg, args); - va_end(args); -} - -/** - * errorDebug: - * @ctxt: An XML parser context - * @msg: the message to display/transmit - * @...: extra parameters for the message display - * - * Display and format a error messages, gives file, line, position and - * extra parameters. - */ -static void XMLCDECL -errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) -{ - va_list args; - - callbacks++; - if (quiet) - return; - va_start(args, msg); - fprintf(stdout, "SAX.error: "); - vfprintf(stdout, msg, args); - va_end(args); -} - -/** - * fatalErrorDebug: - * @ctxt: An XML parser context - * @msg: the message to display/transmit - * @...: extra parameters for the message display - * - * Display and format a fatalError messages, gives file, line, position and - * extra parameters. - */ -static void XMLCDECL -fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) -{ - va_list args; - - callbacks++; - if (quiet) - return; - va_start(args, msg); - fprintf(stdout, "SAX.fatalError: "); - vfprintf(stdout, msg, args); - va_end(args); -} - -static xmlSAXHandler debugSAXHandlerStruct = { - internalSubsetDebug, - isStandaloneDebug, - hasInternalSubsetDebug, - hasExternalSubsetDebug, - resolveEntityDebug, - getEntityDebug, - entityDeclDebug, - notationDeclDebug, - attributeDeclDebug, - elementDeclDebug, - unparsedEntityDeclDebug, - setDocumentLocatorDebug, - startDocumentDebug, - endDocumentDebug, - startElementDebug, - endElementDebug, - referenceDebug, - charactersDebug, - ignorableWhitespaceDebug, - processingInstructionDebug, - commentDebug, - warningDebug, - errorDebug, - fatalErrorDebug, - getParameterEntityDebug, - cdataBlockDebug, - externalSubsetDebug, - 1, - NULL, - NULL, - NULL, - NULL -}; - -xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct; - -/* - * SAX2 specific callbacks - */ -/** - * startElementNsDebug: - * @ctxt: An XML parser context - * @name: The element name - * - * called when an opening tag has been processed. - */ -static void -startElementNsDebug(void *ctx ATTRIBUTE_UNUSED, - const xmlChar *localname, - const xmlChar *prefix, - const xmlChar *URI, - int nb_namespaces, - const xmlChar **namespaces, - int nb_attributes, - int nb_defaulted, - const xmlChar **attributes) -{ - int i; - - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.startElementNs(%s", (char *) localname); - if (prefix == NULL) - fprintf(stdout, ", NULL"); - else - fprintf(stdout, ", %s", (char *) prefix); - if (URI == NULL) - fprintf(stdout, ", NULL"); - else - fprintf(stdout, ", '%s'", (char *) URI); - fprintf(stdout, ", %d", nb_namespaces); - - if (namespaces != NULL) { - for (i = 0;i < nb_namespaces * 2;i++) { - fprintf(stdout, ", xmlns"); - if (namespaces[i] != NULL) - fprintf(stdout, ":%s", namespaces[i]); - i++; - fprintf(stdout, "='%s'", namespaces[i]); - } - } - fprintf(stdout, ", %d, %d", nb_attributes, nb_defaulted); - if (attributes != NULL) { - for (i = 0;i < nb_attributes * 5;i += 5) { - if (attributes[i + 1] != NULL) - fprintf(stdout, ", %s:%s='", attributes[i + 1], attributes[i]); - else - fprintf(stdout, ", %s='", attributes[i]); - fprintf(stdout, "%.4s...', %d", attributes[i + 3], - (int)(attributes[i + 4] - attributes[i + 3])); - } - } - fprintf(stdout, ")\n"); -} - -/** - * endElementDebug: - * @ctxt: An XML parser context - * @name: The element name - * - * called when the end of an element has been detected. - */ -static void -endElementNsDebug(void *ctx ATTRIBUTE_UNUSED, - const xmlChar *localname, - const xmlChar *prefix, - const xmlChar *URI) -{ - callbacks++; - if (quiet) - return; - fprintf(stdout, "SAX.endElementNs(%s", (char *) localname); - if (prefix == NULL) - fprintf(stdout, ", NULL"); - else - fprintf(stdout, ", %s", (char *) prefix); - if (URI == NULL) - fprintf(stdout, ", NULL)\n"); - else - fprintf(stdout, ", '%s')\n", (char *) URI); -} - -static xmlSAXHandler debugSAX2HandlerStruct = { - internalSubsetDebug, - isStandaloneDebug, - hasInternalSubsetDebug, - hasExternalSubsetDebug, - resolveEntityDebug, - getEntityDebug, - entityDeclDebug, - notationDeclDebug, - attributeDeclDebug, - elementDeclDebug, - unparsedEntityDeclDebug, - setDocumentLocatorDebug, - startDocumentDebug, - endDocumentDebug, - NULL, - NULL, - referenceDebug, - charactersDebug, - ignorableWhitespaceDebug, - processingInstructionDebug, - commentDebug, - warningDebug, - errorDebug, - fatalErrorDebug, - getParameterEntityDebug, - cdataBlockDebug, - externalSubsetDebug, - XML_SAX2_MAGIC, - NULL, - startElementNsDebug, - endElementNsDebug, - NULL -}; - -static xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct; - -/************************************************************************ - * * - * Debug * - * * - ************************************************************************/ - -static void -parseAndPrintFile(char *filename) { - int res; - -#ifdef LIBXML_PUSH_ENABLED - if (push) { - FILE *f; - - if ((!quiet) && (!nonull)) { - /* - * Empty callbacks for checking - */ - f = fopen(filename, "rb"); - if (f != NULL) { - int ret; - char chars[10]; - xmlParserCtxtPtr ctxt; - - ret = fread(chars, 1, 4, f); - if (ret > 0) { - ctxt = xmlCreatePushParserCtxt(emptySAXHandler, NULL, - chars, ret, filename); - while ((ret = fread(chars, 1, 3, f)) > 0) { - xmlParseChunk(ctxt, chars, ret, 0); - } - xmlParseChunk(ctxt, chars, 0, 1); - xmlFreeParserCtxt(ctxt); - } - fclose(f); - } else { - xmlGenericError(xmlGenericErrorContext, - "Cannot read file %s\n", filename); - } - } - /* - * Debug callback - */ - f = fopen(filename, "rb"); - if (f != NULL) { - int ret; - char chars[10]; - xmlParserCtxtPtr ctxt; - - ret = fread(chars, 1, 4, f); - if (ret > 0) { - if (sax2) - ctxt = xmlCreatePushParserCtxt(debugSAX2Handler, NULL, - chars, ret, filename); - else - ctxt = xmlCreatePushParserCtxt(debugSAXHandler, NULL, - chars, ret, filename); - while ((ret = fread(chars, 1, 3, f)) > 0) { - xmlParseChunk(ctxt, chars, ret, 0); - } - ret = xmlParseChunk(ctxt, chars, 0, 1); - xmlFreeParserCtxt(ctxt); - if (ret != 0) { - fprintf(stdout, - "xmlSAXUserParseFile returned error %d\n", ret); - } - } - fclose(f); - } - } else { -#endif /* LIBXML_PUSH_ENABLED */ - if (!speed) { - /* - * Empty callbacks for checking - */ - if ((!quiet) && (!nonull)) { - res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename); - if (res != 0) { - fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res); - } - } - - /* - * Debug callback - */ - callbacks = 0; - if (repeat) { - int i; - for (i = 0;i < 99;i++) { - if (sax2) - res = xmlSAXUserParseFile(debugSAX2Handler, NULL, - filename); - else - res = xmlSAXUserParseFile(debugSAXHandler, NULL, - filename); - } - } - if (sax2) - res = xmlSAXUserParseFile(debugSAX2Handler, NULL, filename); - else - res = xmlSAXUserParseFile(debugSAXHandler, NULL, filename); - if (res != 0) { - fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res); - } - if (quiet) - fprintf(stdout, "%d callbacks generated\n", callbacks); - } else { - /* - * test 100x the SAX parse - */ - int i; - - for (i = 0; i<100;i++) - res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename); - if (res != 0) { - fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res); - } - } -#ifdef LIBXML_PUSH_ENABLED - } -#endif -} - - -int main(int argc, char **argv) { - int i; - int files = 0; - - LIBXML_TEST_VERSION /* be safe, plus calls xmlInitParser */ - - for (i = 1; i < argc ; i++) { - if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) - debug++; - else if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) - copy++; - else if ((!strcmp(argv[i], "-recover")) || - (!strcmp(argv[i], "--recover"))) - recovery++; - else if ((!strcmp(argv[i], "-push")) || - (!strcmp(argv[i], "--push"))) -#ifdef LIBXML_PUSH_ENABLED - push++; -#else - fprintf(stderr,"'push' not enabled in library - ignoring\n"); -#endif /* LIBXML_PUSH_ENABLED */ - else if ((!strcmp(argv[i], "-speed")) || - (!strcmp(argv[i], "--speed"))) - speed++; - else if ((!strcmp(argv[i], "-timing")) || - (!strcmp(argv[i], "--timing"))) { - nonull++; - timing++; - quiet++; - } else if ((!strcmp(argv[i], "-repeat")) || - (!strcmp(argv[i], "--repeat"))) { - repeat++; - quiet++; - } else if ((!strcmp(argv[i], "-noent")) || - (!strcmp(argv[i], "--noent"))) - noent++; - else if ((!strcmp(argv[i], "-quiet")) || - (!strcmp(argv[i], "--quiet"))) - quiet++; - else if ((!strcmp(argv[i], "-sax2")) || - (!strcmp(argv[i], "--sax2"))) - sax2++; - else if ((!strcmp(argv[i], "-nonull")) || - (!strcmp(argv[i], "--nonull"))) - nonull++; - } - if (noent != 0) xmlSubstituteEntitiesDefault(1); - for (i = 1; i < argc ; i++) { - if (argv[i][0] != '-') { - if (timing) { - startTimer(); - } - parseAndPrintFile(argv[i]); - if (timing) { - endTimer("Parsing"); - } - files ++; - } - } - xmlCleanupParser(); - xmlMemoryDump(); - - return(0); -} -#else -int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { - printf("%s : SAX1 parsing support not compiled in\n", argv[0]); - return(0); -} -#endif /* LIBXML_SAX1_ENABLED */ diff --git a/testSchemas.c b/testSchemas.c deleted file mode 100644 index a8d2d1d5..00000000 --- a/testSchemas.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * testSchemas.c : a small tester program for Schema validation - * - * See Copyright for the status of this software. - * - * Daniel.Veillard@w3.org - */ - -#include "libxml.h" -#ifdef LIBXML_SCHEMAS_ENABLED - -#include <libxml/xmlversion.h> -#include <libxml/parser.h> - -#include <stdio.h> -#include <string.h> -#include <stdarg.h> -#include <stdlib.h> - -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -/* seems needed for Solaris */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *) -1) -#endif -#endif - -#include <libxml/xmlmemory.h> -#include <libxml/debugXML.h> -#include <libxml/xmlschemas.h> -#include <libxml/xmlschemastypes.h> - -#ifdef LIBXML_DEBUG_ENABLED -static int debug = 0; -#endif -static int noout = 0; -#ifdef HAVE_MMAP -static int memory = 0; -#endif - - -int main(int argc, char **argv) { - int i; - int files = 0; - xmlSchemaPtr schema = NULL; - - for (i = 1; i < argc ; i++) { -#ifdef LIBXML_DEBUG_ENABLED - if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) - debug++; - else -#endif -#ifdef HAVE_MMAP - if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) { - memory++; - } else -#endif - if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) { - noout++; - } - } - xmlLineNumbersDefault(1); - for (i = 1; i < argc ; i++) { - if (argv[i][0] != '-') { - if (schema == NULL) { - xmlSchemaParserCtxtPtr ctxt; - -#ifdef HAVE_MMAP - if (memory) { - int fd; - struct stat info; - const char *base; - if (stat(argv[i], &info) < 0) - break; - if ((fd = open(argv[i], O_RDONLY)) < 0) - break; - base = mmap(NULL, info.st_size, PROT_READ, - MAP_SHARED, fd, 0) ; - if (base == (void *) MAP_FAILED) - break; - - ctxt = xmlSchemaNewMemParserCtxt((char *)base,info.st_size); - - xmlSchemaSetParserErrors(ctxt, - xmlGenericError, xmlGenericError, NULL); - schema = xmlSchemaParse(ctxt); - xmlSchemaFreeParserCtxt(ctxt); - munmap((char *) base, info.st_size); - } else -#endif - { - ctxt = xmlSchemaNewParserCtxt(argv[i]); - xmlSchemaSetParserErrors(ctxt, - xmlGenericError, xmlGenericError, NULL); - schema = xmlSchemaParse(ctxt); - xmlSchemaFreeParserCtxt(ctxt); - } -#ifdef LIBXML_OUTPUT_ENABLED -#ifdef LIBXML_DEBUG_ENABLED - if (debug) - xmlSchemaDump(stdout, schema); -#endif -#endif /* LIBXML_OUTPUT_ENABLED */ - if (schema == NULL) - goto failed_schemas; - } else { - xmlDocPtr doc; - - doc = xmlReadFile(argv[i],NULL,0); - - if (doc == NULL) { - fprintf(stderr, "Could not parse %s\n", argv[i]); - } else { - xmlSchemaValidCtxtPtr ctxt; - int ret; - - ctxt = xmlSchemaNewValidCtxt(schema); - xmlSchemaSetValidErrors(ctxt, - xmlGenericError, xmlGenericError, NULL); - ret = xmlSchemaValidateDoc(ctxt, doc); - if (ret == 0) { - printf("%s validates\n", argv[i]); - } else if (ret > 0) { - printf("%s fails to validate\n", argv[i]); - } else { - printf("%s validation generated an internal error\n", - argv[i]); - } - xmlSchemaFreeValidCtxt(ctxt); - xmlFreeDoc(doc); - } - } - files ++; - } - } - if (schema != NULL) - xmlSchemaFree(schema); - if (files == 0) { - printf("Usage : %s [--debug] [--noout] schemas XMLfiles ...\n", - argv[0]); - printf("\tParse the HTML files and output the result of the parsing\n"); -#ifdef LIBXML_DEBUG_ENABLED - printf("\t--debug : dump a debug tree of the in-memory document\n"); -#endif - printf("\t--noout : do not print the result\n"); -#ifdef HAVE_MMAP - printf("\t--memory : test the schemas in memory parsing\n"); -#endif - } -failed_schemas: - xmlCleanupParser(); - xmlMemoryDump(); - - return(0); -} - -#else -#include <stdio.h> -int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { - printf("%s : Schemas support not compiled in\n", argv[0]); - return(0); -} -#endif /* LIBXML_SCHEMAS_ENABLED */ diff --git a/testURI.c b/testURI.c deleted file mode 100644 index 0043b203..00000000 --- a/testURI.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * testURI.c : a small tester program for XML input. - * - * See Copyright for the status of this software. - * - * daniel@veillard.com - */ - -#include "libxml.h" - -#include <string.h> -#include <stdio.h> -#include <stdarg.h> - -#include <libxml/xmlmemory.h> -#include <libxml/uri.h> -#include <libxml/globals.h> - -static const char *base = NULL; -static int escape = 0; -static int debug = 0; -static int relative = 0; - -static void handleURI(const char *str) { - int ret; - xmlURIPtr uri; - xmlChar *res = NULL, *parsed = NULL; - - uri = xmlCreateURI(); - - if (base == NULL) { - ret = xmlParseURIReference(uri, str); - if (ret != 0) - printf("%s : error %d\n", str, ret); - else { - if (debug) { - if (uri->scheme) printf("scheme: %s\n", uri->scheme); - if (uri->opaque) printf("opaque: %s\n", uri->opaque); - if (uri->authority) printf("authority: %s\n", uri->authority); - if (uri->server) printf("server: %s\n", uri->server); - if (uri->user) printf("user: %s\n", uri->user); - if (uri->port != 0) printf("port: %d\n", uri->port); - if (uri->path) printf("path: %s\n", uri->path); - if (uri->query) printf("query: %s\n", uri->query); - if (uri->fragment) printf("fragment: %s\n", uri->fragment); - if (uri->query_raw) printf("query_raw: %s\n", uri->query_raw); - if (uri->cleanup != 0) printf("cleanup\n"); - } - xmlNormalizeURIPath(uri->path); - if (escape != 0) { - parsed = xmlSaveUri(uri); - res = xmlURIEscape(parsed); - printf("%s\n", (char *) res); - - } else { - xmlPrintURI(stdout, uri); - printf("\n"); - } - } - } else { - if (relative) { - res = xmlBuildRelativeURI((xmlChar *)str, (xmlChar *) base); - } else { - res = xmlBuildURI((xmlChar *)str, (xmlChar *) base); - } - - if (res != NULL) { - printf("%s\n", (char *) res); - } - else - printf("::ERROR::\n"); - } - if (res != NULL) - xmlFree(res); - if (parsed != NULL) - xmlFree(parsed); - xmlFreeURI(uri); -} - -int main(int argc, char **argv) { - int i, arg = 1; - - if ((argc > arg) && (argv[arg] != NULL) && - (!strcmp(argv[arg], "--relative"))) { - arg++; - relative++; - } - if ((argc > arg) && (argv[arg] != NULL) && - ((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) { - arg++; - base = argv[arg]; - if (base != NULL) - arg++; - } - if ((argc > arg) && (argv[arg] != NULL) && - ((!strcmp(argv[arg], "-escape")) || (!strcmp(argv[arg], "--escape")))) { - arg++; - escape++; - } - if ((argc > arg) && (argv[arg] != NULL) && - ((!strcmp(argv[arg], "-debug")) || (!strcmp(argv[arg], "--debug")))) { - arg++; - debug++; - } - if (argv[arg] == NULL) { - char str[1024]; - - while (1) { - /* - * read one line in string buffer. - */ - if (fgets (&str[0], sizeof (str) - 1, stdin) == NULL) - break; - - /* - * remove the ending spaces - */ - i = strlen(str); - while ((i > 0) && - ((str[i - 1] == '\n') || (str[i - 1] == '\r') || - (str[i - 1] == ' ') || (str[i - 1] == '\t'))) { - i--; - str[i] = 0; - } - handleURI(str); - } - } else { - while (argv[arg] != NULL) { - handleURI(argv[arg]); - arg++; - } - } - xmlMemoryDump(); - return(0); -} diff --git a/testXPath.c b/testXPath.c deleted file mode 100644 index 4e2cf2ad..00000000 --- a/testXPath.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * testXPath.c : a small tester program for XPath. - * - * See Copyright for the status of this software. - * - * daniel@veillard.com - */ - -#include "libxml.h" -#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED) - -#include <string.h> -#include <stdlib.h> - -#include <libxml/xpath.h> -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/debugXML.h> -#include <libxml/xmlmemory.h> -#include <libxml/parserInternals.h> -#include <libxml/xpathInternals.h> -#include <libxml/xmlerror.h> -#include <libxml/globals.h> -#if defined(LIBXML_XPTR_ENABLED) -#include <libxml/xpointer.h> -static int xptr = 0; -#endif -static int debug = 0; -static int valid = 0; -static int expr = 0; -static int tree = 0; -static int nocdata = 0; -static xmlDocPtr document = NULL; - -/* - * Default document - */ -static xmlChar buffer[] = -"<?xml version=\"1.0\"?>\n\ -<EXAMPLE prop1=\"gnome is great\" prop2=\"& linux too\">\n\ - <head>\n\ - <title>Welcome to Gnome</title>\n\ - </head>\n\ - <chapter>\n\ - <title>The Linux adventure</title>\n\ - <p>bla bla bla ...</p>\n\ - <image href=\"linus.gif\"/>\n\ - <p>...</p>\n\ - </chapter>\n\ - <chapter>\n\ - <title>Chapter 2</title>\n\ - <p>this is chapter 2 ...</p>\n\ - </chapter>\n\ - <chapter>\n\ - <title>Chapter 3</title>\n\ - <p>this is chapter 3 ...</p>\n\ - </chapter>\n\ -</EXAMPLE>\n\ -"; - - -static void -testXPath(const char *str) { - xmlXPathObjectPtr res; - xmlXPathContextPtr ctxt; - -#if defined(LIBXML_XPTR_ENABLED) - if (xptr) { - ctxt = xmlXPtrNewContext(document, NULL, NULL); - res = xmlXPtrEval(BAD_CAST str, ctxt); - } else { -#endif - ctxt = xmlXPathNewContext(document); - ctxt->node = xmlDocGetRootElement(document); - if (expr) - res = xmlXPathEvalExpression(BAD_CAST str, ctxt); - else { - /* res = xmlXPathEval(BAD_CAST str, ctxt); */ - xmlXPathCompExprPtr comp; - - comp = xmlXPathCompile(BAD_CAST str); - if (comp != NULL) { - if (tree) - xmlXPathDebugDumpCompExpr(stdout, comp, 0); - - res = xmlXPathCompiledEval(comp, ctxt); - xmlXPathFreeCompExpr(comp); - } else - res = NULL; - } -#if defined(LIBXML_XPTR_ENABLED) - } -#endif - xmlXPathDebugDumpObject(stdout, res, 0); - xmlXPathFreeObject(res); - xmlXPathFreeContext(ctxt); -} - -static void -testXPathFile(const char *filename) { - FILE *input; - char expression[5000]; - int len; - - input = fopen(filename, "rb"); - if (input == NULL) { - xmlGenericError(xmlGenericErrorContext, - "Cannot open %s for reading\n", filename); - return; - } - while (fgets(expression, 4500, input) != NULL) { - len = strlen(expression); - len--; - while ((len >= 0) && - ((expression[len] == '\n') || (expression[len] == '\t') || - (expression[len] == '\r') || (expression[len] == ' '))) len--; - expression[len + 1] = 0; - if (len >= 0) { - printf("\n========================\nExpression: %s\n", expression) ; - testXPath(expression); - } - } - - fclose(input); -} - -int main(int argc, char **argv) { - int i; - int strings = 0; - int usefile = 0; - char *filename = NULL; - - xmlInitParser(); - - for (i = 1; i < argc ; i++) { -#if defined(LIBXML_XPTR_ENABLED) - if ((!strcmp(argv[i], "-xptr")) || (!strcmp(argv[i], "--xptr"))) - xptr++; - else -#endif - if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) - debug++; - else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid"))) - valid++; - else if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr"))) - expr++; - else if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree"))) - tree++; - else if ((!strcmp(argv[i], "-nocdata")) || - (!strcmp(argv[i], "--nocdata"))) - nocdata++; - else if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input"))) - filename = argv[++i]; - else if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file"))) - usefile++; - } - if (valid != 0) xmlDoValidityCheckingDefaultValue = 1; - xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS; - xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS; - xmlSubstituteEntitiesDefaultValue = 1; -#ifdef LIBXML_SAX1_ENABLED - if (nocdata != 0) { - xmlDefaultSAXHandler.cdataBlock = NULL; - } -#endif - if (document == NULL) { - if (filename == NULL) - document = xmlReadDoc(buffer,NULL,NULL,XML_PARSE_COMPACT); - else - document = xmlReadFile(filename,NULL,XML_PARSE_COMPACT); - } - for (i = 1; i < argc ; i++) { - if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input"))) { - i++; continue; - } - if (argv[i][0] != '-') { - if (usefile) - testXPathFile(argv[i]); - else - testXPath(argv[i]); - strings ++; - } - } - if (strings == 0) { - printf("Usage : %s [--debug] [--copy] stringsorfiles ...\n", - argv[0]); - printf("\tParse the XPath strings and output the result of the parsing\n"); - printf("\t--debug : dump a debug version of the result\n"); - printf("\t--valid : switch on DTD support in the parser\n"); -#if defined(LIBXML_XPTR_ENABLED) - printf("\t--xptr : expressions are XPointer expressions\n"); -#endif - printf("\t--expr : debug XPath expressions only\n"); - printf("\t--tree : show the compiled XPath tree\n"); - printf("\t--nocdata : do not generate CDATA nodes\n"); - printf("\t--input filename : or\n"); - printf("\t-i filename : read the document from filename\n"); - printf("\t--file : or\n"); - printf("\t-f : read queries from files, args\n"); - } - if (document != NULL) - xmlFreeDoc(document); - xmlCleanupParser(); - xmlMemoryDump(); - - return(0); -} -#else -#include <stdio.h> -int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { - printf("%s : XPath/Debug support not compiled in\n", argv[0]); - return(0); -} -#endif /* LIBXML_XPATH_ENABLED */ diff --git a/vms/build_libxml.com b/vms/build_libxml.com index 1f7936e5..2db561f3 100755 --- a/vms/build_libxml.com +++ b/vms/build_libxml.com @@ -64,8 +64,7 @@ $! $!- list of test modules to compile and link. Compare this list to the $! definition of check_PROGRAMS in MAKEFILE. $! -$ check_PROGRAMS = "testSchemas testRelax testSAX testHTML testXPath testURI " - - + "testThreads testC14N testAutomata testRegexp testReader" +$ check_PROGRAMS = "testThreads testAutomata testRegexp" $! $!- set up build logicals -----------------------------------------------------\ $! diff --git a/win32/Makefile.bcb b/win32/Makefile.bcb index 6adc245e..0fe8eae0 100644 --- a/win32/Makefile.bcb +++ b/win32/Makefile.bcb @@ -206,16 +206,8 @@ XML_OBJS_A = $(XML_INTDIR_A)\buf.obj\ UTILS = $(BINDIR)\xmllint.exe\ $(BINDIR)\xmlcatalog.exe\ $(BINDIR)\testAutomata.exe\ - $(BINDIR)\testC14N.exe\ - $(BINDIR)\testHTML.exe\ - $(BINDIR)\testReader.exe\ - $(BINDIR)\testRelax.exe\ $(BINDIR)\testRegexp.exe\ $(BINDIR)\testModule.exe\ - $(BINDIR)\testSAX.exe\ - $(BINDIR)\testSchemas.exe\ - $(BINDIR)\testURI.exe\ - $(BINDIR)\testXPath.exe\ $(BINDIR)\runtest.exe\ $(BINDIR)\runsuite.exe\ $(BINDIR)\testapi.exe\ diff --git a/win32/Makefile.mingw b/win32/Makefile.mingw index a4452ffb..3f6069b8 100644 --- a/win32/Makefile.mingw +++ b/win32/Makefile.mingw @@ -202,16 +202,8 @@ XML_SRCS_A = $(subst .o,.c,$(subst $(XML_INTDIR_A)/,$(XML_SRCDIR)/,$(XML_OBJS_A) UTILS = $(BINDIR)/xmllint.exe\ $(BINDIR)/xmlcatalog.exe\ $(BINDIR)/testAutomata.exe\ - $(BINDIR)/testC14N.exe\ - $(BINDIR)/testHTML.exe\ - $(BINDIR)/testReader.exe\ $(BINDIR)/testRegexp.exe\ $(BINDIR)/testModule.exe\ - $(BINDIR)/testRelax.exe\ - $(BINDIR)/testSAX.exe\ - $(BINDIR)/testSchemas.exe\ - $(BINDIR)/testURI.exe\ - $(BINDIR)/testXPath.exe\ $(BINDIR)/runtest.exe\ $(BINDIR)/runsuite.exe\ $(BINDIR)/testapi.exe\ diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc index 5d3b4e1b..233251c2 100644 --- a/win32/Makefile.msvc +++ b/win32/Makefile.msvc @@ -256,16 +256,8 @@ XML_OBJS_A_DLL = $(XML_OBJS_A_DLL) $(XML_INTDIR_A_DLL)\xzlib.obj UTILS = $(BINDIR)\xmllint.exe\ $(BINDIR)\xmlcatalog.exe\ $(BINDIR)\testAutomata.exe\ - $(BINDIR)\testC14N.exe\ - $(BINDIR)\testHTML.exe\ - $(BINDIR)\testReader.exe\ - $(BINDIR)\testRelax.exe\ $(BINDIR)\testRegexp.exe\ $(BINDIR)\testModule.exe\ - $(BINDIR)\testSAX.exe\ - $(BINDIR)\testSchemas.exe\ - $(BINDIR)\testURI.exe\ - $(BINDIR)\testXPath.exe\ $(BINDIR)\runtest.exe\ $(BINDIR)\runsuite.exe\ $(BINDIR)\runxmlconf.exe\ @@ -436,63 +428,3 @@ checktests : $(UTILS) cd .. && win32\$(BINDIR)\testdict.exe cd .. && win32\$(BINDIR)\runxmlconf.exe -XPathtests : $(BINDIR)\testXPath.exe - @echo. 2> .memdump - @echo ## XPath regression tests - @-$(BINDIR)\testXPath.exe | find /C "support not compiled in" 1>nul - @if %ERRORLEVEL% NEQ 0 @( \ - echo Skipping debug not compiled in\ - @exit 0 \ - ) - @for %%I in ($(XML_SRCDIR)\test\XPath\expr\*.*) do @( \ - @IF NOT EXIST $(XML_SRCDIR)\result\XPath\expr\%%~nxI ( \ - @echo New test %%~nxI &&\ - @echo %%~nxI &&\ - $(BINDIR)\testXPath.exe -f --expr %%I > $(XML_SRCDIR)/result/XPath/expr/%%~nxI &&\ - findstr /C:"MEMORY ALLOCATED : 0" \ - ) ELSE ( \ - $(BINDIR)\testXPath.exe -f --expr %%I 2>&1 > result.%%~nxI &&\ - fc $(XML_SRCDIR)\result\XPath\expr\%%~nxI result.%%~nxI >nul &\ - iF ERRORLEVEL 1 exit 1 & \ - findstr "MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" >nul &&\ - del result.%%~nxI \ - ) \ - ) - @for %%I in ($(XML_SRCDIR)\test\XPath\docs\*.*) do @( \ - for %%J in ($(XML_SRCDIR)\test\XPath\tests\%%~nxI*.*) do @( \ - if not exist $(XML_SRCDIR)\result\XPath\tests\%%~nxJ ( \ - $(BINDIR)\testXPath.exe -f -i %%I %%J > $(XML_SRCDIR)\result\XPath\tests\%%~nxJ &&\ - findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > nul \ - ) ELSE ( \ - $(BINDIR)\testXPAth.exe -f -i %%I %%J 2>&1 > result.%%~nxJ &&\ - findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0">null &&\ - fc $(XML_SRCDIR)\result\XPath\tests\%%~nxJ result.%%~nxJ >null & \ - IF ERRORLEVEL 1 (echo Error: %%I %%J & exit 1) & \ - del result.%%~nxJ \ - )\ - )\ - ) - -XMLtests : $(BINDIR)\xmllint.exe - @echo. 2> .memdump - @echo ## XML regression tests - -@for %%I in ($(XML_SRCDIR)\test\*) do @( \ - if not exist $(XML_SRCDIR)\result\%%~nxI ( \ - echo New test file %%~nxI &\ - $(BINDIR)\xmllint.exe %%I > $(XML_SRCDIR)\result\%%~nxI && \ - findstr /C:"MEMORY ALLOCATED" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > null \ - ) ELSE ( \ - $(BINDIR)\xmllint.exe %%I 2>&1 > result.%%~nxI && \ - findstr /C:"MEMORY ALLOC" .memdump | findstr /C:"MEMORY ALLOCATED : 0" > null && \ - fc $(XML_SRCDIR)\result\%%~nxI result.%%~nxI > null && \ - $(BINDIR)\xmllint.exe result.%%~nxI 2>&1 > result2.%%~nxI | findstr /V /C:"failed to load external entity" && \ - fc result.%%~nxI result2.%%~nxI & \ - del result.%%~nxI result2.%%~nxI\ - ) \ - ) - - - - - - |