[libxslt] tests: Port most of the test suite to C



commit 971d5c4dd158095194759a9c7173d47c90645444
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Wed Sep 7 16:43:06 2022 +0200

    tests: Port most of the test suite to C
    
    Use runtest.c from libxml2 as a starting point.
    
    This finally allows us to run most of tests with CMake and Autotools
    VPATH builds.

 .gitignore                                        |   1 +
 .gitlab-ci/test.sh                                |   5 +-
 .gitlab-ci/test_cmake.sh                          |   4 +-
 CMakeLists.txt                                    |  34 +-
 Makefile.am                                       |  18 -
 configure.ac                                      |  22 -
 libxslt.spec.in                                   |   2 +-
 python/tests/Makefile.am                          |   4 +-
 tests/Makefile.am                                 |  59 +-
 tests/REC/Makefile.am                             | 219 ------
 tests/REC/test-6.1.out                            |   0
 tests/REC1/Makefile.am                            |  23 -
 tests/REC2/Makefile.am                            |  30 -
 tests/REC2/data.xml                               |  21 -
 tests/REC2/html.out                               |  32 +
 tests/REC2/html.xml                               |  53 +-
 tests/REC2/svg.out                                |  18 +
 tests/REC2/svg.xml                                |  39 +-
 tests/REC2/vrml.out                               |  38 +
 tests/REC2/vrml.xml                               |  59 +-
 tests/XSLTMark/Makefile.am                        |   8 +-
 tests/docbook/Makefile.am                         |   6 +-
 tests/docs/Makefile.am                            | 228 ------
 tests/documents/Makefile.am                       |  42 --
 tests/documents/{result.xhtml => bredfort.out}    |   0
 tests/documents/{index.xml => bredfort.xml}       |   0
 tests/documents/{fragment.result => fragment.out} |   0
 tests/documents/{message.result => message.err}   |   0
 tests/documents/{test.result => test.out}         |   0
 tests/documents/test_bad.err                      |   4 +-
 tests/documents/{test_bad.result => test_bad.out} |   0
 tests/documents/test_bad.xsl                      |  16 +
 tests/exslt/Makefile.am                           |  12 -
 tests/exslt/common/Makefile.am                    |  56 --
 tests/exslt/crypto/Makefile.am                    |  47 --
 tests/exslt/date/Makefile.am                      |  86 ---
 tests/exslt/date/sum.2.err                        |   0
 tests/exslt/dynamic/Makefile.am                   |  52 --
 tests/exslt/functions/Makefile.am                 |  56 --
 tests/exslt/math/Makefile.am                      |  57 --
 tests/exslt/saxon/Makefile.am                     |  45 --
 tests/exslt/saxon/eval.2.out                      |   0
 tests/exslt/saxon/eval.3.out                      |   0
 tests/exslt/sets/Makefile.am                      |  50 --
 tests/exslt/strings/Makefile.am                   |  53 --
 tests/extensions/Makefile.am                      |  51 --
 tests/fuzz/Makefile.am                            |   6 +-
 tests/general/Makefile.am                         | 310 --------
 tests/{docs => general}/array.xml                 |   0
 tests/{docs => general}/bug-1-.xml                |   0
 tests/{docs => general}/bug-10-.xml               |   0
 tests/{docs => general}/bug-100.xml               |   0
 tests/{docs => general}/bug-101.xml               |   0
 tests/{docs => general}/bug-102.xml               |   0
 tests/{docs => general}/bug-103.xml               |   0
 tests/{docs => general}/bug-104.xml               |   0
 tests/{docs => general}/bug-105.xml               |   0
 tests/{docs => general}/bug-106.xml               |   0
 tests/{docs => general}/bug-107.xml               |   0
 tests/{docs => general}/bug-108.xml               |   0
 tests/{docs => general}/bug-109.xml               |   0
 tests/{docs => general}/bug-11-.xml               |   0
 tests/{docs => general}/bug-110.ent               |   0
 tests/general/bug-110.err                         |   0
 tests/{docs => general}/bug-110.xml               |   0
 tests/{docs => general}/bug-111.xml               |   0
 tests/{docs => general}/bug-112.xml               |   0
 tests/{docs => general}/bug-113.xml               |   0
 tests/{docs => general}/bug-114.xml               |   0
 tests/{docs => general}/bug-115.xml               |   0
 tests/{docs => general}/bug-116.xml               |   0
 tests/{docs => general}/bug-117.xml               |   0
 tests/{docs => general}/bug-118.xml               |   0
 tests/{docs => general}/bug-119.xml               |   0
 tests/{docs => general}/bug-12-.xml               |   0
 tests/{docs => general}/bug-120.xml               |   0
 tests/{docs => general}/bug-121.xml               |   0
 tests/{docs => general}/bug-122.xml               |   0
 tests/{docs => general}/bug-123.xml               |   0
 tests/{docs => general}/bug-124.xml               |   0
 tests/{docs => general}/bug-125.xml               |   0
 tests/{docs => general}/bug-126.xml               |   0
 tests/{docs => general}/bug-127.xml               |   0
 tests/{docs => general}/bug-128.xml               |   0
 tests/{docs => general}/bug-129.xml               |   0
 tests/{docs => general}/bug-13-.xml               |   0
 tests/{docs => general}/bug-130.doc               |   0
 tests/{docs => general}/bug-130.xml               |   0
 tests/general/bug-130.xsl                         |   2 +-
 tests/{docs => general}/bug-131.xml               |   0
 tests/{docs => general}/bug-132.xml               |   0
 tests/{docs => general}/bug-133.xml               |   0
 tests/{docs => general}/bug-134.xml               |   0
 tests/{docs => general}/bug-135.xml               |   0
 tests/{docs => general}/bug-136.xml               |   0
 tests/{docs => general}/bug-137.xml               |   0
 tests/{docs => general}/bug-138.xml               |   0
 tests/{docs => general}/bug-139.xml               |   0
 tests/{docs => general}/bug-14-.xml               |   0
 tests/{docs => general}/bug-140.xml               |   0
 tests/{docs => general}/bug-141.xml               |   0
 tests/{docs => general}/bug-142.xml               |   0
 tests/{docs => general}/bug-143.xml               |   0
 tests/{docs => general}/bug-144.xml               |   0
 tests/general/bug-145.err                         |   2 +-
 tests/general/bug-145.out                         |   0
 tests/{docs => general}/bug-145.xml               |   0
 tests/{docs => general}/bug-146.xml               |   0
 tests/{docs => general}/bug-147.xml               |   0
 tests/{docs => general}/bug-148.xml               |   0
 tests/{docs => general}/bug-149.xml               |   0
 tests/{docs => general}/bug-15-.xml               |   0
 tests/{docs => general}/bug-150.xml               |   0
 tests/general/bug-151.out                         |   0
 tests/{docs => general}/bug-151.xml               |   0
 tests/{docs => general}/bug-152.xml               |   0
 tests/{docs => general}/bug-153.doc               |   0
 tests/{docs => general}/bug-153.xml               |   0
 tests/general/bug-153.xsl                         |   2 +-
 tests/general/bug-154.out                         |   0
 tests/{docs => general}/bug-154.xml               |   0
 tests/{docs => general}/bug-155.xml               |   0
 tests/general/bug-156.out                         |   0
 tests/{docs => general}/bug-156.xml               |   0
 tests/{docs => general}/bug-157.xml               |   0
 tests/{docs => general}/bug-158.doc               |   0
 tests/{docs => general}/bug-158.xml               |   0
 tests/general/bug-158.xsl                         |   2 +-
 tests/{docs => general}/bug-159.xml               |   0
 tests/{docs => general}/bug-16-.xml               |   0
 tests/{docs => general}/bug-160.xml               |   0
 tests/{docs => general}/bug-161.xml               |   0
 tests/{docs => general}/bug-163.xml               |   0
 tests/{docs => general}/bug-164.xml               |   0
 tests/general/bug-165.err                         |   2 +-
 tests/general/bug-165.out                         |   0
 tests/{docs => general}/bug-165.xml               |   0
 tests/{docs => general}/bug-166.xml               |   0
 tests/{docs => general}/bug-167.xml               |   0
 tests/{docs => general}/bug-168.xml               |   0
 tests/{docs => general}/bug-169.xml               |   0
 tests/{docs => general}/bug-17-.xml               |   0
 tests/{docs => general}/bug-170.xml               |   0
 tests/{docs => general}/bug-171.xml               |   0
 tests/{docs => general}/bug-172.xml               |   0
 tests/{docs => general}/bug-173.xml               |   0
 tests/general/bug-174.out                         |   0
 tests/{docs => general}/bug-174.xml               |   0
 tests/{docs => general}/bug-175.xml               |   0
 tests/{docs => general}/bug-176.xml               |   0
 tests/{docs => general}/bug-177.xml               |   0
 tests/{docs => general}/bug-178.xml               |   0
 tests/{docs => general}/bug-179.xml               |   0
 tests/{docs => general}/bug-18-.xml               |   0
 tests/general/bug-180.err                         |   2 +-
 tests/general/bug-180.out                         |   0
 tests/{docs => general}/bug-180.xml               |   0
 tests/{docs => general}/bug-181.xml               |   0
 tests/{docs => general}/bug-182.xml               |   0
 tests/{docs => general}/bug-183.xml               |   0
 tests/general/bug-184.err                         |   2 +-
 tests/general/bug-184.out                         |   0
 tests/{docs => general}/bug-184.xml               |   0
 tests/{docs => general}/bug-186.xml               |   0
 tests/{docs => general}/bug-187.xml               |   0
 tests/{docs => general}/bug-188.xml               |   0
 tests/{docs => general}/bug-189.xml               |   0
 tests/{docs => general}/bug-19-.xml               |   0
 tests/{docs => general}/bug-190.xml               |   0
 tests/general/bug-191.out                         |   0
 tests/{docs => general}/bug-191.xml               |   0
 tests/{docs => general}/bug-192.xml               |   0
 tests/{docs => general}/bug-193.xml               |   0
 tests/general/bug-194.err                         |   2 +-
 tests/general/bug-194.out                         |   0
 tests/{docs => general}/bug-194.xml               |   0
 tests/{docs => general}/bug-195.xml               |   0
 tests/{docs => general}/bug-196.xml               |   0
 tests/{docs => general}/bug-197.xml               |   0
 tests/{docs => general}/bug-198.xml               |   0
 tests/{docs => general}/bug-199.xml               |   0
 tests/{docs => general}/bug-2-.xml                |   0
 tests/{docs => general}/bug-20-.xml               |   0
 tests/{docs => general}/bug-200.xml               |   0
 tests/general/bug-201.err                         |   2 +-
 tests/general/bug-201.out                         |   0
 tests/{docs => general}/bug-201.xml               |   0
 tests/general/bug-202.out                         |   0
 tests/{docs => general}/bug-202.xml               |   0
 tests/general/bug-203.out                         |   0
 tests/{docs => general}/bug-203.xml               |   0
 tests/general/bug-204.out                         |   0
 tests/{docs => general}/bug-204.xml               |   0
 tests/{docs => general}/bug-205.xml               |   0
 tests/{docs => general}/bug-206.xml               |   0
 tests/{docs => general}/bug-207.xml               |   0
 tests/general/bug-208.err                         |   2 +-
 tests/general/bug-208.out                         |   0
 tests/{docs => general}/bug-208.xml               |   0
 tests/{docs => general}/bug-209.xml               |   0
 tests/general/bug-21-.out                         |   2 +-
 tests/{docs => general}/bug-21-.xml               |   0
 tests/{docs => general}/bug-210.xml               |   0
 tests/{docs => general}/bug-211.xml               |   0
 tests/{docs => general}/bug-212.xml               |   0
 tests/{docs => general}/bug-213.xml               |   0
 tests/{docs => general}/bug-214.xml               |   0
 tests/general/bug-215.err                         |   2 +-
 tests/general/bug-215.out                         |   0
 tests/{docs => general}/bug-215.xml               |   0
 tests/{docs => general}/bug-216.xml               |   0
 tests/{docs => general}/bug-217.xml               |   0
 tests/{docs => general}/bug-218.xml               |   0
 tests/{docs => general}/bug-219.xml               |   0
 tests/{docs => general}/bug-22-.xml               |   0
 tests/{docs => general}/bug-220.xml               |   0
 tests/{docs => general}/bug-221.xml               |   0
 tests/{docs => general}/bug-222.xml               |   0
 tests/{docs => general}/bug-23-.xml               |   0
 tests/{docs => general}/bug-24-.xml               |   0
 tests/{docs => general}/bug-25-.xml               |   0
 tests/{docs => general}/bug-26-.xml               |   0
 tests/{docs => general}/bug-27-.xml               |   0
 tests/{docs => general}/bug-28-.xml               |   0
 tests/{docs => general}/bug-29-.ent               |   0
 tests/{docs => general}/bug-29-.xml               |   0
 tests/{docs => general}/bug-3-.xml                |   0
 tests/{docs => general}/bug-30-.xml               |   0
 tests/{docs => general}/bug-31-.xml               |   0
 tests/{docs => general}/bug-32-.xml               |   0
 tests/{docs => general}/bug-33-.xml               |   0
 tests/{docs => general}/bug-35-.xml               |   0
 tests/{docs => general}/bug-36-.xml               |   0
 tests/{docs => general}/bug-37-.xml               |   0
 tests/{docs => general}/bug-38-.xml               |   0
 tests/{docs => general}/bug-39-.xml               |   0
 tests/{docs => general}/bug-4-.xml                |   0
 tests/{docs => general}/bug-40-.xml               |   0
 tests/{docs => general}/bug-41-.xml               |   0
 tests/{docs => general}/bug-42-.xml               |   0
 tests/{docs => general}/bug-43-.xml               |   0
 tests/{docs => general}/bug-44-.xml               |   0
 tests/{docs => general}/bug-45-.xml               |   0
 tests/{docs => general}/bug-46-.xml               |   0
 tests/{docs => general}/bug-47-.xml               |   0
 tests/{docs => general}/bug-48-.xml               |   0
 tests/{docs => general}/bug-49-.xml               |   0
 tests/{docs => general}/bug-5-.xml                |   0
 tests/{docs => general}/bug-50-.xml               |   0
 tests/general/bug-52.out                          |   2 +-
 tests/{docs => general}/bug-52.xml                |   0
 tests/{docs => general}/bug-53.xml                |   0
 tests/{docs => general}/bug-54.xml                |   0
 tests/{docs => general}/bug-55.xml                |   0
 tests/{docs => general}/bug-56.xml                |   0
 tests/{docs => general}/bug-57.xml                |   0
 tests/{docs => general}/bug-59.xml                |   0
 tests/{docs => general}/bug-6-.xml                |   0
 tests/{docs => general}/bug-60.xml                |   0
 tests/{docs => general}/bug-61.xml                |   0
 tests/{docs => general}/bug-62.xml                |   0
 tests/{docs => general}/bug-63.xml                |   0
 tests/{docs => general}/bug-64.xml                |   0
 tests/{docs => general}/bug-65.xml                |   0
 tests/{docs => general}/bug-66.xml                |   0
 tests/{docs => general}/bug-68.xml                |   0
 tests/{docs => general}/bug-69.xml                |   0
 tests/{docs => general}/bug-7-.xml                |   0
 tests/{docs => general}/bug-70.xml                |   0
 tests/{docs => general}/bug-71.xml                |   0
 tests/{docs => general}/bug-72.xml                |   0
 tests/{docs => general}/bug-73.xml                |   0
 tests/{docs => general}/bug-74.xml                |   0
 tests/{docs => general}/bug-75.xml                |   0
 tests/{docs => general}/bug-76.xml                |   0
 tests/{docs => general}/bug-77.xml                |   0
 tests/{docs => general}/bug-78.xml                |   0
 tests/{docs => general}/bug-79.xml                |   0
 tests/{docs => general}/bug-8-.xml                |   0
 tests/{docs => general}/bug-80.xml                |   0
 tests/{docs => general}/bug-81.xml                |   0
 tests/{docs => general}/bug-82.xml                |   0
 tests/{docs => general}/bug-83.xml                |   0
 tests/{docs => general}/bug-84.xml                |   0
 tests/{docs => general}/bug-86.xml                |   0
 tests/{docs => general}/bug-87.xml                |   0
 tests/{docs => general}/bug-88.xml                |   0
 tests/{docs => general}/bug-89.xml                |   0
 tests/{docs => general}/bug-9-.xml                |   0
 tests/{docs => general}/bug-90.xml                |   0
 tests/{docs => general}/bug-91.xml                |   0
 tests/{docs => general}/bug-92.xml                |   0
 tests/{docs => general}/bug-93.xml                |   0
 tests/{docs => general}/bug-94.xml                |   0
 tests/{docs => general}/bug-95.xml                |   0
 tests/{docs => general}/bug-96.xml                |   0
 tests/{docs => general}/bug-97.xml                |   0
 tests/{docs => general}/bug-98.xml                |   0
 tests/{docs => general}/bug-99.xml                |   0
 tests/{docs => general}/character.xml             |   0
 tests/{docs => general}/date_add.xml              |   0
 tests/{REC1 => general}/doc.dtd                   |   0
 tests/{REC1/result.xml => general/doc.out}        |   0
 tests/{REC1 => general}/doc.xml                   |   0
 tests/{REC1 => general}/doc.xsl                   |   0
 tests/{docs => general}/items.xml                 |   0
 tests/keys/Makefile.am                            |  23 -
 tests/keys/{month.out => dates.out}               |   0
 tests/keys/{month.xsl => dates.xsl}               |   0
 tests/multiple/Makefile.am                        |   6 +-
 tests/namespaces/Makefile.am                      |  59 --
 tests/namespaces/extra2.out                       |   0
 tests/numbers/Makefile.am                         |  21 -
 tests/plugins/Makefile.am                         |  43 --
 tests/reports/Makefile.am                         |  57 --
 tests/reports/recglobparam.out                    |   0
 tests/reports/recglobvar.out                      |   0
 tests/reports/reclocparam.out                     |   0
 tests/reports/reclocvar.out                       |   0
 tests/reports/tst-1.out                           |   0
 tests/reports/tst-2.out                           |   0
 tests/reports/undefvar.out                        |   0
 tests/runtest.c                                   | 866 ++++++++++++++++++++++
 tests/{plugins => }/testplugin.c                  |   0
 tests/xinclude/Makefile.am                        |   6 +-
 tests/xmlspec/Makefile.am                         |   6 +-
 xsltproc/Makefile.am                              |   5 +-
 327 files changed, 1141 insertions(+), 1843 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index eb199be3..91aefd68 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,6 +48,7 @@ python/libxsltclass.py
 python/libxsltclass.txt
 python/tests/foo
 stamp-h1
+tests/runtest
 tests/xmlspec/debug
 xslt-config
 xsltConf.sh
diff --git a/.gitlab-ci/test.sh b/.gitlab-ci/test.sh
index fcef8704..6028250f 100644
--- a/.gitlab-ci/test.sh
+++ b/.gitlab-ci/test.sh
@@ -10,7 +10,4 @@ cd ..
 
 sh autogen.sh $CONFIG --with-libxml-src=libxml2
 make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror"
-make -s -C tests tests | tee test.log
-make -s -C xsltproc tests | tee -a test.log
-grep -qv '^## Running' test.log && exit 1
-make -s -C python tests
+make -s check
diff --git a/.gitlab-ci/test_cmake.sh b/.gitlab-ci/test_cmake.sh
index c17ef489..83b13f78 100644
--- a/.gitlab-ci/test_cmake.sh
+++ b/.gitlab-ci/test_cmake.sh
@@ -21,8 +21,10 @@ cmake "$@" \
     -DCMAKE_C_FLAGS='-Werror' \
     -S . -B libxslt-build
 cmake --build libxslt-build --target install
+
+(cd libxslt-build && ctest -VV)
+
 mkdir -p libxslt-install/share/libxslt
 cp Copyright libxslt-install/share/libxslt
-
 (cd libxslt-install &&
     tar -czf ../libxslt-$CI_COMMIT_SHORT_SHA-$SUFFIX.tar.gz *)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a0ee9e4..e6272d1c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,10 @@ option(LIBXSLT_WITH_THREADS "Add multithread support" ON)
 set(LIBXSLT_WITH_TRIO OFF)
 option(LIBXSLT_WITH_XSLT_DEBUG "Add the debugging code" ON)
 
+if(NOT BUILD_SHARED_LIBS)
+       set(LIBXSLT_WITH_MODULES OFF)
+endif()
+
 if(LIBXSLT_WITH_CRYPTO AND NOT WIN32)
        find_package(Gcrypt REQUIRED)
 endif()
@@ -352,10 +356,38 @@ install(TARGETS xsltproc EXPORT LibXslt RUNTIME DESTINATION ${CMAKE_INSTALL_BIND
 
 if(LIBXSLT_WITH_TESTS)
        enable_testing()
+
+       if (NOT MSVC)
+               # TODO:
+               # - Unsupported encoding windows-1251
+               # - Segfault in exslt dynamic tests
+
+               add_executable(runtest tests/runtest.c)
+               target_link_libraries(runtest LibXslt LibExslt)
+               add_test(
+                       NAME runtest COMMAND runtest
+                       WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tests"
+               )
+
+               if (LIBXSLT_WITH_MODULES)
+                       add_library(testplugin SHARED tests/testplugin.c)
+                       target_link_libraries(testplugin LibExslt LibXslt)
+                       set_target_properties(
+                               testplugin PROPERTIES
+                               PREFIX ""
+                               OUTPUT_NAME xmlsoft_org_xslt_testplugin
+                       )
+                       set_tests_properties(
+                               runtest PROPERTIES
+                               ENVIRONMENT "LIBXSLT_PLUGINS_PATH=${CMAKE_CURRENT_BINARY_DIR}"
+                       )
+               endif()
+       endif()
+
        if(Threads_FOUND)
                add_executable(testThreads xsltproc/testThreads.c)
                target_link_libraries(testThreads LibXslt LibExslt Threads::Threads)
-               add_test(NAME testThreads COMMAND testThreads WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+               add_test(NAME testThreads COMMAND testThreads)
        endif()
 endif()
 
diff --git a/Makefile.am b/Makefile.am
index a2d766f5..db50cddb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,24 +39,6 @@ xsltConf.sh: xsltConf.sh.in Makefile
 
 CLEANFILES = xsltConf.sh
 
-check-local: tests
-
-dummy:
-
-tests: dummy
-       @echo '## Running the regression test suite'
-       @(cd tests ; $(MAKE) -s tests)
-       @(cd xsltproc ; $(MAKE) -s tests)
-if WITH_PYTHON
-       @cd python && $(MAKE) tests
-endif
-
-valgrind:
-       @echo '## Running the regression tests under Valgrind'
-       @echo '## Go get a cup of coffee it is gonna take a while ...'
-       @(cd tests ; $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests)
-       @(cd xsltproc ; $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests)
-
 cleanup:
        -@(find . -name .\#\* -exec rm {} \;)
 
diff --git a/configure.ac b/configure.ac
index 4ceeacf1..0cf164d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -551,33 +551,11 @@ xsltproc/Makefile
 python/Makefile
 python/tests/Makefile
 tests/Makefile
-tests/docs/Makefile
-tests/REC1/Makefile
-tests/REC2/Makefile
-tests/REC/Makefile
-tests/general/Makefile
-tests/reports/Makefile
-tests/extensions/Makefile
-tests/namespaces/Makefile
-tests/keys/Makefile
-tests/numbers/Makefile
-tests/documents/Makefile
 tests/xmlspec/Makefile
 tests/multiple/Makefile
 tests/xinclude/Makefile
 tests/XSLTMark/Makefile
 tests/docbook/Makefile
-tests/exslt/Makefile
-tests/exslt/common/Makefile
-tests/exslt/functions/Makefile
-tests/exslt/math/Makefile
-tests/exslt/saxon/Makefile
-tests/exslt/sets/Makefile
-tests/exslt/strings/Makefile
-tests/exslt/date/Makefile
-tests/exslt/dynamic/Makefile
-tests/exslt/crypto/Makefile
-tests/plugins/Makefile
 tests/fuzz/Makefile
 doc/Makefile
 doc/devhelp/Makefile
diff --git a/libxslt.spec.in b/libxslt.spec.in
index ad34e3cb..722e5880 100644
--- a/libxslt.spec.in
+++ b/libxslt.spec.in
@@ -69,7 +69,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
 rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/%{name}{,-python}-%{version}
 
 %check
-make tests
+make check
 
 %clean
 rm -fr %{buildroot}
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am
index 9239d1dc..861151fc 100644
--- a/python/tests/Makefile.am
+++ b/python/tests/Makefile.am
@@ -8,7 +8,7 @@ TESTSPY =       \
 exampledir = $(docdir)/python/examples
 dist_example_DATA = test.xml test.xsl pyxsltproc.py $(TESTSPY)
 
-tests: $(TESTSPY)
+check-local: $(TESTSPY)
        @(export PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH"; \
          export 
LD_LIBRARY_PATH="$(top_builddir)/libxslt/.libs:$(top_builddir)/libexslt/.libs:$$LD_LIBRARY_PATH"; \
          export 
DYLD_LIBRARY_PATH="$(top_builddir)/libxslt/.libs:$(top_builddir)/libexslt/.libs:$$DYLD_LIBRARY_PATH"; \
@@ -23,8 +23,6 @@ tests: $(TESTSPY)
            echo "-- $$test" ; \
            $(PYTHON) $(srcdir)/$$test; \
          done)
-else
-tests:
 endif
 
 CLEANFILES = *.pyc core
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5645bb01..72ecabf1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,26 +1,53 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS=docs REC1 REC2 REC general namespaces keys numbers documents \
-        extensions reports xmlspec multiple xinclude XSLTMark docbook \
-       exslt plugins fuzz
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)
 
-all:
+SUBDIRS = xmlspec multiple xinclude XSLTMark docbook fuzz
+
+DEPENDENCIES = $(top_builddir)/libxslt/libxslt.la \
+               $(top_builddir)/libexslt/libexslt.la
+
+LDADD = $(top_builddir)/libxslt/libxslt.la \
+        $(top_builddir)/libexslt/libexslt.la \
+        $(LIBXML_LIBS)
+
+check_PROGRAMS = runtest
+
+runtest_SOURCES = runtest.c
+
+if WITH_MODULES
 
-# Each subdirectory has it's own Makefile to cater for the unique
-# requirements of that subdirectory.  In general, xsltproc will be
-# run on the *.xsl / *.xml file combinations, and the output of that
-# run will be compared with the "expected" output contained in *.out
-# and (if errors are expected) in *.err
-test tests:
-       @(cur=`pwd` ; for dir in $(SUBDIRS) ; do cd $$dir ; $(MAKE) CHECKER='$(CHECKER)' tests ; cd $$cur ; 
done)
+check_LTLIBRARIES = xmlsoft_org_xslt_testplugin.la
 
-valgrind:
-       @echo '## Running the regression tests under Valgrind'
-       @echo '## Go get a cup of coffee it is gonna take a while ...'
-       $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests
+# our rpath is a rather unorthodox location as we
+# don't want to pollute $(DESTDIR) with the test plugin
+
+plugindir = $(abs_builddir)/.libs
+
+xmlsoft_org_xslt_testplugin_la_CFLAGS = $(AM_CFLAGS) -DMODULE_COMPILE
+xmlsoft_org_xslt_testplugin_la_SOURCES = testplugin.c
+xmlsoft_org_xslt_testplugin_la_LIBADD = $(top_builddir)/libxslt/libxslt.la $(EXTRA_LIBS)
+xmlsoft_org_xslt_testplugin_la_LDFLAGS = \
+       $(AM_LDFLAGS) -no-undefined \
+       -module -avoid-version -rpath $(plugindir)
+
+endif
+
+all:
 
-full: tests docbook_tests
+check-local:
+       cd $(srcdir) && LIBXSLT_PLUGINS_PATH=$(plugindir) $(abs_builddir)/runtest
 
 docbook_tests:
        @(cd docbook ; $(MAKE) full)
 
+dist-hook:
+       cp -a $(srcdir)/REC $(distdir)
+       cp -a $(srcdir)/REC2 $(distdir)
+       cp -a $(srcdir)/exslt $(distdir)
+       cp -a $(srcdir)/extensions $(distdir)
+       cp -a $(srcdir)/general $(distdir)
+       cp -a $(srcdir)/namespaces $(distdir)
+       cp -a $(srcdir)/numbers $(distdir)
+       cp -a $(srcdir)/plugins $(distdir)
+       cp -a $(srcdir)/reports $(distdir)
diff --git a/tests/REC2/html.out b/tests/REC2/html.out
new file mode 100644
index 00000000..94ed6c59
--- /dev/null
+++ b/tests/REC2/html.out
@@ -0,0 +1,32 @@
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Sales Results By Division</title>
+</head>
+<body><table border="1">
+<tr>
+<th>Division</th>
+<th>Revenue</th>
+<th>Growth</th>
+<th>Bonus</th>
+</tr>
+<tr>
+<td><em>North</em></td>
+<td>10</td>
+<td>9</td>
+<td>7</td>
+</tr>
+<tr>
+<td><em>West</em></td>
+<td>6</td>
+<td style="color:red">-1.5</td>
+<td>2</td>
+</tr>
+<tr>
+<td><em>South</em></td>
+<td>4</td>
+<td>3</td>
+<td>4</td>
+</tr>
+</table></body>
+</html>
diff --git a/tests/REC2/html.xml b/tests/REC2/html.xml
index 94ed6c59..a5437417 100644
--- a/tests/REC2/html.xml
+++ b/tests/REC2/html.xml
@@ -1,32 +1,21 @@
-<html lang="en">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>Sales Results By Division</title>
-</head>
-<body><table border="1">
-<tr>
-<th>Division</th>
-<th>Revenue</th>
-<th>Growth</th>
-<th>Bonus</th>
-</tr>
-<tr>
-<td><em>North</em></td>
-<td>10</td>
-<td>9</td>
-<td>7</td>
-</tr>
-<tr>
-<td><em>West</em></td>
-<td>6</td>
-<td style="color:red">-1.5</td>
-<td>2</td>
-</tr>
-<tr>
-<td><em>South</em></td>
-<td>4</td>
-<td>3</td>
-<td>4</td>
-</tr>
-</table></body>
-</html>
+<sales>
+
+        <division id="North">
+                <revenue>10</revenue>
+                <growth>9</growth>
+                <bonus>7</bonus>
+        </division>
+
+        <division id="South">
+                <revenue>4</revenue>
+                <growth>3</growth>
+                <bonus>4</bonus>
+        </division>
+
+        <division id="West">
+                <revenue>6</revenue>
+                <growth>-1.5</growth>
+                <bonus>2</bonus>
+        </division>
+
+</sales>
diff --git a/tests/REC2/svg.out b/tests/REC2/svg.out
new file mode 100644
index 00000000..fdaca227
--- /dev/null
+++ b/tests/REC2/svg.out
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/Graphics/SVG/SVG-19990812.dtd"; width="3in" height="3in">
+  <g style="stroke: #000000">
+    <line x1="0" x2="150" y1="150" y2="150"/>
+    <line x1="0" x2="0" y1="0" y2="150"/>
+    <text x="0" y="10">Revenue</text>
+    <text x="150" y="165">Division</text>
+    <rect x="10" y="50" width="20" height="100"/>
+    <text x="10" y="165">North</text>
+    <text x="10" y="45">10</text>
+    <rect x="50" y="110" width="20" height="40"/>
+    <text x="50" y="165">South</text>
+    <text x="50" y="105">4</text>
+    <rect x="90" y="90" width="20" height="60"/>
+    <text x="90" y="165">West</text>
+    <text x="90" y="85">6</text>
+  </g>
+</svg>
diff --git a/tests/REC2/svg.xml b/tests/REC2/svg.xml
index fdaca227..a5437417 100644
--- a/tests/REC2/svg.xml
+++ b/tests/REC2/svg.xml
@@ -1,18 +1,21 @@
-<?xml version="1.0"?>
-<svg xmlns="http://www.w3.org/Graphics/SVG/SVG-19990812.dtd"; width="3in" height="3in">
-  <g style="stroke: #000000">
-    <line x1="0" x2="150" y1="150" y2="150"/>
-    <line x1="0" x2="0" y1="0" y2="150"/>
-    <text x="0" y="10">Revenue</text>
-    <text x="150" y="165">Division</text>
-    <rect x="10" y="50" width="20" height="100"/>
-    <text x="10" y="165">North</text>
-    <text x="10" y="45">10</text>
-    <rect x="50" y="110" width="20" height="40"/>
-    <text x="50" y="165">South</text>
-    <text x="50" y="105">4</text>
-    <rect x="90" y="90" width="20" height="60"/>
-    <text x="90" y="165">West</text>
-    <text x="90" y="85">6</text>
-  </g>
-</svg>
+<sales>
+
+        <division id="North">
+                <revenue>10</revenue>
+                <growth>9</growth>
+                <bonus>7</bonus>
+        </division>
+
+        <division id="South">
+                <revenue>4</revenue>
+                <growth>3</growth>
+                <bonus>4</bonus>
+        </division>
+
+        <division id="West">
+                <revenue>6</revenue>
+                <growth>-1.5</growth>
+                <bonus>2</bonus>
+        </division>
+
+</sales>
diff --git a/tests/REC2/vrml.out b/tests/REC2/vrml.out
new file mode 100644
index 00000000..c9ba69f5
--- /dev/null
+++ b/tests/REC2/vrml.out
@@ -0,0 +1,38 @@
+#VRML V2.0 utf8 
+ 
+# externproto definition of a single bar element 
+EXTERNPROTO bar [ 
+  field SFInt32 x  
+  field SFInt32 y  
+  field SFInt32 z  
+  field SFString name  
+  ] 
+  "http://www.vrml.org/WorkingGroups/dbwork/barProto.wrl"; 
+ 
+# inline containing the graph axes 
+Inline {  
+        url "http://www.vrml.org/WorkingGroups/dbwork/barAxes.wrl"; 
+        } 
+        
+                
+bar {
+        x 10
+        y 9
+        z 7
+        name "North" 
+        }
+                
+bar {
+        x 4
+        y 3
+        z 4
+        name "South" 
+        }
+                
+bar {
+        x 6
+        y -1.5
+        z 2
+        name "West" 
+        }
+                
\ No newline at end of file
diff --git a/tests/REC2/vrml.xml b/tests/REC2/vrml.xml
index c9ba69f5..a5437417 100644
--- a/tests/REC2/vrml.xml
+++ b/tests/REC2/vrml.xml
@@ -1,38 +1,21 @@
-#VRML V2.0 utf8 
- 
-# externproto definition of a single bar element 
-EXTERNPROTO bar [ 
-  field SFInt32 x  
-  field SFInt32 y  
-  field SFInt32 z  
-  field SFString name  
-  ] 
-  "http://www.vrml.org/WorkingGroups/dbwork/barProto.wrl"; 
- 
-# inline containing the graph axes 
-Inline {  
-        url "http://www.vrml.org/WorkingGroups/dbwork/barAxes.wrl"; 
-        } 
-        
-                
-bar {
-        x 10
-        y 9
-        z 7
-        name "North" 
-        }
-                
-bar {
-        x 4
-        y 3
-        z 4
-        name "South" 
-        }
-                
-bar {
-        x 6
-        y -1.5
-        z 2
-        name "West" 
-        }
-                
\ No newline at end of file
+<sales>
+
+        <division id="North">
+                <revenue>10</revenue>
+                <growth>9</growth>
+                <bonus>7</bonus>
+        </division>
+
+        <division id="South">
+                <revenue>4</revenue>
+                <growth>3</growth>
+                <bonus>4</bonus>
+        </division>
+
+        <division id="West">
+                <revenue>6</revenue>
+                <growth>-1.5</growth>
+                <bonus>2</bonus>
+        </division>
+
+</sales>
diff --git a/tests/XSLTMark/Makefile.am b/tests/XSLTMark/Makefile.am
index 6932fef6..5ed2d73f 100644
--- a/tests/XSLTMark/Makefile.am
+++ b/tests/XSLTMark/Makefile.am
@@ -61,14 +61,10 @@ xsltproc = $(top_builddir)/xsltproc/xsltproc
 $(xsltproc):
        cd ../../xsltproc && $(MAKE) xsltproc
 
-test tests:
+check-local:
        @echo '## Running XSLTMark tests'
        @$(MAKE) $(ALL_TESTS)
 
-valgrind:
-       @echo '## Running the regression tests under Valgrind'
-       $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests
-
 CLEANFILES = *.tmp *~ .memdump core db100.xml db1000.xml db10000.xml
 
 
@@ -740,4 +736,4 @@ depth: $(xsltproc)
        fi
        @rm -f $@.tmp
 
-.PHONY: test tests valgrind $(ALL_TESTS)
+.PHONY: $(ALL_TESTS)
diff --git a/tests/docbook/Makefile.am b/tests/docbook/Makefile.am
index 83b1be3c..71ba0644 100644
--- a/tests/docbook/Makefile.am
+++ b/tests/docbook/Makefile.am
@@ -1,13 +1,9 @@
 ## Process this file with automake to produce Makefile.in
 
-tests:
+check-local:
        @$(MAKE) single
        @$(MAKE) xtchunk
 
-valgrind:
-       @echo '## Running the regression tests under Valgrind'
-       $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests
-
 $(top_builddir)/xsltproc/xsltproc:
        @(cd ../../xsltproc ; $(MAKE) xsltproc)
 
diff --git a/tests/documents/result.xhtml b/tests/documents/bredfort.out
similarity index 100%
rename from tests/documents/result.xhtml
rename to tests/documents/bredfort.out
diff --git a/tests/documents/index.xml b/tests/documents/bredfort.xml
similarity index 100%
rename from tests/documents/index.xml
rename to tests/documents/bredfort.xml
diff --git a/tests/documents/fragment.result b/tests/documents/fragment.out
similarity index 100%
rename from tests/documents/fragment.result
rename to tests/documents/fragment.out
diff --git a/tests/documents/message.result b/tests/documents/message.err
similarity index 100%
rename from tests/documents/message.result
rename to tests/documents/message.err
diff --git a/tests/documents/test.result b/tests/documents/test.out
similarity index 100%
rename from tests/documents/test.result
rename to tests/documents/test.out
diff --git a/tests/documents/test_bad.err b/tests/documents/test_bad.err
index 52e8b02c..e2ec793e 100644
--- a/tests/documents/test_bad.err
+++ b/tests/documents/test_bad.err
@@ -1,2 +1,2 @@
-warning: failed to load external entity "foofile.xml"
-warning: failed to load external entity "foo_file.xml"
+I/O warning : failed to load external entity "foofile.xml"
+I/O warning : failed to load external entity "foo_file.xml"
diff --git a/tests/documents/test_bad.result b/tests/documents/test_bad.out
similarity index 100%
rename from tests/documents/test_bad.result
rename to tests/documents/test_bad.out
diff --git a/tests/documents/test_bad.xsl b/tests/documents/test_bad.xsl
new file mode 100644
index 00000000..5c5aab09
--- /dev/null
+++ b/tests/documents/test_bad.xsl
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet
+         xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+         version="1.0">
+<xsl:output method="text" encoding="iso-8859-1"/>
+
+<xsl:template match="/files/file">
+    <xsl:variable name="file" select="document(@name)"/>
+        <xsl:if test="not($file)">
+        <xsl:text>Can't Open File: </xsl:text>
+        <xsl:value-of select="@name"/>
+    </xsl:if>
+    <xsl:value-of select="$file/tag1"/>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/fuzz/Makefile.am b/tests/fuzz/Makefile.am
index 372d2c5d..006e6215 100644
--- a/tests/fuzz/Makefile.am
+++ b/tests/fuzz/Makefile.am
@@ -24,11 +24,9 @@ $(top_builddir)/libxslt/libxslt.la:
 $(top_builddir)/libexslt/libexslt.la: $(top_builddir)/libxslt/libxslt.la
        cd $(top_builddir)/libexslt && $(MAKE) libexslt.la
 
-.PHONY: tests fuzz-xpath fuzz-xslt
+.PHONY: fuzz-xpath fuzz-xslt
 
-tests:
-
-fuzz: $(check_PROGRAMS)
+check-local: $(check_PROGRAMS)
        @echo '## Running fuzz target tests'
        @./testTargets $(srcdir)
 
diff --git a/tests/docs/array.xml b/tests/general/array.xml
similarity index 100%
rename from tests/docs/array.xml
rename to tests/general/array.xml
diff --git a/tests/docs/bug-1-.xml b/tests/general/bug-1-.xml
similarity index 100%
rename from tests/docs/bug-1-.xml
rename to tests/general/bug-1-.xml
diff --git a/tests/docs/bug-10-.xml b/tests/general/bug-10-.xml
similarity index 100%
rename from tests/docs/bug-10-.xml
rename to tests/general/bug-10-.xml
diff --git a/tests/docs/bug-100.xml b/tests/general/bug-100.xml
similarity index 100%
rename from tests/docs/bug-100.xml
rename to tests/general/bug-100.xml
diff --git a/tests/docs/bug-101.xml b/tests/general/bug-101.xml
similarity index 100%
rename from tests/docs/bug-101.xml
rename to tests/general/bug-101.xml
diff --git a/tests/docs/bug-102.xml b/tests/general/bug-102.xml
similarity index 100%
rename from tests/docs/bug-102.xml
rename to tests/general/bug-102.xml
diff --git a/tests/docs/bug-103.xml b/tests/general/bug-103.xml
similarity index 100%
rename from tests/docs/bug-103.xml
rename to tests/general/bug-103.xml
diff --git a/tests/docs/bug-104.xml b/tests/general/bug-104.xml
similarity index 100%
rename from tests/docs/bug-104.xml
rename to tests/general/bug-104.xml
diff --git a/tests/docs/bug-105.xml b/tests/general/bug-105.xml
similarity index 100%
rename from tests/docs/bug-105.xml
rename to tests/general/bug-105.xml
diff --git a/tests/docs/bug-106.xml b/tests/general/bug-106.xml
similarity index 100%
rename from tests/docs/bug-106.xml
rename to tests/general/bug-106.xml
diff --git a/tests/docs/bug-107.xml b/tests/general/bug-107.xml
similarity index 100%
rename from tests/docs/bug-107.xml
rename to tests/general/bug-107.xml
diff --git a/tests/docs/bug-108.xml b/tests/general/bug-108.xml
similarity index 100%
rename from tests/docs/bug-108.xml
rename to tests/general/bug-108.xml
diff --git a/tests/docs/bug-109.xml b/tests/general/bug-109.xml
similarity index 100%
rename from tests/docs/bug-109.xml
rename to tests/general/bug-109.xml
diff --git a/tests/docs/bug-11-.xml b/tests/general/bug-11-.xml
similarity index 100%
rename from tests/docs/bug-11-.xml
rename to tests/general/bug-11-.xml
diff --git a/tests/docs/bug-110.ent b/tests/general/bug-110.ent
similarity index 100%
rename from tests/docs/bug-110.ent
rename to tests/general/bug-110.ent
diff --git a/tests/docs/bug-110.xml b/tests/general/bug-110.xml
similarity index 100%
rename from tests/docs/bug-110.xml
rename to tests/general/bug-110.xml
diff --git a/tests/docs/bug-111.xml b/tests/general/bug-111.xml
similarity index 100%
rename from tests/docs/bug-111.xml
rename to tests/general/bug-111.xml
diff --git a/tests/docs/bug-112.xml b/tests/general/bug-112.xml
similarity index 100%
rename from tests/docs/bug-112.xml
rename to tests/general/bug-112.xml
diff --git a/tests/docs/bug-113.xml b/tests/general/bug-113.xml
similarity index 100%
rename from tests/docs/bug-113.xml
rename to tests/general/bug-113.xml
diff --git a/tests/docs/bug-114.xml b/tests/general/bug-114.xml
similarity index 100%
rename from tests/docs/bug-114.xml
rename to tests/general/bug-114.xml
diff --git a/tests/docs/bug-115.xml b/tests/general/bug-115.xml
similarity index 100%
rename from tests/docs/bug-115.xml
rename to tests/general/bug-115.xml
diff --git a/tests/docs/bug-116.xml b/tests/general/bug-116.xml
similarity index 100%
rename from tests/docs/bug-116.xml
rename to tests/general/bug-116.xml
diff --git a/tests/docs/bug-117.xml b/tests/general/bug-117.xml
similarity index 100%
rename from tests/docs/bug-117.xml
rename to tests/general/bug-117.xml
diff --git a/tests/docs/bug-118.xml b/tests/general/bug-118.xml
similarity index 100%
rename from tests/docs/bug-118.xml
rename to tests/general/bug-118.xml
diff --git a/tests/docs/bug-119.xml b/tests/general/bug-119.xml
similarity index 100%
rename from tests/docs/bug-119.xml
rename to tests/general/bug-119.xml
diff --git a/tests/docs/bug-12-.xml b/tests/general/bug-12-.xml
similarity index 100%
rename from tests/docs/bug-12-.xml
rename to tests/general/bug-12-.xml
diff --git a/tests/docs/bug-120.xml b/tests/general/bug-120.xml
similarity index 100%
rename from tests/docs/bug-120.xml
rename to tests/general/bug-120.xml
diff --git a/tests/docs/bug-121.xml b/tests/general/bug-121.xml
similarity index 100%
rename from tests/docs/bug-121.xml
rename to tests/general/bug-121.xml
diff --git a/tests/docs/bug-122.xml b/tests/general/bug-122.xml
similarity index 100%
rename from tests/docs/bug-122.xml
rename to tests/general/bug-122.xml
diff --git a/tests/docs/bug-123.xml b/tests/general/bug-123.xml
similarity index 100%
rename from tests/docs/bug-123.xml
rename to tests/general/bug-123.xml
diff --git a/tests/docs/bug-124.xml b/tests/general/bug-124.xml
similarity index 100%
rename from tests/docs/bug-124.xml
rename to tests/general/bug-124.xml
diff --git a/tests/docs/bug-125.xml b/tests/general/bug-125.xml
similarity index 100%
rename from tests/docs/bug-125.xml
rename to tests/general/bug-125.xml
diff --git a/tests/docs/bug-126.xml b/tests/general/bug-126.xml
similarity index 100%
rename from tests/docs/bug-126.xml
rename to tests/general/bug-126.xml
diff --git a/tests/docs/bug-127.xml b/tests/general/bug-127.xml
similarity index 100%
rename from tests/docs/bug-127.xml
rename to tests/general/bug-127.xml
diff --git a/tests/docs/bug-128.xml b/tests/general/bug-128.xml
similarity index 100%
rename from tests/docs/bug-128.xml
rename to tests/general/bug-128.xml
diff --git a/tests/docs/bug-129.xml b/tests/general/bug-129.xml
similarity index 100%
rename from tests/docs/bug-129.xml
rename to tests/general/bug-129.xml
diff --git a/tests/docs/bug-13-.xml b/tests/general/bug-13-.xml
similarity index 100%
rename from tests/docs/bug-13-.xml
rename to tests/general/bug-13-.xml
diff --git a/tests/docs/bug-130.doc b/tests/general/bug-130.doc
similarity index 100%
rename from tests/docs/bug-130.doc
rename to tests/general/bug-130.doc
diff --git a/tests/docs/bug-130.xml b/tests/general/bug-130.xml
similarity index 100%
rename from tests/docs/bug-130.xml
rename to tests/general/bug-130.xml
diff --git a/tests/general/bug-130.xsl b/tests/general/bug-130.xsl
index 1ac6e9fc..27377d22 100644
--- a/tests/general/bug-130.xsl
+++ b/tests/general/bug-130.xsl
@@ -10,7 +10,7 @@
 
 <xsl:output method="html" indent="no"/>
 
-<xsl:variable name="g.doc.root" select="document('../docs/bug-130.doc')"/>
+<xsl:variable name="g.doc.root" select="document('bug-130.doc')"/>
 
 <xsl:template match="/">
   <html>
diff --git a/tests/docs/bug-131.xml b/tests/general/bug-131.xml
similarity index 100%
rename from tests/docs/bug-131.xml
rename to tests/general/bug-131.xml
diff --git a/tests/docs/bug-132.xml b/tests/general/bug-132.xml
similarity index 100%
rename from tests/docs/bug-132.xml
rename to tests/general/bug-132.xml
diff --git a/tests/docs/bug-133.xml b/tests/general/bug-133.xml
similarity index 100%
rename from tests/docs/bug-133.xml
rename to tests/general/bug-133.xml
diff --git a/tests/docs/bug-134.xml b/tests/general/bug-134.xml
similarity index 100%
rename from tests/docs/bug-134.xml
rename to tests/general/bug-134.xml
diff --git a/tests/docs/bug-135.xml b/tests/general/bug-135.xml
similarity index 100%
rename from tests/docs/bug-135.xml
rename to tests/general/bug-135.xml
diff --git a/tests/docs/bug-136.xml b/tests/general/bug-136.xml
similarity index 100%
rename from tests/docs/bug-136.xml
rename to tests/general/bug-136.xml
diff --git a/tests/docs/bug-137.xml b/tests/general/bug-137.xml
similarity index 100%
rename from tests/docs/bug-137.xml
rename to tests/general/bug-137.xml
diff --git a/tests/docs/bug-138.xml b/tests/general/bug-138.xml
similarity index 100%
rename from tests/docs/bug-138.xml
rename to tests/general/bug-138.xml
diff --git a/tests/docs/bug-139.xml b/tests/general/bug-139.xml
similarity index 100%
rename from tests/docs/bug-139.xml
rename to tests/general/bug-139.xml
diff --git a/tests/docs/bug-14-.xml b/tests/general/bug-14-.xml
similarity index 100%
rename from tests/docs/bug-14-.xml
rename to tests/general/bug-14-.xml
diff --git a/tests/docs/bug-140.xml b/tests/general/bug-140.xml
similarity index 100%
rename from tests/docs/bug-140.xml
rename to tests/general/bug-140.xml
diff --git a/tests/docs/bug-141.xml b/tests/general/bug-141.xml
similarity index 100%
rename from tests/docs/bug-141.xml
rename to tests/general/bug-141.xml
diff --git a/tests/docs/bug-142.xml b/tests/general/bug-142.xml
similarity index 100%
rename from tests/docs/bug-142.xml
rename to tests/general/bug-142.xml
diff --git a/tests/docs/bug-143.xml b/tests/general/bug-143.xml
similarity index 100%
rename from tests/docs/bug-143.xml
rename to tests/general/bug-143.xml
diff --git a/tests/docs/bug-144.xml b/tests/general/bug-144.xml
similarity index 100%
rename from tests/docs/bug-144.xml
rename to tests/general/bug-144.xml
diff --git a/tests/general/bug-145.err b/tests/general/bug-145.err
index 5daeab4c..79d6a505 100644
--- a/tests/general/bug-145.err
+++ b/tests/general/bug-145.err
@@ -2,4 +2,4 @@ compilation error: file ./bug-145.xsl line 4 element transform
 xsl:version is missing: document may not be a stylesheet
 runtime error: file ./bug-145.xsl line 6 element call-template
 The called template '{a}a' was not found.
-no result for ./../docs/bug-145.xml
+no result for ./bug-145.xml
diff --git a/tests/docs/bug-145.xml b/tests/general/bug-145.xml
similarity index 100%
rename from tests/docs/bug-145.xml
rename to tests/general/bug-145.xml
diff --git a/tests/docs/bug-146.xml b/tests/general/bug-146.xml
similarity index 100%
rename from tests/docs/bug-146.xml
rename to tests/general/bug-146.xml
diff --git a/tests/docs/bug-147.xml b/tests/general/bug-147.xml
similarity index 100%
rename from tests/docs/bug-147.xml
rename to tests/general/bug-147.xml
diff --git a/tests/docs/bug-148.xml b/tests/general/bug-148.xml
similarity index 100%
rename from tests/docs/bug-148.xml
rename to tests/general/bug-148.xml
diff --git a/tests/docs/bug-149.xml b/tests/general/bug-149.xml
similarity index 100%
rename from tests/docs/bug-149.xml
rename to tests/general/bug-149.xml
diff --git a/tests/docs/bug-15-.xml b/tests/general/bug-15-.xml
similarity index 100%
rename from tests/docs/bug-15-.xml
rename to tests/general/bug-15-.xml
diff --git a/tests/docs/bug-150.xml b/tests/general/bug-150.xml
similarity index 100%
rename from tests/docs/bug-150.xml
rename to tests/general/bug-150.xml
diff --git a/tests/docs/bug-151.xml b/tests/general/bug-151.xml
similarity index 100%
rename from tests/docs/bug-151.xml
rename to tests/general/bug-151.xml
diff --git a/tests/docs/bug-152.xml b/tests/general/bug-152.xml
similarity index 100%
rename from tests/docs/bug-152.xml
rename to tests/general/bug-152.xml
diff --git a/tests/docs/bug-153.doc b/tests/general/bug-153.doc
similarity index 100%
rename from tests/docs/bug-153.doc
rename to tests/general/bug-153.doc
diff --git a/tests/docs/bug-153.xml b/tests/general/bug-153.xml
similarity index 100%
rename from tests/docs/bug-153.xml
rename to tests/general/bug-153.xml
diff --git a/tests/general/bug-153.xsl b/tests/general/bug-153.xsl
index 68b05324..3de7f7c3 100644
--- a/tests/general/bug-153.xsl
+++ b/tests/general/bug-153.xsl
@@ -10,7 +10,7 @@
 
   <xsl:template match="c">
     <p>
-      <xsl:value-of select="document('../docs/bug-153.doc')/ch/v[@name=current()/v]"/>
+      <xsl:value-of select="document('bug-153.doc')/ch/v[@name=current()/v]"/>
     </p>
   </xsl:template>
 
diff --git a/tests/docs/bug-154.xml b/tests/general/bug-154.xml
similarity index 100%
rename from tests/docs/bug-154.xml
rename to tests/general/bug-154.xml
diff --git a/tests/docs/bug-155.xml b/tests/general/bug-155.xml
similarity index 100%
rename from tests/docs/bug-155.xml
rename to tests/general/bug-155.xml
diff --git a/tests/docs/bug-156.xml b/tests/general/bug-156.xml
similarity index 100%
rename from tests/docs/bug-156.xml
rename to tests/general/bug-156.xml
diff --git a/tests/docs/bug-157.xml b/tests/general/bug-157.xml
similarity index 100%
rename from tests/docs/bug-157.xml
rename to tests/general/bug-157.xml
diff --git a/tests/docs/bug-158.doc b/tests/general/bug-158.doc
similarity index 100%
rename from tests/docs/bug-158.doc
rename to tests/general/bug-158.doc
diff --git a/tests/docs/bug-158.xml b/tests/general/bug-158.xml
similarity index 100%
rename from tests/docs/bug-158.xml
rename to tests/general/bug-158.xml
diff --git a/tests/general/bug-158.xsl b/tests/general/bug-158.xsl
index 3b955dca..230aca23 100644
--- a/tests/general/bug-158.xsl
+++ b/tests/general/bug-158.xsl
@@ -7,7 +7,7 @@
                 xmlns="http://www.w3.org/1999/xhtml";>
 
 <xsl:variable name="myPath" select="/dsl:page/@path" />
-<xsl:variable name="layout" select="document('../docs/bug-158.doc')"/>
+<xsl:variable name="layout" select="document('bug-158.doc')"/>
 <xsl:variable name="root"><xsl:value-of select="$layout//layout:page[@path=$myPath]" />
 </xsl:variable>
 
diff --git a/tests/docs/bug-159.xml b/tests/general/bug-159.xml
similarity index 100%
rename from tests/docs/bug-159.xml
rename to tests/general/bug-159.xml
diff --git a/tests/docs/bug-16-.xml b/tests/general/bug-16-.xml
similarity index 100%
rename from tests/docs/bug-16-.xml
rename to tests/general/bug-16-.xml
diff --git a/tests/docs/bug-160.xml b/tests/general/bug-160.xml
similarity index 100%
rename from tests/docs/bug-160.xml
rename to tests/general/bug-160.xml
diff --git a/tests/docs/bug-161.xml b/tests/general/bug-161.xml
similarity index 100%
rename from tests/docs/bug-161.xml
rename to tests/general/bug-161.xml
diff --git a/tests/docs/bug-163.xml b/tests/general/bug-163.xml
similarity index 100%
rename from tests/docs/bug-163.xml
rename to tests/general/bug-163.xml
diff --git a/tests/docs/bug-164.xml b/tests/general/bug-164.xml
similarity index 100%
rename from tests/docs/bug-164.xml
rename to tests/general/bug-164.xml
diff --git a/tests/general/bug-165.err b/tests/general/bug-165.err
index dab9d7ef..df0e7949 100644
--- a/tests/general/bug-165.err
+++ b/tests/general/bug-165.err
@@ -3,4 +3,4 @@ Variable 'pStyle' has not been declared.
 XPath error : Undefined variable
 runtime error: file ./bug-165.xsl line 6 element value-of
 XPath evaluation returned no result.
-no result for ./../docs/bug-165.xml
+no result for ./bug-165.xml
diff --git a/tests/docs/bug-165.xml b/tests/general/bug-165.xml
similarity index 100%
rename from tests/docs/bug-165.xml
rename to tests/general/bug-165.xml
diff --git a/tests/docs/bug-166.xml b/tests/general/bug-166.xml
similarity index 100%
rename from tests/docs/bug-166.xml
rename to tests/general/bug-166.xml
diff --git a/tests/docs/bug-167.xml b/tests/general/bug-167.xml
similarity index 100%
rename from tests/docs/bug-167.xml
rename to tests/general/bug-167.xml
diff --git a/tests/docs/bug-168.xml b/tests/general/bug-168.xml
similarity index 100%
rename from tests/docs/bug-168.xml
rename to tests/general/bug-168.xml
diff --git a/tests/docs/bug-169.xml b/tests/general/bug-169.xml
similarity index 100%
rename from tests/docs/bug-169.xml
rename to tests/general/bug-169.xml
diff --git a/tests/docs/bug-17-.xml b/tests/general/bug-17-.xml
similarity index 100%
rename from tests/docs/bug-17-.xml
rename to tests/general/bug-17-.xml
diff --git a/tests/docs/bug-170.xml b/tests/general/bug-170.xml
similarity index 100%
rename from tests/docs/bug-170.xml
rename to tests/general/bug-170.xml
diff --git a/tests/docs/bug-171.xml b/tests/general/bug-171.xml
similarity index 100%
rename from tests/docs/bug-171.xml
rename to tests/general/bug-171.xml
diff --git a/tests/docs/bug-172.xml b/tests/general/bug-172.xml
similarity index 100%
rename from tests/docs/bug-172.xml
rename to tests/general/bug-172.xml
diff --git a/tests/docs/bug-173.xml b/tests/general/bug-173.xml
similarity index 100%
rename from tests/docs/bug-173.xml
rename to tests/general/bug-173.xml
diff --git a/tests/docs/bug-174.xml b/tests/general/bug-174.xml
similarity index 100%
rename from tests/docs/bug-174.xml
rename to tests/general/bug-174.xml
diff --git a/tests/docs/bug-175.xml b/tests/general/bug-175.xml
similarity index 100%
rename from tests/docs/bug-175.xml
rename to tests/general/bug-175.xml
diff --git a/tests/docs/bug-176.xml b/tests/general/bug-176.xml
similarity index 100%
rename from tests/docs/bug-176.xml
rename to tests/general/bug-176.xml
diff --git a/tests/docs/bug-177.xml b/tests/general/bug-177.xml
similarity index 100%
rename from tests/docs/bug-177.xml
rename to tests/general/bug-177.xml
diff --git a/tests/docs/bug-178.xml b/tests/general/bug-178.xml
similarity index 100%
rename from tests/docs/bug-178.xml
rename to tests/general/bug-178.xml
diff --git a/tests/docs/bug-179.xml b/tests/general/bug-179.xml
similarity index 100%
rename from tests/docs/bug-179.xml
rename to tests/general/bug-179.xml
diff --git a/tests/docs/bug-18-.xml b/tests/general/bug-18-.xml
similarity index 100%
rename from tests/docs/bug-18-.xml
rename to tests/general/bug-18-.xml
diff --git a/tests/general/bug-180.err b/tests/general/bug-180.err
index 7b15044d..76e3ae1d 100644
--- a/tests/general/bug-180.err
+++ b/tests/general/bug-180.err
@@ -1,4 +1,4 @@
 runtime error: file ./bug-180.xsl line 4 element copy-of
 Variable 'xxx' has not been declared.
 XPath error : Undefined variable
-no result for ./../docs/bug-180.xml
+no result for ./bug-180.xml
diff --git a/tests/docs/bug-180.xml b/tests/general/bug-180.xml
similarity index 100%
rename from tests/docs/bug-180.xml
rename to tests/general/bug-180.xml
diff --git a/tests/docs/bug-181.xml b/tests/general/bug-181.xml
similarity index 100%
rename from tests/docs/bug-181.xml
rename to tests/general/bug-181.xml
diff --git a/tests/docs/bug-182.xml b/tests/general/bug-182.xml
similarity index 100%
rename from tests/docs/bug-182.xml
rename to tests/general/bug-182.xml
diff --git a/tests/docs/bug-183.xml b/tests/general/bug-183.xml
similarity index 100%
rename from tests/docs/bug-183.xml
rename to tests/general/bug-183.xml
diff --git a/tests/general/bug-184.err b/tests/general/bug-184.err
index eaeb65bd..ddcef71d 100644
--- a/tests/general/bug-184.err
+++ b/tests/general/bug-184.err
@@ -3,4 +3,4 @@ Variable 'nonexistent' has not been declared.
 XPath error : Undefined variable
 runtime error: file ./bug-184.xsl line 5 element value-of
 XPath evaluation returned no result.
-no result for ./../docs/bug-184.xml
+no result for ./bug-184.xml
diff --git a/tests/docs/bug-184.xml b/tests/general/bug-184.xml
similarity index 100%
rename from tests/docs/bug-184.xml
rename to tests/general/bug-184.xml
diff --git a/tests/docs/bug-186.xml b/tests/general/bug-186.xml
similarity index 100%
rename from tests/docs/bug-186.xml
rename to tests/general/bug-186.xml
diff --git a/tests/docs/bug-187.xml b/tests/general/bug-187.xml
similarity index 100%
rename from tests/docs/bug-187.xml
rename to tests/general/bug-187.xml
diff --git a/tests/docs/bug-188.xml b/tests/general/bug-188.xml
similarity index 100%
rename from tests/docs/bug-188.xml
rename to tests/general/bug-188.xml
diff --git a/tests/docs/bug-189.xml b/tests/general/bug-189.xml
similarity index 100%
rename from tests/docs/bug-189.xml
rename to tests/general/bug-189.xml
diff --git a/tests/docs/bug-19-.xml b/tests/general/bug-19-.xml
similarity index 100%
rename from tests/docs/bug-19-.xml
rename to tests/general/bug-19-.xml
diff --git a/tests/docs/bug-190.xml b/tests/general/bug-190.xml
similarity index 100%
rename from tests/docs/bug-190.xml
rename to tests/general/bug-190.xml
diff --git a/tests/docs/bug-191.xml b/tests/general/bug-191.xml
similarity index 100%
rename from tests/docs/bug-191.xml
rename to tests/general/bug-191.xml
diff --git a/tests/docs/bug-192.xml b/tests/general/bug-192.xml
similarity index 100%
rename from tests/docs/bug-192.xml
rename to tests/general/bug-192.xml
diff --git a/tests/docs/bug-193.xml b/tests/general/bug-193.xml
similarity index 100%
rename from tests/docs/bug-193.xml
rename to tests/general/bug-193.xml
diff --git a/tests/general/bug-194.err b/tests/general/bug-194.err
index 2d5a6bef..79b9b009 100644
--- a/tests/general/bug-194.err
+++ b/tests/general/bug-194.err
@@ -6,4 +6,4 @@ Failed to evaluate the expression of variable 'p'.
 XPath error : Undefined variable
 runtime error: file ./bug-194.xsl line 5 element param
 Failed to evaluate the expression of variable 'p2'.
-no result for ./../docs/bug-194.xml
+no result for ./bug-194.xml
diff --git a/tests/docs/bug-194.xml b/tests/general/bug-194.xml
similarity index 100%
rename from tests/docs/bug-194.xml
rename to tests/general/bug-194.xml
diff --git a/tests/docs/bug-195.xml b/tests/general/bug-195.xml
similarity index 100%
rename from tests/docs/bug-195.xml
rename to tests/general/bug-195.xml
diff --git a/tests/docs/bug-196.xml b/tests/general/bug-196.xml
similarity index 100%
rename from tests/docs/bug-196.xml
rename to tests/general/bug-196.xml
diff --git a/tests/docs/bug-197.xml b/tests/general/bug-197.xml
similarity index 100%
rename from tests/docs/bug-197.xml
rename to tests/general/bug-197.xml
diff --git a/tests/docs/bug-198.xml b/tests/general/bug-198.xml
similarity index 100%
rename from tests/docs/bug-198.xml
rename to tests/general/bug-198.xml
diff --git a/tests/docs/bug-199.xml b/tests/general/bug-199.xml
similarity index 100%
rename from tests/docs/bug-199.xml
rename to tests/general/bug-199.xml
diff --git a/tests/docs/bug-2-.xml b/tests/general/bug-2-.xml
similarity index 100%
rename from tests/docs/bug-2-.xml
rename to tests/general/bug-2-.xml
diff --git a/tests/docs/bug-20-.xml b/tests/general/bug-20-.xml
similarity index 100%
rename from tests/docs/bug-20-.xml
rename to tests/general/bug-20-.xml
diff --git a/tests/docs/bug-200.xml b/tests/general/bug-200.xml
similarity index 100%
rename from tests/docs/bug-200.xml
rename to tests/general/bug-200.xml
diff --git a/tests/general/bug-201.err b/tests/general/bug-201.err
index a115d4d2..624c4c55 100644
--- a/tests/general/bug-201.err
+++ b/tests/general/bug-201.err
@@ -3,4 +3,4 @@ exsltFuncFunctionFunction: Potentially infinite recursion detected in function {
 XPath error : Stack usage error
 runtime error: file ./bug-201.xsl line 8 element param
 Failed to evaluate the expression of variable 'var'.
-no result for ./../docs/bug-201.xml
+no result for ./bug-201.xml
diff --git a/tests/docs/bug-201.xml b/tests/general/bug-201.xml
similarity index 100%
rename from tests/docs/bug-201.xml
rename to tests/general/bug-201.xml
diff --git a/tests/docs/bug-202.xml b/tests/general/bug-202.xml
similarity index 100%
rename from tests/docs/bug-202.xml
rename to tests/general/bug-202.xml
diff --git a/tests/docs/bug-203.xml b/tests/general/bug-203.xml
similarity index 100%
rename from tests/docs/bug-203.xml
rename to tests/general/bug-203.xml
diff --git a/tests/docs/bug-204.xml b/tests/general/bug-204.xml
similarity index 100%
rename from tests/docs/bug-204.xml
rename to tests/general/bug-204.xml
diff --git a/tests/docs/bug-205.xml b/tests/general/bug-205.xml
similarity index 100%
rename from tests/docs/bug-205.xml
rename to tests/general/bug-205.xml
diff --git a/tests/docs/bug-206.xml b/tests/general/bug-206.xml
similarity index 100%
rename from tests/docs/bug-206.xml
rename to tests/general/bug-206.xml
diff --git a/tests/docs/bug-207.xml b/tests/general/bug-207.xml
similarity index 100%
rename from tests/docs/bug-207.xml
rename to tests/general/bug-207.xml
diff --git a/tests/general/bug-208.err b/tests/general/bug-208.err
index 02c97121..4b96fa74 100644
--- a/tests/general/bug-208.err
+++ b/tests/general/bug-208.err
@@ -3,4 +3,4 @@ XPath error : Undefined namespace prefix
 XPath error : Undefined namespace prefix
 XPath error : Undefined namespace prefix
 XPath error : Undefined namespace prefix
-no result for ./../docs/bug-208.xml
+no result for ./bug-208.xml
diff --git a/tests/docs/bug-208.xml b/tests/general/bug-208.xml
similarity index 100%
rename from tests/docs/bug-208.xml
rename to tests/general/bug-208.xml
diff --git a/tests/docs/bug-209.xml b/tests/general/bug-209.xml
similarity index 100%
rename from tests/docs/bug-209.xml
rename to tests/general/bug-209.xml
diff --git a/tests/general/bug-21-.out b/tests/general/bug-21-.out
index 8a98dfde..ac45087a 100644
--- a/tests/general/bug-21-.out
+++ b/tests/general/bug-21-.out
@@ -1,2 +1,2 @@
 <?xml version="1.0"?>
-../docs/test.jpg
+test.jpg
diff --git a/tests/docs/bug-21-.xml b/tests/general/bug-21-.xml
similarity index 100%
rename from tests/docs/bug-21-.xml
rename to tests/general/bug-21-.xml
diff --git a/tests/docs/bug-210.xml b/tests/general/bug-210.xml
similarity index 100%
rename from tests/docs/bug-210.xml
rename to tests/general/bug-210.xml
diff --git a/tests/docs/bug-211.xml b/tests/general/bug-211.xml
similarity index 100%
rename from tests/docs/bug-211.xml
rename to tests/general/bug-211.xml
diff --git a/tests/docs/bug-212.xml b/tests/general/bug-212.xml
similarity index 100%
rename from tests/docs/bug-212.xml
rename to tests/general/bug-212.xml
diff --git a/tests/docs/bug-213.xml b/tests/general/bug-213.xml
similarity index 100%
rename from tests/docs/bug-213.xml
rename to tests/general/bug-213.xml
diff --git a/tests/docs/bug-214.xml b/tests/general/bug-214.xml
similarity index 100%
rename from tests/docs/bug-214.xml
rename to tests/general/bug-214.xml
diff --git a/tests/general/bug-215.err b/tests/general/bug-215.err
index 3d8dc184..4d4fd80f 100644
--- a/tests/general/bug-215.err
+++ b/tests/general/bug-215.err
@@ -2,4 +2,4 @@
 XPath error : Stack usage error
 runtime error: file ./bug-215.xsl line 5 element variable
 Evaluating global variable  var/param being computed failed
-no result for ./../docs/bug-215.xml
+no result for ./bug-215.xml
diff --git a/tests/docs/bug-215.xml b/tests/general/bug-215.xml
similarity index 100%
rename from tests/docs/bug-215.xml
rename to tests/general/bug-215.xml
diff --git a/tests/docs/bug-216.xml b/tests/general/bug-216.xml
similarity index 100%
rename from tests/docs/bug-216.xml
rename to tests/general/bug-216.xml
diff --git a/tests/docs/bug-217.xml b/tests/general/bug-217.xml
similarity index 100%
rename from tests/docs/bug-217.xml
rename to tests/general/bug-217.xml
diff --git a/tests/docs/bug-218.xml b/tests/general/bug-218.xml
similarity index 100%
rename from tests/docs/bug-218.xml
rename to tests/general/bug-218.xml
diff --git a/tests/docs/bug-219.xml b/tests/general/bug-219.xml
similarity index 100%
rename from tests/docs/bug-219.xml
rename to tests/general/bug-219.xml
diff --git a/tests/docs/bug-22-.xml b/tests/general/bug-22-.xml
similarity index 100%
rename from tests/docs/bug-22-.xml
rename to tests/general/bug-22-.xml
diff --git a/tests/docs/bug-220.xml b/tests/general/bug-220.xml
similarity index 100%
rename from tests/docs/bug-220.xml
rename to tests/general/bug-220.xml
diff --git a/tests/docs/bug-221.xml b/tests/general/bug-221.xml
similarity index 100%
rename from tests/docs/bug-221.xml
rename to tests/general/bug-221.xml
diff --git a/tests/docs/bug-222.xml b/tests/general/bug-222.xml
similarity index 100%
rename from tests/docs/bug-222.xml
rename to tests/general/bug-222.xml
diff --git a/tests/docs/bug-23-.xml b/tests/general/bug-23-.xml
similarity index 100%
rename from tests/docs/bug-23-.xml
rename to tests/general/bug-23-.xml
diff --git a/tests/docs/bug-24-.xml b/tests/general/bug-24-.xml
similarity index 100%
rename from tests/docs/bug-24-.xml
rename to tests/general/bug-24-.xml
diff --git a/tests/docs/bug-25-.xml b/tests/general/bug-25-.xml
similarity index 100%
rename from tests/docs/bug-25-.xml
rename to tests/general/bug-25-.xml
diff --git a/tests/docs/bug-26-.xml b/tests/general/bug-26-.xml
similarity index 100%
rename from tests/docs/bug-26-.xml
rename to tests/general/bug-26-.xml
diff --git a/tests/docs/bug-27-.xml b/tests/general/bug-27-.xml
similarity index 100%
rename from tests/docs/bug-27-.xml
rename to tests/general/bug-27-.xml
diff --git a/tests/docs/bug-28-.xml b/tests/general/bug-28-.xml
similarity index 100%
rename from tests/docs/bug-28-.xml
rename to tests/general/bug-28-.xml
diff --git a/tests/docs/bug-29-.ent b/tests/general/bug-29-.ent
similarity index 100%
rename from tests/docs/bug-29-.ent
rename to tests/general/bug-29-.ent
diff --git a/tests/docs/bug-29-.xml b/tests/general/bug-29-.xml
similarity index 100%
rename from tests/docs/bug-29-.xml
rename to tests/general/bug-29-.xml
diff --git a/tests/docs/bug-3-.xml b/tests/general/bug-3-.xml
similarity index 100%
rename from tests/docs/bug-3-.xml
rename to tests/general/bug-3-.xml
diff --git a/tests/docs/bug-30-.xml b/tests/general/bug-30-.xml
similarity index 100%
rename from tests/docs/bug-30-.xml
rename to tests/general/bug-30-.xml
diff --git a/tests/docs/bug-31-.xml b/tests/general/bug-31-.xml
similarity index 100%
rename from tests/docs/bug-31-.xml
rename to tests/general/bug-31-.xml
diff --git a/tests/docs/bug-32-.xml b/tests/general/bug-32-.xml
similarity index 100%
rename from tests/docs/bug-32-.xml
rename to tests/general/bug-32-.xml
diff --git a/tests/docs/bug-33-.xml b/tests/general/bug-33-.xml
similarity index 100%
rename from tests/docs/bug-33-.xml
rename to tests/general/bug-33-.xml
diff --git a/tests/docs/bug-35-.xml b/tests/general/bug-35-.xml
similarity index 100%
rename from tests/docs/bug-35-.xml
rename to tests/general/bug-35-.xml
diff --git a/tests/docs/bug-36-.xml b/tests/general/bug-36-.xml
similarity index 100%
rename from tests/docs/bug-36-.xml
rename to tests/general/bug-36-.xml
diff --git a/tests/docs/bug-37-.xml b/tests/general/bug-37-.xml
similarity index 100%
rename from tests/docs/bug-37-.xml
rename to tests/general/bug-37-.xml
diff --git a/tests/docs/bug-38-.xml b/tests/general/bug-38-.xml
similarity index 100%
rename from tests/docs/bug-38-.xml
rename to tests/general/bug-38-.xml
diff --git a/tests/docs/bug-39-.xml b/tests/general/bug-39-.xml
similarity index 100%
rename from tests/docs/bug-39-.xml
rename to tests/general/bug-39-.xml
diff --git a/tests/docs/bug-4-.xml b/tests/general/bug-4-.xml
similarity index 100%
rename from tests/docs/bug-4-.xml
rename to tests/general/bug-4-.xml
diff --git a/tests/docs/bug-40-.xml b/tests/general/bug-40-.xml
similarity index 100%
rename from tests/docs/bug-40-.xml
rename to tests/general/bug-40-.xml
diff --git a/tests/docs/bug-41-.xml b/tests/general/bug-41-.xml
similarity index 100%
rename from tests/docs/bug-41-.xml
rename to tests/general/bug-41-.xml
diff --git a/tests/docs/bug-42-.xml b/tests/general/bug-42-.xml
similarity index 100%
rename from tests/docs/bug-42-.xml
rename to tests/general/bug-42-.xml
diff --git a/tests/docs/bug-43-.xml b/tests/general/bug-43-.xml
similarity index 100%
rename from tests/docs/bug-43-.xml
rename to tests/general/bug-43-.xml
diff --git a/tests/docs/bug-44-.xml b/tests/general/bug-44-.xml
similarity index 100%
rename from tests/docs/bug-44-.xml
rename to tests/general/bug-44-.xml
diff --git a/tests/docs/bug-45-.xml b/tests/general/bug-45-.xml
similarity index 100%
rename from tests/docs/bug-45-.xml
rename to tests/general/bug-45-.xml
diff --git a/tests/docs/bug-46-.xml b/tests/general/bug-46-.xml
similarity index 100%
rename from tests/docs/bug-46-.xml
rename to tests/general/bug-46-.xml
diff --git a/tests/docs/bug-47-.xml b/tests/general/bug-47-.xml
similarity index 100%
rename from tests/docs/bug-47-.xml
rename to tests/general/bug-47-.xml
diff --git a/tests/docs/bug-48-.xml b/tests/general/bug-48-.xml
similarity index 100%
rename from tests/docs/bug-48-.xml
rename to tests/general/bug-48-.xml
diff --git a/tests/docs/bug-49-.xml b/tests/general/bug-49-.xml
similarity index 100%
rename from tests/docs/bug-49-.xml
rename to tests/general/bug-49-.xml
diff --git a/tests/docs/bug-5-.xml b/tests/general/bug-5-.xml
similarity index 100%
rename from tests/docs/bug-5-.xml
rename to tests/general/bug-5-.xml
diff --git a/tests/docs/bug-50-.xml b/tests/general/bug-50-.xml
similarity index 100%
rename from tests/docs/bug-50-.xml
rename to tests/general/bug-50-.xml
diff --git a/tests/general/bug-52.out b/tests/general/bug-52.out
index 486ba022..3179a6a7 100644
--- a/tests/general/bug-52.out
+++ b/tests/general/bug-52.out
@@ -1,3 +1,3 @@
 
-Graphic file=../docs/graphic.gif
+Graphic file=graphic.gif
 
diff --git a/tests/docs/bug-52.xml b/tests/general/bug-52.xml
similarity index 100%
rename from tests/docs/bug-52.xml
rename to tests/general/bug-52.xml
diff --git a/tests/docs/bug-53.xml b/tests/general/bug-53.xml
similarity index 100%
rename from tests/docs/bug-53.xml
rename to tests/general/bug-53.xml
diff --git a/tests/docs/bug-54.xml b/tests/general/bug-54.xml
similarity index 100%
rename from tests/docs/bug-54.xml
rename to tests/general/bug-54.xml
diff --git a/tests/docs/bug-55.xml b/tests/general/bug-55.xml
similarity index 100%
rename from tests/docs/bug-55.xml
rename to tests/general/bug-55.xml
diff --git a/tests/docs/bug-56.xml b/tests/general/bug-56.xml
similarity index 100%
rename from tests/docs/bug-56.xml
rename to tests/general/bug-56.xml
diff --git a/tests/docs/bug-57.xml b/tests/general/bug-57.xml
similarity index 100%
rename from tests/docs/bug-57.xml
rename to tests/general/bug-57.xml
diff --git a/tests/docs/bug-59.xml b/tests/general/bug-59.xml
similarity index 100%
rename from tests/docs/bug-59.xml
rename to tests/general/bug-59.xml
diff --git a/tests/docs/bug-6-.xml b/tests/general/bug-6-.xml
similarity index 100%
rename from tests/docs/bug-6-.xml
rename to tests/general/bug-6-.xml
diff --git a/tests/docs/bug-60.xml b/tests/general/bug-60.xml
similarity index 100%
rename from tests/docs/bug-60.xml
rename to tests/general/bug-60.xml
diff --git a/tests/docs/bug-61.xml b/tests/general/bug-61.xml
similarity index 100%
rename from tests/docs/bug-61.xml
rename to tests/general/bug-61.xml
diff --git a/tests/docs/bug-62.xml b/tests/general/bug-62.xml
similarity index 100%
rename from tests/docs/bug-62.xml
rename to tests/general/bug-62.xml
diff --git a/tests/docs/bug-63.xml b/tests/general/bug-63.xml
similarity index 100%
rename from tests/docs/bug-63.xml
rename to tests/general/bug-63.xml
diff --git a/tests/docs/bug-64.xml b/tests/general/bug-64.xml
similarity index 100%
rename from tests/docs/bug-64.xml
rename to tests/general/bug-64.xml
diff --git a/tests/docs/bug-65.xml b/tests/general/bug-65.xml
similarity index 100%
rename from tests/docs/bug-65.xml
rename to tests/general/bug-65.xml
diff --git a/tests/docs/bug-66.xml b/tests/general/bug-66.xml
similarity index 100%
rename from tests/docs/bug-66.xml
rename to tests/general/bug-66.xml
diff --git a/tests/docs/bug-68.xml b/tests/general/bug-68.xml
similarity index 100%
rename from tests/docs/bug-68.xml
rename to tests/general/bug-68.xml
diff --git a/tests/docs/bug-69.xml b/tests/general/bug-69.xml
similarity index 100%
rename from tests/docs/bug-69.xml
rename to tests/general/bug-69.xml
diff --git a/tests/docs/bug-7-.xml b/tests/general/bug-7-.xml
similarity index 100%
rename from tests/docs/bug-7-.xml
rename to tests/general/bug-7-.xml
diff --git a/tests/docs/bug-70.xml b/tests/general/bug-70.xml
similarity index 100%
rename from tests/docs/bug-70.xml
rename to tests/general/bug-70.xml
diff --git a/tests/docs/bug-71.xml b/tests/general/bug-71.xml
similarity index 100%
rename from tests/docs/bug-71.xml
rename to tests/general/bug-71.xml
diff --git a/tests/docs/bug-72.xml b/tests/general/bug-72.xml
similarity index 100%
rename from tests/docs/bug-72.xml
rename to tests/general/bug-72.xml
diff --git a/tests/docs/bug-73.xml b/tests/general/bug-73.xml
similarity index 100%
rename from tests/docs/bug-73.xml
rename to tests/general/bug-73.xml
diff --git a/tests/docs/bug-74.xml b/tests/general/bug-74.xml
similarity index 100%
rename from tests/docs/bug-74.xml
rename to tests/general/bug-74.xml
diff --git a/tests/docs/bug-75.xml b/tests/general/bug-75.xml
similarity index 100%
rename from tests/docs/bug-75.xml
rename to tests/general/bug-75.xml
diff --git a/tests/docs/bug-76.xml b/tests/general/bug-76.xml
similarity index 100%
rename from tests/docs/bug-76.xml
rename to tests/general/bug-76.xml
diff --git a/tests/docs/bug-77.xml b/tests/general/bug-77.xml
similarity index 100%
rename from tests/docs/bug-77.xml
rename to tests/general/bug-77.xml
diff --git a/tests/docs/bug-78.xml b/tests/general/bug-78.xml
similarity index 100%
rename from tests/docs/bug-78.xml
rename to tests/general/bug-78.xml
diff --git a/tests/docs/bug-79.xml b/tests/general/bug-79.xml
similarity index 100%
rename from tests/docs/bug-79.xml
rename to tests/general/bug-79.xml
diff --git a/tests/docs/bug-8-.xml b/tests/general/bug-8-.xml
similarity index 100%
rename from tests/docs/bug-8-.xml
rename to tests/general/bug-8-.xml
diff --git a/tests/docs/bug-80.xml b/tests/general/bug-80.xml
similarity index 100%
rename from tests/docs/bug-80.xml
rename to tests/general/bug-80.xml
diff --git a/tests/docs/bug-81.xml b/tests/general/bug-81.xml
similarity index 100%
rename from tests/docs/bug-81.xml
rename to tests/general/bug-81.xml
diff --git a/tests/docs/bug-82.xml b/tests/general/bug-82.xml
similarity index 100%
rename from tests/docs/bug-82.xml
rename to tests/general/bug-82.xml
diff --git a/tests/docs/bug-83.xml b/tests/general/bug-83.xml
similarity index 100%
rename from tests/docs/bug-83.xml
rename to tests/general/bug-83.xml
diff --git a/tests/docs/bug-84.xml b/tests/general/bug-84.xml
similarity index 100%
rename from tests/docs/bug-84.xml
rename to tests/general/bug-84.xml
diff --git a/tests/docs/bug-86.xml b/tests/general/bug-86.xml
similarity index 100%
rename from tests/docs/bug-86.xml
rename to tests/general/bug-86.xml
diff --git a/tests/docs/bug-87.xml b/tests/general/bug-87.xml
similarity index 100%
rename from tests/docs/bug-87.xml
rename to tests/general/bug-87.xml
diff --git a/tests/docs/bug-88.xml b/tests/general/bug-88.xml
similarity index 100%
rename from tests/docs/bug-88.xml
rename to tests/general/bug-88.xml
diff --git a/tests/docs/bug-89.xml b/tests/general/bug-89.xml
similarity index 100%
rename from tests/docs/bug-89.xml
rename to tests/general/bug-89.xml
diff --git a/tests/docs/bug-9-.xml b/tests/general/bug-9-.xml
similarity index 100%
rename from tests/docs/bug-9-.xml
rename to tests/general/bug-9-.xml
diff --git a/tests/docs/bug-90.xml b/tests/general/bug-90.xml
similarity index 100%
rename from tests/docs/bug-90.xml
rename to tests/general/bug-90.xml
diff --git a/tests/docs/bug-91.xml b/tests/general/bug-91.xml
similarity index 100%
rename from tests/docs/bug-91.xml
rename to tests/general/bug-91.xml
diff --git a/tests/docs/bug-92.xml b/tests/general/bug-92.xml
similarity index 100%
rename from tests/docs/bug-92.xml
rename to tests/general/bug-92.xml
diff --git a/tests/docs/bug-93.xml b/tests/general/bug-93.xml
similarity index 100%
rename from tests/docs/bug-93.xml
rename to tests/general/bug-93.xml
diff --git a/tests/docs/bug-94.xml b/tests/general/bug-94.xml
similarity index 100%
rename from tests/docs/bug-94.xml
rename to tests/general/bug-94.xml
diff --git a/tests/docs/bug-95.xml b/tests/general/bug-95.xml
similarity index 100%
rename from tests/docs/bug-95.xml
rename to tests/general/bug-95.xml
diff --git a/tests/docs/bug-96.xml b/tests/general/bug-96.xml
similarity index 100%
rename from tests/docs/bug-96.xml
rename to tests/general/bug-96.xml
diff --git a/tests/docs/bug-97.xml b/tests/general/bug-97.xml
similarity index 100%
rename from tests/docs/bug-97.xml
rename to tests/general/bug-97.xml
diff --git a/tests/docs/bug-98.xml b/tests/general/bug-98.xml
similarity index 100%
rename from tests/docs/bug-98.xml
rename to tests/general/bug-98.xml
diff --git a/tests/docs/bug-99.xml b/tests/general/bug-99.xml
similarity index 100%
rename from tests/docs/bug-99.xml
rename to tests/general/bug-99.xml
diff --git a/tests/docs/character.xml b/tests/general/character.xml
similarity index 100%
rename from tests/docs/character.xml
rename to tests/general/character.xml
diff --git a/tests/docs/date_add.xml b/tests/general/date_add.xml
similarity index 100%
rename from tests/docs/date_add.xml
rename to tests/general/date_add.xml
diff --git a/tests/REC1/doc.dtd b/tests/general/doc.dtd
similarity index 100%
rename from tests/REC1/doc.dtd
rename to tests/general/doc.dtd
diff --git a/tests/REC1/result.xml b/tests/general/doc.out
similarity index 100%
rename from tests/REC1/result.xml
rename to tests/general/doc.out
diff --git a/tests/REC1/doc.xml b/tests/general/doc.xml
similarity index 100%
rename from tests/REC1/doc.xml
rename to tests/general/doc.xml
diff --git a/tests/REC1/doc.xsl b/tests/general/doc.xsl
similarity index 100%
rename from tests/REC1/doc.xsl
rename to tests/general/doc.xsl
diff --git a/tests/docs/items.xml b/tests/general/items.xml
similarity index 100%
rename from tests/docs/items.xml
rename to tests/general/items.xml
diff --git a/tests/keys/month.out b/tests/keys/dates.out
similarity index 100%
rename from tests/keys/month.out
rename to tests/keys/dates.out
diff --git a/tests/keys/month.xsl b/tests/keys/dates.xsl
similarity index 100%
rename from tests/keys/month.xsl
rename to tests/keys/dates.xsl
diff --git a/tests/multiple/Makefile.am b/tests/multiple/Makefile.am
index 1c40c2d5..d02a4bef 100644
--- a/tests/multiple/Makefile.am
+++ b/tests/multiple/Makefile.am
@@ -30,11 +30,7 @@ GENERATED = \
 
 CLEANFILES = .memdump
 
-valgrind:
-       @echo '## Running the regression tests under Valgrind'
-       $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests
-
-test tests: $(top_builddir)/xsltproc/xsltproc
+check-local: $(top_builddir)/xsltproc/xsltproc
        @echo '## Running multiple tests'
        @(echo > .memdump)
        @($(CHECKER) $(top_builddir)/xsltproc/xsltproc $(srcdir)/dict.xsl $(srcdir)/dict.xml > dict.res ; \
diff --git a/tests/runtest.c b/tests/runtest.c
new file mode 100644
index 00000000..197acaf5
--- /dev/null
+++ b/tests/runtest.c
@@ -0,0 +1,866 @@
+/*
+ * runtest.c: libxslt test suite
+ *
+ * See Copyright for the status of this software.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#ifdef _WIN32
+  #define WIN32_LEAN_AND_MEAN
+  #include <windows.h>
+  #include <io.h>
+#else
+  #include <unistd.h>
+  #include <glob.h>
+#endif
+
+#include <libxml/parser.h>
+#include <libxslt/extensions.h>
+#include <libxslt/transform.h>
+#include <libxslt/xsltInternals.h>
+#include <libxslt/xsltutils.h>
+#include <libexslt/exslt.h>
+
+/*
+ * O_BINARY is just for Windows compatibility - if it isn't defined
+ * on this system, avoid any compilation error
+ */
+#ifdef O_BINARY
+#define RD_FLAGS       O_RDONLY | O_BINARY
+#define WR_FLAGS       O_WRONLY | O_CREAT | O_TRUNC | O_BINARY
+#else
+#define RD_FLAGS       O_RDONLY
+#define WR_FLAGS       O_WRONLY | O_CREAT | O_TRUNC
+#endif
+
+typedef int (*functest) (const char *filename, int options);
+
+typedef struct testDesc testDesc;
+typedef testDesc *testDescPtr;
+struct testDesc {
+    const char *desc; /* description of the test */
+    functest    func; /* function implementing the test */
+    const char *dir;  /* directory to change to */
+    const char *in;   /* glob to path for input files */
+    int     options;  /* parser options for the test */
+};
+
+static int update_results = 0;
+static char* temp_directory = NULL;
+static int checkTestFile(const char *filename);
+
+#if defined(_WIN32)
+
+typedef struct
+{
+      size_t gl_pathc;    /* Count of paths matched so far  */
+      char **gl_pathv;    /* List of matched pathnames.  */
+      size_t gl_offs;     /* Slots to reserve in 'gl_pathv'.  */
+} glob_t;
+
+#define GLOB_DOOFFS 0
+static int glob(const char *pattern, ATTRIBUTE_UNUSED int flags,
+                ATTRIBUTE_UNUSED int errfunc(const char *epath, int eerrno),
+                glob_t *pglob) {
+    glob_t *ret;
+    WIN32_FIND_DATA FindFileData;
+    HANDLE hFind;
+    unsigned int nb_paths = 0;
+    char directory[500];
+    int len;
+
+    if ((pattern == NULL) || (pglob == NULL)) return(-1);
+
+    strncpy(directory, pattern, 499);
+    for (len = strlen(directory);len >= 0;len--) {
+        if (directory[len] == '/') {
+           len++;
+           directory[len] = 0;
+           break;
+       }
+    }
+    if (len <= 0)
+        len = 0;
+
+
+    ret = pglob;
+    memset(ret, 0, sizeof(glob_t));
+
+    hFind = FindFirstFileA(pattern, &FindFileData);
+    if (hFind == INVALID_HANDLE_VALUE)
+        return(0);
+    nb_paths = 20;
+    ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *));
+    if (ret->gl_pathv == NULL) {
+       FindClose(hFind);
+        return(-1);
+    }
+    strncpy(directory + len, FindFileData.cFileName, 499 - len);
+    ret->gl_pathv[ret->gl_pathc] = strdup(directory);
+    if (ret->gl_pathv[ret->gl_pathc] == NULL)
+        goto done;
+    ret->gl_pathc++;
+    while(FindNextFileA(hFind, &FindFileData)) {
+        if (FindFileData.cFileName[0] == '.')
+           continue;
+        if (ret->gl_pathc + 2 > nb_paths) {
+            char **tmp = realloc(ret->gl_pathv, nb_paths * 2 * sizeof(char *));
+            if (tmp == NULL)
+                break;
+            ret->gl_pathv = tmp;
+            nb_paths *= 2;
+       }
+       strncpy(directory + len, FindFileData.cFileName, 499 - len);
+       ret->gl_pathv[ret->gl_pathc] = strdup(directory);
+        if (ret->gl_pathv[ret->gl_pathc] == NULL)
+            break;
+        ret->gl_pathc++;
+    }
+    ret->gl_pathv[ret->gl_pathc] = NULL;
+
+done:
+    FindClose(hFind);
+    return(0);
+}
+
+
+
+static void globfree(glob_t *pglob) {
+    unsigned int i;
+    if (pglob == NULL)
+        return;
+
+    for (i = 0;i < pglob->gl_pathc;i++) {
+         if (pglob->gl_pathv[i] != NULL)
+             free(pglob->gl_pathv[i]);
+    }
+}
+
+#endif
+
+/************************************************************************
+ *                                                                     *
+ *             Libxml2 specific routines                               *
+ *                                                                     *
+ ************************************************************************/
+
+static int nb_tests = 0;
+static int nb_errors = 0;
+static int nb_leaks = 0;
+
+static int
+fatalError(void) {
+    fprintf(stderr, "Exiting tests on fatal error\n");
+    exit(1);
+}
+
+/*
+ * Trapping the error messages at the generic level to grab the equivalent of
+ * stderr messages on CLI tools.
+ */
+static char testErrors[32769];
+static int testErrorsSize = 0;
+
+static void XMLCDECL
+testErrorHandler(void *ctx  ATTRIBUTE_UNUSED, const char *msg, ...) {
+    va_list args;
+    int res;
+
+    if (testErrorsSize >= 32768)
+        return;
+    va_start(args, msg);
+    res = vsnprintf(&testErrors[testErrorsSize],
+                    32768 - testErrorsSize,
+                   msg, args);
+    va_end(args);
+    if (testErrorsSize + res >= 32768) {
+        /* buffer is full */
+       testErrorsSize = 32768;
+       testErrors[testErrorsSize] = 0;
+    } else {
+        testErrorsSize += res;
+    }
+    testErrors[testErrorsSize] = 0;
+}
+
+static void XMLCDECL
+channel(void *ctx  ATTRIBUTE_UNUSED, const char *msg, ...) {
+    va_list args;
+    int res;
+
+    if (testErrorsSize >= 32768)
+        return;
+    va_start(args, msg);
+    res = vsnprintf(&testErrors[testErrorsSize],
+                    32768 - testErrorsSize,
+                   msg, args);
+    va_end(args);
+    if (testErrorsSize + res >= 32768) {
+        /* buffer is full */
+       testErrorsSize = 32768;
+       testErrors[testErrorsSize] = 0;
+    } else {
+        testErrorsSize += res;
+    }
+    testErrors[testErrorsSize] = 0;
+}
+
+/**
+ * xmlParserPrintFileContext:
+ * @input:  an xmlParserInputPtr input
+ *
+ * Displays current context within the input content for error tracking
+ */
+
+static void
+xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
+               xmlGenericErrorFunc chanl, void *data ) {
+    const xmlChar *cur, *base;
+    unsigned int n, col;       /* GCC warns if signed, because compared with sizeof() */
+    xmlChar  content[81]; /* space for 80 chars + line terminator */
+    xmlChar *ctnt;
+
+    if (input == NULL) return;
+    cur = input->cur;
+    base = input->base;
+    /* skip backwards over any end-of-lines */
+    while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) {
+       cur--;
+    }
+    n = 0;
+    /* search backwards for beginning-of-line (to max buff size) */
+    while ((n++ < (sizeof(content)-1)) && (cur > base) &&
+   (*(cur) != '\n') && (*(cur) != '\r'))
+        cur--;
+    if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
+    /* calculate the error position in terms of the current position */
+    col = input->cur - cur;
+    /* search forward for end-of-line (to max buff size) */
+    n = 0;
+    ctnt = content;
+    /* copy selected text to our buffer */
+    while ((*cur != 0) && (*(cur) != '\n') &&
+   (*(cur) != '\r') && (n < sizeof(content)-1)) {
+               *ctnt++ = *cur++;
+       n++;
+    }
+    *ctnt = 0;
+    /* print out the selected text */
+    chanl(data ,"%s\n", content);
+    /* create blank line with problem pointer */
+    n = 0;
+    ctnt = content;
+    /* (leave buffer space for pointer + line terminator) */
+    while ((n<col) && (n++ < sizeof(content)-2) && (*ctnt != 0)) {
+       if (*(ctnt) != '\t')
+           *(ctnt) = ' ';
+       ctnt++;
+    }
+    *ctnt++ = '^';
+    *ctnt = 0;
+    chanl(data ,"%s\n", content);
+}
+
+static void
+testStructuredErrorHandler(void *ctx  ATTRIBUTE_UNUSED, xmlErrorPtr err) {
+    char *file = NULL;
+    int line = 0;
+    int code = -1;
+    int domain;
+    void *data = NULL;
+    const char *str;
+    const xmlChar *name = NULL;
+    xmlNodePtr node;
+    xmlErrorLevel level;
+    xmlParserInputPtr input = NULL;
+    xmlParserInputPtr cur = NULL;
+    xmlParserCtxtPtr ctxt = NULL;
+
+    if (err == NULL)
+        return;
+
+    file = err->file;
+    line = err->line;
+    code = err->code;
+    domain = err->domain;
+    level = err->level;
+    node = err->node;
+    if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) ||
+        (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) ||
+       (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
+       ctxt = err->ctxt;
+    }
+    str = err->message;
+
+    if (code == XML_ERR_OK)
+        return;
+
+    if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
+        name = node->name;
+
+    /*
+     * Maintain the compatibility with the legacy error handling
+     */
+    if (ctxt != NULL) {
+        input = ctxt->input;
+        if ((input != NULL) && (input->filename == NULL) &&
+            (ctxt->inputNr > 1)) {
+            cur = input;
+            input = ctxt->inputTab[ctxt->inputNr - 2];
+        }
+        if (input != NULL) {
+            if (input->filename)
+                channel(data, "%s:%d: ", input->filename, input->line);
+            else if ((line != 0) && (domain == XML_FROM_PARSER))
+                channel(data, "Entity: line %d: ", input->line);
+        }
+    } else {
+        if (file != NULL)
+            channel(data, "%s:%d: ", file, line);
+        else if ((line != 0) && (domain == XML_FROM_PARSER))
+            channel(data, "Entity: line %d: ", line);
+    }
+    if (name != NULL) {
+        channel(data, "element %s: ", name);
+    }
+    if (code == XML_ERR_OK)
+        return;
+    switch (domain) {
+        case XML_FROM_PARSER:
+            channel(data, "parser ");
+            break;
+        case XML_FROM_NAMESPACE:
+            channel(data, "namespace ");
+            break;
+        case XML_FROM_DTD:
+        case XML_FROM_VALID:
+            channel(data, "validity ");
+            break;
+        case XML_FROM_HTML:
+            channel(data, "HTML parser ");
+            break;
+        case XML_FROM_MEMORY:
+            channel(data, "memory ");
+            break;
+        case XML_FROM_OUTPUT:
+            channel(data, "output ");
+            break;
+        case XML_FROM_IO:
+            channel(data, "I/O ");
+            break;
+        case XML_FROM_XINCLUDE:
+            channel(data, "XInclude ");
+            break;
+        case XML_FROM_XPATH:
+            channel(data, "XPath ");
+            break;
+        case XML_FROM_XPOINTER:
+            channel(data, "parser ");
+            break;
+        case XML_FROM_REGEXP:
+            channel(data, "regexp ");
+            break;
+        case XML_FROM_MODULE:
+            channel(data, "module ");
+            break;
+        case XML_FROM_SCHEMASV:
+            channel(data, "Schemas validity ");
+            break;
+        case XML_FROM_SCHEMASP:
+            channel(data, "Schemas parser ");
+            break;
+        case XML_FROM_RELAXNGP:
+            channel(data, "Relax-NG parser ");
+            break;
+        case XML_FROM_RELAXNGV:
+            channel(data, "Relax-NG validity ");
+            break;
+        case XML_FROM_CATALOG:
+            channel(data, "Catalog ");
+            break;
+        case XML_FROM_C14N:
+            channel(data, "C14N ");
+            break;
+        case XML_FROM_XSLT:
+            channel(data, "XSLT ");
+            break;
+        default:
+            break;
+    }
+    if (code == XML_ERR_OK)
+        return;
+    switch (level) {
+        case XML_ERR_NONE:
+            channel(data, ": ");
+            break;
+        case XML_ERR_WARNING:
+            channel(data, "warning : ");
+            break;
+        case XML_ERR_ERROR:
+            channel(data, "error : ");
+            break;
+        case XML_ERR_FATAL:
+            channel(data, "error : ");
+            break;
+    }
+    if (code == XML_ERR_OK)
+        return;
+    if (str != NULL) {
+        int len;
+       len = xmlStrlen((const xmlChar *)str);
+       if ((len > 0) && (str[len - 1] != '\n'))
+           channel(data, "%s\n", str);
+       else
+           channel(data, "%s", str);
+    } else {
+        channel(data, "%s\n", "out of memory error");
+    }
+    if (code == XML_ERR_OK)
+        return;
+
+    if (ctxt != NULL) {
+        xmlParserPrintFileContextInternal(input, channel, data);
+        if (cur != NULL) {
+            if (cur->filename)
+                channel(data, "%s:%d: \n", cur->filename, cur->line);
+            else if ((line != 0) && (domain == XML_FROM_PARSER))
+                channel(data, "Entity: line %d: \n", cur->line);
+            xmlParserPrintFileContextInternal(cur, channel, data);
+        }
+    }
+    if ((domain == XML_FROM_XPATH) && (err->str1 != NULL) &&
+        (err->int1 < 100) &&
+       (err->int1 < xmlStrlen((const xmlChar *)err->str1))) {
+       xmlChar buf[150];
+       int i;
+
+       channel(data, "%s\n", err->str1);
+       for (i=0;i < err->int1;i++)
+            buf[i] = ' ';
+       buf[i++] = '^';
+       buf[i] = 0;
+       channel(data, "%s\n", buf);
+    }
+}
+
+static void
+initializeLibxml2(void) {
+    xmlInitParser();
+    xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
+    xmlSetGenericErrorFunc(NULL, testErrorHandler);
+    xsltSetGenericErrorFunc(NULL, testErrorHandler);
+    xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
+    exsltRegisterAll();
+    xsltRegisterTestModule();
+    xsltMaxDepth = 200;
+}
+
+
+/************************************************************************
+ *                                                                     *
+ *             File name and path utilities                            *
+ *                                                                     *
+ ************************************************************************/
+
+static char *
+changeSuffix(const char *filename, const char *suffix) {
+    const char *dot;
+    char *ret;
+    char res[500];
+    int baseLen;
+
+    dot = strrchr(filename, '.');
+    baseLen = dot ? dot - filename : (int) strlen(filename);
+    snprintf(res, sizeof(res), "%.*s%s", baseLen, filename, suffix);
+
+    ret = strdup(res);
+    if (ret == NULL) {
+        fprintf(stderr, "strdup failed\n");
+        fatalError();
+    }
+
+    return(ret);
+}
+
+static int
+checkTestFile(const char *filename) {
+    struct stat buf;
+
+    if (stat(filename, &buf) == -1)
+        return(0);
+
+#if defined(_WIN32)
+    if (!(buf.st_mode & _S_IFREG))
+        return(0);
+#else
+    if (!S_ISREG(buf.st_mode))
+        return(0);
+#endif
+
+    return(1);
+}
+
+static int compareFileMem(const char *filename, const char *mem, int size) {
+    int res;
+    int fd;
+    char bytes[4096];
+    int idx = 0;
+    struct stat info;
+
+    if (update_results) {
+        if (size == 0) {
+            unlink(filename);
+            return(0);
+        }
+        fd = open(filename, WR_FLAGS, 0644);
+        if (fd < 0) {
+           fprintf(stderr, "failed to open %s for writing", filename);
+            return(-1);
+       }
+        res = write(fd, mem, size);
+        close(fd);
+        return(res != size);
+    }
+
+    if (stat(filename, &info) < 0) {
+        if (size == 0)
+            return(0);
+        fprintf(stderr, "failed to stat %s\n", filename);
+       return(-1);
+    }
+    if (info.st_size != size) {
+        fprintf(stderr, "file %s is %ld bytes, result is %d bytes\n",
+               filename, (long) info.st_size, size);
+        return(-1);
+    }
+    fd = open(filename, RD_FLAGS);
+    if (fd < 0) {
+       fprintf(stderr, "failed to open %s for reading", filename);
+        return(-1);
+    }
+    while (idx < size) {
+        res = read(fd, bytes, 4096);
+       if (res <= 0)
+           break;
+       if (res + idx > size)
+           break;
+       if (memcmp(bytes, &mem[idx], res) != 0) {
+           int ix;
+           for (ix=0; ix<res; ix++)
+               if (bytes[ix] != mem[idx+ix])
+                       break;
+           fprintf(stderr,"Compare error at position %d\n", idx+ix);
+           close(fd);
+           return(1);
+       }
+       idx += res;
+    }
+    close(fd);
+    if (idx != size) {
+       fprintf(stderr,"Compare error index %d, size %d\n", idx, size);
+    }
+    return(idx != size);
+}
+
+/************************************************************************
+ *                                                                     *
+ *             Tests implementations                                   *
+ *                                                                     *
+ ************************************************************************/
+
+/************************************************************************
+ *                                                                     *
+ *             XSLT tests                                              *
+ *                                                                     *
+ ************************************************************************/
+
+static int
+xsltTest(const char *filename, int options) {
+    xsltStylesheetPtr style;
+    xmlDocPtr styleDoc, doc, outDoc;
+    xmlChar *out = NULL;
+    const char *outSuffix, *errSuffix;
+    char *docFilename, *outFilename, *errFilename;
+    int outSize = 0;
+    int res;
+    int ret = 0;
+
+    styleDoc = xmlReadFile(filename, NULL, XSLT_PARSE_OPTIONS | options);
+    style = xsltLoadStylesheetPI(styleDoc);
+    if (style != NULL) {
+        /* Standalone stylesheet */
+        doc = styleDoc;
+        docFilename = strdup(filename);
+
+        outSuffix = ".stand.out";
+        errSuffix = ".stand.err";
+    } else {
+        docFilename = changeSuffix(filename, ".xml");
+        if (!checkTestFile(docFilename)) {
+            goto out;
+        }
+        style = xsltParseStylesheetDoc(styleDoc);
+        if (style == NULL) {
+            xmlFreeDoc(styleDoc);
+        } else {
+            doc = xmlReadFile(docFilename, NULL, XSLT_PARSE_OPTIONS | options);
+        }
+
+        outSuffix = ".out";
+        errSuffix = ".err";
+    }
+
+    if (style != NULL) {
+        const char *params[] = {
+            "test", "'passed_value'",
+            "test2", "'passed_value2'",
+            NULL
+        };
+
+        outDoc = xsltApplyStylesheet(style, doc, params);
+        if (outDoc == NULL) {
+            /* xsltproc compat */
+           channel(NULL, "no result for %s\n", docFilename);
+        } else {
+            xsltSaveResultToString(&out, &outSize, outDoc, style);
+            xmlFreeDoc(outDoc);
+        }
+        xsltFreeStylesheet(style);
+    }
+
+    outFilename = changeSuffix(filename, outSuffix);
+    res = compareFileMem(outFilename, (char *) out, outSize);
+    if (res != 0) {
+        fprintf(stderr, "Result for %s failed\n", filename);
+        /* printf("####\n%s####\n", out); */
+        ret = -1;
+    }
+    free(outFilename);
+    xmlFree(out);
+
+    errFilename = changeSuffix(filename, errSuffix);
+    res = compareFileMem(errFilename, testErrors, testErrorsSize);
+    if (res != 0) {
+        fprintf(stderr, "Error for %s failed\n", filename);
+        /* printf("####\n%s####\n", testErrors); */
+        ret = -1;
+    }
+    free(errFilename);
+
+out:
+    free(docFilename);
+    return(ret);
+}
+
+/************************************************************************
+ *                                                                     *
+ *                     Tests Descriptions                              *
+ *                                                                     *
+ ************************************************************************/
+
+static
+testDesc testDescriptions[] = {
+    { "REC2 tests",
+      xsltTest, "REC2", "./*.xsl", 0 },
+    { "REC tests",
+      xsltTest, "REC", "./*.xsl", 0 },
+    { "REC tests (standalone)",
+      xsltTest, "REC", "./stand*.xml", 0 },
+    { "REC tests without dictionaries",
+      xsltTest, "REC", "./*.xsl", XML_PARSE_NODICT },
+    { "REC tests without dictionaries (standalone)",
+      xsltTest, "REC", "./stand*.xml", XML_PARSE_NODICT },
+    { "general tests",
+      xsltTest, "general", "./*.xsl", 0 },
+    { "general tests without dictionaries",
+      xsltTest, "general", "./*.xsl", XML_PARSE_NODICT },
+    { "documents tests",
+      xsltTest, "documents", "./*.xsl", 0 },
+    { "numbers tests",
+      xsltTest, "numbers", "./*.xsl", 0 },
+    { "keys tests",
+      xsltTest, "keys", "./*.xsl", 0 },
+    { "namespaces tests",
+      xsltTest, "namespaces", "./*.xsl", 0 },
+    { "extensions tests",
+      xsltTest, "extensions", "./*.xsl", 0 },
+    { "reports tests",
+      xsltTest, "reports", "./*.xsl", 0 },
+    { "exslt common tests",
+      xsltTest, "exslt/common", "./*.xsl", 0 },
+#if defined(EXSLT_CRYPTO_ENABLED) && !defined(_WIN32)
+    { "exslt crypto tests",
+      xsltTest, "exslt/crypto", "./*.xsl", 0 },
+#endif
+    { "exslt date tests",
+      xsltTest, "exslt/date", "./*.xsl", 0 },
+    { "exslt dynamic tests",
+      xsltTest, "exslt/dynamic", "./*.xsl", 0 },
+    { "exslt functions tests",
+      xsltTest, "exslt/functions", "./*.xsl", 0 },
+    { "exslt math tests",
+      xsltTest, "exslt/math", "./*.xsl", 0 },
+    { "exslt saxon tests",
+      xsltTest, "exslt/saxon", "./*.xsl", 0 },
+    { "exslt sets tests",
+      xsltTest, "exslt/sets", "./*.xsl", 0 },
+    { "exslt strings tests",
+      xsltTest, "exslt/strings", "./*.xsl", 0 },
+#ifdef LIBXSLT_DEFAULT_PLUGINS_PATH
+    { "plugin tests",
+      xsltTest, "plugins", "./*.xsl", 0 },
+#endif
+    {NULL, NULL, NULL, NULL, 0}
+};
+
+/************************************************************************
+ *                                                                     *
+ *             The main code driving the tests                         *
+ *                                                                     *
+ ************************************************************************/
+
+static int
+launchTests(testDescPtr tst) {
+    int res = 0, err = 0;
+    size_t i;
+    char oldDir[500] = {0};
+
+    if (tst->dir) {
+        if (getcwd(oldDir, sizeof(oldDir)) == NULL) {
+            fprintf(stderr, "Can't can't get current directory\n");
+           nb_errors++;
+            return(1);
+        }
+        if (chdir(tst->dir) < 0) {
+            fprintf(stderr, "Can't change directory to %s\n", tst->dir);
+           nb_errors++;
+            return(1);
+        }
+    }
+
+    if (tst->in != NULL) {
+       glob_t globbuf;
+
+       globbuf.gl_offs = 0;
+       glob(tst->in, GLOB_DOOFFS, NULL, &globbuf);
+       for (i = 0;i < globbuf.gl_pathc;i++) {
+            testErrorsSize = 0;
+            testErrors[0] = 0;
+            nb_tests++;
+            res = tst->func(globbuf.gl_pathv[i], tst->options);
+            xmlResetLastError();
+            if (res != 0) {
+                fprintf(stderr, "File %s generated an error\n",
+                        globbuf.gl_pathv[i]);
+                nb_errors++;
+                err++;
+            }
+            testErrorsSize = 0;
+       }
+       globfree(&globbuf);
+    } else {
+        testErrorsSize = 0;
+       testErrors[0] = 0;
+        nb_tests++;
+        res = tst->func(NULL, tst->options);
+       if (res != 0) {
+           nb_errors++;
+           err++;
+       }
+    }
+
+    if (oldDir[0] && chdir(oldDir) < 0) {
+        fprintf(stderr, "Can't change directory to %s\n", oldDir);
+       nb_errors++;
+        err++;
+    }
+
+    return(err);
+}
+
+static int verbose = 0;
+static int tests_quiet = 0;
+
+static int
+runtest(int i) {
+    int ret = 0, res;
+    int old_errors, old_tests, old_leaks;
+
+    old_errors = nb_errors;
+    old_tests = nb_tests;
+    old_leaks = nb_leaks;
+    if ((tests_quiet == 0) && (testDescriptions[i].desc != NULL))
+       printf("## Running %s\n", testDescriptions[i].desc);
+    res = launchTests(&testDescriptions[i]);
+    if (res != 0)
+       ret++;
+    if (verbose) {
+       if ((nb_errors == old_errors) && (nb_leaks == old_leaks))
+           printf("Ran %d tests, no errors\n", nb_tests - old_tests);
+       else
+           printf("Ran %d tests, %d errors, %d leaks\n",
+                  nb_tests - old_tests,
+                  nb_errors - old_errors,
+                  nb_leaks - old_leaks);
+    }
+    return(ret);
+}
+
+int
+main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
+    int i, a, ret = 0;
+    int subset = 0;
+
+#if defined(_WIN32)
+    setvbuf(stdout, NULL, _IONBF, 0);
+    setvbuf(stderr, NULL, _IONBF, 0);
+#endif
+
+#if defined(_MSC_VER) && _MSC_VER >= 1400 && _MSC_VER < 1900
+    _set_output_format(_TWO_DIGIT_EXPONENT);
+#endif
+
+    initializeLibxml2();
+
+    for (a = 1; a < argc;a++) {
+        if (!strcmp(argv[a], "-v"))
+           verbose = 1;
+        else if (!strcmp(argv[a], "-u"))
+           update_results = 1;
+        else if (!strcmp(argv[a], "-quiet"))
+           tests_quiet = 1;
+        else if (!strcmp(argv[a], "--out"))
+           temp_directory = argv[++a];
+       else {
+           for (i = 0; testDescriptions[i].func != NULL; i++) {
+               if (strstr(testDescriptions[i].desc, argv[a])) {
+                   ret += runtest(i);
+                   subset++;
+               }
+           }
+       }
+    }
+    if (subset == 0) {
+       for (i = 0; testDescriptions[i].func != NULL; i++) {
+           ret += runtest(i);
+       }
+    }
+    if ((nb_errors == 0) && (nb_leaks == 0)) {
+        ret = 0;
+       printf("Total %d tests, no errors\n",
+              nb_tests);
+    } else {
+        ret = 1;
+       printf("Total %d tests, %d errors, %d leaks\n",
+              nb_tests, nb_errors, nb_leaks);
+    }
+    xmlCleanupParser();
+
+    return(ret);
+}
diff --git a/tests/plugins/testplugin.c b/tests/testplugin.c
similarity index 100%
rename from tests/plugins/testplugin.c
rename to tests/testplugin.c
diff --git a/tests/xinclude/Makefile.am b/tests/xinclude/Makefile.am
index 35624548..81b67241 100644
--- a/tests/xinclude/Makefile.am
+++ b/tests/xinclude/Makefile.am
@@ -13,11 +13,7 @@ EXTRA_DIST =         \
 
 CLEANFILES = .memdump
 
-valgrind:
-       @echo '## Running the regression tests under Valgrind'
-       $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests
-
-test tests: $(top_builddir)/xsltproc/xsltproc
+check-local: $(top_builddir)/xsltproc/xsltproc
        @echo '## Running XInclude test'
        @(echo > .memdump)
        @($(CHECKER) $(top_builddir)/xsltproc/xsltproc $(srcdir)/e.xsl $(srcdir)/e.xml > res ; \
diff --git a/tests/xmlspec/Makefile.am b/tests/xmlspec/Makefile.am
index 9770058c..8b813293 100644
--- a/tests/xmlspec/Makefile.am
+++ b/tests/xmlspec/Makefile.am
@@ -9,11 +9,7 @@ EXTRA_DIST = REC-xml-20001006.xml xmlspec-v21.dtd W3C-REC.css \
 
 CLEANFILES = .memdump debug
 
-valgrind:
-       @echo '## Running the regression tests under Valgrind'
-       $(MAKE) CHECKER='libtool --mode=execute valgrind -q --leak-check=full' tests
-
-test tests: $(top_builddir)/xsltproc/xsltproc
+check-local: $(top_builddir)/xsltproc/xsltproc
        @echo '## Running xmlspec tests'
        @(echo > .memdump)
        @log=`$(CHECKER) $(top_builddir)/xsltproc/xsltproc -timing \
diff --git a/xsltproc/Makefile.am b/xsltproc/Makefile.am
index 3f7c24ee..bf2d5f58 100644
--- a/xsltproc/Makefile.am
+++ b/xsltproc/Makefile.am
@@ -2,10 +2,9 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/libxslt -I$(top_srcdir)/libexslt \
              -I$(top_builddir) -I$(top_builddir)/libxslt \
              -I$(top_builddir)/libexslt
 
-EXTRA_PROGRAMS=
 bin_PROGRAMS = xsltproc
 
-noinst_PROGRAMS=testThreads
+check_PROGRAMS = testThreads
 
 xsltproc_SOURCES = xsltproc.c
 xsltproc_LDFLAGS = 
@@ -33,7 +32,7 @@ $(top_builddir)/libxslt/libxslt.la:
 $(top_builddir)/libexslt/libexslt.la: $(top_builddir)/libxslt/libxslt.la
        cd $(top_builddir)/libexslt && $(MAKE) libexslt.la
 
-tests: testThreads
+check-local:
        @echo > .memdump
        @echo '## Running testThreads'
        @($(CHECKER) ./testThreads > /dev/null; grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0" 
|| true)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]