From 35a201cc8ef0c3f5b2df88d2e528aabee1048348 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Fri, 30 Apr 2021 18:47:09 +0200 Subject: Initial/Final commit --- libxml2-2.9.10/python/tests/Makefile.am | 78 +++ libxml2-2.9.10/python/tests/Makefile.in | 688 ++++++++++++++++++++++++++ libxml2-2.9.10/python/tests/attribs.py | 34 ++ libxml2-2.9.10/python/tests/build.py | 59 +++ libxml2-2.9.10/python/tests/compareNodes.py | 50 ++ libxml2-2.9.10/python/tests/ctxterror.py | 56 +++ libxml2-2.9.10/python/tests/cutnpaste.py | 48 ++ libxml2-2.9.10/python/tests/dtdvalid.py | 32 ++ libxml2-2.9.10/python/tests/error.py | 51 ++ libxml2-2.9.10/python/tests/inbuf.py | 30 ++ libxml2-2.9.10/python/tests/indexes.py | 113 +++++ libxml2-2.9.10/python/tests/input_callback.py | 148 ++++++ libxml2-2.9.10/python/tests/invalid.xml | 6 + libxml2-2.9.10/python/tests/nsdel.py | 62 +++ libxml2-2.9.10/python/tests/outbuf.py | 110 ++++ libxml2-2.9.10/python/tests/push.py | 35 ++ libxml2-2.9.10/python/tests/pushSAX.py | 64 +++ libxml2-2.9.10/python/tests/pushSAXhtml.py | 65 +++ libxml2-2.9.10/python/tests/reader.py | 446 +++++++++++++++++ libxml2-2.9.10/python/tests/reader2.py | 265 ++++++++++ libxml2-2.9.10/python/tests/reader3.py | 160 ++++++ libxml2-2.9.10/python/tests/reader4.py | 50 ++ libxml2-2.9.10/python/tests/reader5.py | 47 ++ libxml2-2.9.10/python/tests/reader6.py | 128 +++++ libxml2-2.9.10/python/tests/reader7.py | 101 ++++ libxml2-2.9.10/python/tests/reader8.py | 36 ++ libxml2-2.9.10/python/tests/readererr.py | 56 +++ libxml2-2.9.10/python/tests/readernext.py | 86 ++++ libxml2-2.9.10/python/tests/regexp.py | 32 ++ libxml2-2.9.10/python/tests/relaxng.py | 48 ++ libxml2-2.9.10/python/tests/resolver.py | 44 ++ libxml2-2.9.10/python/tests/schema.py | 52 ++ libxml2-2.9.10/python/tests/serialize.py | 150 ++++++ libxml2-2.9.10/python/tests/sync.py | 138 ++++++ libxml2-2.9.10/python/tests/test.dtd | 1 + libxml2-2.9.10/python/tests/thread2.py | 99 ++++ libxml2-2.9.10/python/tests/tst.py | 28 ++ libxml2-2.9.10/python/tests/tst.xml | 1 + libxml2-2.9.10/python/tests/tstLastError.py | 82 +++ libxml2-2.9.10/python/tests/tstURI.py | 41 ++ libxml2-2.9.10/python/tests/tstmem.py | 36 ++ libxml2-2.9.10/python/tests/tstxpath.py | 63 +++ libxml2-2.9.10/python/tests/valid.xml | 4 + libxml2-2.9.10/python/tests/validDTD.py | 59 +++ libxml2-2.9.10/python/tests/validRNG.py | 76 +++ libxml2-2.9.10/python/tests/validSchemas.py | 83 ++++ libxml2-2.9.10/python/tests/validate.py | 82 +++ libxml2-2.9.10/python/tests/walker.py | 144 ++++++ libxml2-2.9.10/python/tests/xpath.py | 51 ++ libxml2-2.9.10/python/tests/xpathext.py | 49 ++ libxml2-2.9.10/python/tests/xpathleak.py | 55 ++ libxml2-2.9.10/python/tests/xpathns.py | 29 ++ libxml2-2.9.10/python/tests/xpathret.py | 57 +++ 53 files changed, 4608 insertions(+) create mode 100644 libxml2-2.9.10/python/tests/Makefile.am create mode 100644 libxml2-2.9.10/python/tests/Makefile.in create mode 100755 libxml2-2.9.10/python/tests/attribs.py create mode 100755 libxml2-2.9.10/python/tests/build.py create mode 100755 libxml2-2.9.10/python/tests/compareNodes.py create mode 100755 libxml2-2.9.10/python/tests/ctxterror.py create mode 100755 libxml2-2.9.10/python/tests/cutnpaste.py create mode 100755 libxml2-2.9.10/python/tests/dtdvalid.py create mode 100755 libxml2-2.9.10/python/tests/error.py create mode 100755 libxml2-2.9.10/python/tests/inbuf.py create mode 100755 libxml2-2.9.10/python/tests/indexes.py create mode 100755 libxml2-2.9.10/python/tests/input_callback.py create mode 100644 libxml2-2.9.10/python/tests/invalid.xml create mode 100755 libxml2-2.9.10/python/tests/nsdel.py create mode 100755 libxml2-2.9.10/python/tests/outbuf.py create mode 100755 libxml2-2.9.10/python/tests/push.py create mode 100755 libxml2-2.9.10/python/tests/pushSAX.py create mode 100755 libxml2-2.9.10/python/tests/pushSAXhtml.py create mode 100755 libxml2-2.9.10/python/tests/reader.py create mode 100755 libxml2-2.9.10/python/tests/reader2.py create mode 100755 libxml2-2.9.10/python/tests/reader3.py create mode 100755 libxml2-2.9.10/python/tests/reader4.py create mode 100755 libxml2-2.9.10/python/tests/reader5.py create mode 100755 libxml2-2.9.10/python/tests/reader6.py create mode 100755 libxml2-2.9.10/python/tests/reader7.py create mode 100755 libxml2-2.9.10/python/tests/reader8.py create mode 100755 libxml2-2.9.10/python/tests/readererr.py create mode 100755 libxml2-2.9.10/python/tests/readernext.py create mode 100755 libxml2-2.9.10/python/tests/regexp.py create mode 100755 libxml2-2.9.10/python/tests/relaxng.py create mode 100755 libxml2-2.9.10/python/tests/resolver.py create mode 100755 libxml2-2.9.10/python/tests/schema.py create mode 100755 libxml2-2.9.10/python/tests/serialize.py create mode 100755 libxml2-2.9.10/python/tests/sync.py create mode 100644 libxml2-2.9.10/python/tests/test.dtd create mode 100755 libxml2-2.9.10/python/tests/thread2.py create mode 100755 libxml2-2.9.10/python/tests/tst.py create mode 100644 libxml2-2.9.10/python/tests/tst.xml create mode 100755 libxml2-2.9.10/python/tests/tstLastError.py create mode 100755 libxml2-2.9.10/python/tests/tstURI.py create mode 100755 libxml2-2.9.10/python/tests/tstmem.py create mode 100755 libxml2-2.9.10/python/tests/tstxpath.py create mode 100644 libxml2-2.9.10/python/tests/valid.xml create mode 100755 libxml2-2.9.10/python/tests/validDTD.py create mode 100755 libxml2-2.9.10/python/tests/validRNG.py create mode 100755 libxml2-2.9.10/python/tests/validSchemas.py create mode 100755 libxml2-2.9.10/python/tests/validate.py create mode 100755 libxml2-2.9.10/python/tests/walker.py create mode 100755 libxml2-2.9.10/python/tests/xpath.py create mode 100755 libxml2-2.9.10/python/tests/xpathext.py create mode 100755 libxml2-2.9.10/python/tests/xpathleak.py create mode 100755 libxml2-2.9.10/python/tests/xpathns.py create mode 100755 libxml2-2.9.10/python/tests/xpathret.py (limited to 'libxml2-2.9.10/python/tests') diff --git a/libxml2-2.9.10/python/tests/Makefile.am b/libxml2-2.9.10/python/tests/Makefile.am new file mode 100644 index 0000000..227e24d --- /dev/null +++ b/libxml2-2.9.10/python/tests/Makefile.am @@ -0,0 +1,78 @@ +exampledir = $(datadir)/doc/libxml2-python-$(LIBXML_VERSION)/examples +dist_example_DATA = $(PYTESTS) $(XMLS) + +PYTESTS= \ + build.py \ + attribs.py \ + tst.py \ + tstxpath.py \ + xpathext.py \ + push.py \ + pushSAX.py \ + pushSAXhtml.py \ + error.py \ + serialize.py\ + validate.py \ + tstURI.py \ + cutnpaste.py\ + xpathret.py \ + xpath.py \ + outbuf.py \ + inbuf.py \ + input_callback.py \ + resolver.py \ + regexp.py \ + reader.py \ + reader2.py \ + reader3.py \ + reader4.py \ + reader5.py \ + reader6.py \ + reader7.py \ + reader8.py \ + readernext.py \ + walker.py \ + nsdel.py \ + ctxterror.py\ + readererr.py\ + relaxng.py \ + schema.py \ + thread2.py \ + sync.py \ + tstLastError.py \ + indexes.py \ + dtdvalid.py \ + tstmem.py \ + validDTD.py \ + validSchemas.py \ + validRNG.py \ + compareNodes.py \ + xpathns.py \ + xpathleak.py + +XMLS= \ + tst.xml \ + valid.xml \ + invalid.xml \ + test.dtd + +CLEANFILES = core tmp.xml *.pyc + +if WITH_PYTHON +tests: $(PYTESTS) + @for f in $(XMLS) ; do test -f $$f || $(LN_S) $(srcdir)/$$f . ; done + @echo "## running Python regression tests" + @(export PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH" ; \ + export LD_LIBRARY_PATH="$(top_builddir)/.libs:$$LD_LIBRARY_PATH" ; \ + export PATH="$(top_builddir)/.libs:$$PATH" ; \ + for test in $(PYTESTS) ; do \ + log=`$(PYTHON) $(srcdir)/$$test` ; \ + if [ "$$?" -ne 0 ] ; then \ + echo "-- $$test" ; \ + echo "$$log" ; \ + exit 1 ; \ + fi ; \ + done) +else +tests: +endif diff --git a/libxml2-2.9.10/python/tests/Makefile.in b/libxml2-2.9.10/python/tests/Makefile.in new file mode 100644 index 0000000..b2a9da5 --- /dev/null +++ b/libxml2-2.9.10/python/tests/Makefile.in @@ -0,0 +1,688 @@ +# Makefile.in generated by automake 1.16.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2018 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = python/tests +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(dist_example_DATA) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(exampledir)" +DATA = $(dist_example_DATA) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_THREAD_LIBS = @BASE_THREAD_LIBS@ +C14N_OBJ = @C14N_OBJ@ +CATALOG_OBJ = @CATALOG_OBJ@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +CYGWIN_EXTRA_LDFLAGS = @CYGWIN_EXTRA_LDFLAGS@ +CYGWIN_EXTRA_PYTHON_LIBADD = @CYGWIN_EXTRA_PYTHON_LIBADD@ +DEBUG_OBJ = @DEBUG_OBJ@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOCB_OBJ = @DOCB_OBJ@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +FGREP = @FGREP@ +FTP_OBJ = @FTP_OBJ@ +GREP = @GREP@ +HAVE_ISINF = @HAVE_ISINF@ +HAVE_ISNAN = @HAVE_ISNAN@ +HTML_DIR = @HTML_DIR@ +HTML_OBJ = @HTML_OBJ@ +HTTP_OBJ = @HTTP_OBJ@ +ICONV_LIBS = @ICONV_LIBS@ +ICU_CFLAGS = @ICU_CFLAGS@ +ICU_LIBS = @ICU_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBXML_MAJOR_VERSION = @LIBXML_MAJOR_VERSION@ +LIBXML_MICRO_VERSION = @LIBXML_MICRO_VERSION@ +LIBXML_MINOR_VERSION = @LIBXML_MINOR_VERSION@ +LIBXML_VERSION = @LIBXML_VERSION@ +LIBXML_VERSION_EXTRA = @LIBXML_VERSION_EXTRA@ +LIBXML_VERSION_INFO = @LIBXML_VERSION_INFO@ +LIBXML_VERSION_NUMBER = @LIBXML_VERSION_NUMBER@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +LZMA_CFLAGS = @LZMA_CFLAGS@ +LZMA_LIBS = @LZMA_LIBS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MODULE_EXTENSION = @MODULE_EXTENSION@ +MODULE_PLATFORM_LIBS = @MODULE_PLATFORM_LIBS@ +MV = @MV@ +M_LIBS = @M_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PYTHON = @PYTHON@ +PYTHON_INCLUDES = @PYTHON_INCLUDES@ +PYTHON_LIBS = @PYTHON_LIBS@ +PYTHON_SITE_PACKAGES = @PYTHON_SITE_PACKAGES@ +PYTHON_SUBDIR = @PYTHON_SUBDIR@ +PYTHON_TESTS = @PYTHON_TESTS@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RDL_LIBS = @RDL_LIBS@ +READER_TEST = @READER_TEST@ +RELDATE = @RELDATE@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STATIC_BINARIES = @STATIC_BINARIES@ +STRIP = @STRIP@ +TAR = @TAR@ +TEST_C14N = @TEST_C14N@ +TEST_CATALOG = @TEST_CATALOG@ +TEST_DEBUG = @TEST_DEBUG@ +TEST_HTML = @TEST_HTML@ +TEST_MODULES = @TEST_MODULES@ +TEST_PATTERN = @TEST_PATTERN@ +TEST_PHTML = @TEST_PHTML@ +TEST_PUSH = @TEST_PUSH@ +TEST_REGEXPS = @TEST_REGEXPS@ +TEST_SAX = @TEST_SAX@ +TEST_SCHEMAS = @TEST_SCHEMAS@ +TEST_SCHEMATRON = @TEST_SCHEMATRON@ +TEST_THREADS = @TEST_THREADS@ +TEST_VALID = @TEST_VALID@ +TEST_VTIME = @TEST_VTIME@ +TEST_XINCLUDE = @TEST_XINCLUDE@ +TEST_XPATH = @TEST_XPATH@ +TEST_XPTR = @TEST_XPTR@ +THREAD_CFLAGS = @THREAD_CFLAGS@ +THREAD_LIBS = @THREAD_LIBS@ +VERSION = @VERSION@ +VERSION_SCRIPT_FLAGS = @VERSION_SCRIPT_FLAGS@ +WGET = @WGET@ +WIN32_EXTRA_LDFLAGS = @WIN32_EXTRA_LDFLAGS@ +WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@ +WIN32_EXTRA_PYTHON_LIBADD = @WIN32_EXTRA_PYTHON_LIBADD@ +WITH_C14N = @WITH_C14N@ +WITH_CATALOG = @WITH_CATALOG@ +WITH_DEBUG = @WITH_DEBUG@ +WITH_DOCB = @WITH_DOCB@ +WITH_FTP = @WITH_FTP@ +WITH_HTML = @WITH_HTML@ +WITH_HTTP = @WITH_HTTP@ +WITH_ICONV = @WITH_ICONV@ +WITH_ICU = @WITH_ICU@ +WITH_ISO8859X = @WITH_ISO8859X@ +WITH_LEGACY = @WITH_LEGACY@ +WITH_LZMA = @WITH_LZMA@ +WITH_MEM_DEBUG = @WITH_MEM_DEBUG@ +WITH_MODULES = @WITH_MODULES@ +WITH_OUTPUT = @WITH_OUTPUT@ +WITH_PATTERN = @WITH_PATTERN@ +WITH_PUSH = @WITH_PUSH@ +WITH_READER = @WITH_READER@ +WITH_REGEXPS = @WITH_REGEXPS@ +WITH_RUN_DEBUG = @WITH_RUN_DEBUG@ +WITH_SAX1 = @WITH_SAX1@ +WITH_SCHEMAS = @WITH_SCHEMAS@ +WITH_SCHEMATRON = @WITH_SCHEMATRON@ +WITH_THREADS = @WITH_THREADS@ +WITH_THREAD_ALLOC = @WITH_THREAD_ALLOC@ +WITH_TREE = @WITH_TREE@ +WITH_TRIO = @WITH_TRIO@ +WITH_VALID = @WITH_VALID@ +WITH_WRITER = @WITH_WRITER@ +WITH_XINCLUDE = @WITH_XINCLUDE@ +WITH_XPATH = @WITH_XPATH@ +WITH_XPTR = @WITH_XPTR@ +WITH_ZLIB = @WITH_ZLIB@ +XINCLUDE_OBJ = @XINCLUDE_OBJ@ +XMLLINT = @XMLLINT@ +XML_CFLAGS = @XML_CFLAGS@ +XML_INCLUDEDIR = @XML_INCLUDEDIR@ +XML_LIBDIR = @XML_LIBDIR@ +XML_LIBS = @XML_LIBS@ +XML_LIBTOOLLIBS = @XML_LIBTOOLLIBS@ +XML_PRIVATE_LIBS = @XML_PRIVATE_LIBS@ +XPATH_OBJ = @XPATH_OBJ@ +XPTR_OBJ = @XPTR_OBJ@ +XSLTPROC = @XSLTPROC@ +Z_CFLAGS = @Z_CFLAGS@ +Z_LIBS = @Z_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +exampledir = $(datadir)/doc/libxml2-python-$(LIBXML_VERSION)/examples +dist_example_DATA = $(PYTESTS) $(XMLS) +PYTESTS = \ + build.py \ + attribs.py \ + tst.py \ + tstxpath.py \ + xpathext.py \ + push.py \ + pushSAX.py \ + pushSAXhtml.py \ + error.py \ + serialize.py\ + validate.py \ + tstURI.py \ + cutnpaste.py\ + xpathret.py \ + xpath.py \ + outbuf.py \ + inbuf.py \ + input_callback.py \ + resolver.py \ + regexp.py \ + reader.py \ + reader2.py \ + reader3.py \ + reader4.py \ + reader5.py \ + reader6.py \ + reader7.py \ + reader8.py \ + readernext.py \ + walker.py \ + nsdel.py \ + ctxterror.py\ + readererr.py\ + relaxng.py \ + schema.py \ + thread2.py \ + sync.py \ + tstLastError.py \ + indexes.py \ + dtdvalid.py \ + tstmem.py \ + validDTD.py \ + validSchemas.py \ + validRNG.py \ + compareNodes.py \ + xpathns.py \ + xpathleak.py + +XMLS = \ + tst.xml \ + valid.xml \ + invalid.xml \ + test.dtd + +CLEANFILES = core tmp.xml *.pyc +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu python/tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu python/tests/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-dist_exampleDATA: $(dist_example_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_example_DATA)'; test -n "$(exampledir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(exampledir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(exampledir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(exampledir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(exampledir)" || exit $$?; \ + done + +uninstall-dist_exampleDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_example_DATA)'; test -n "$(exampledir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(exampledir)'; $(am__uninstall_files_from_dir) +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) +installdirs: + for dir in "$(DESTDIR)$(exampledir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-dist_exampleDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-dist_exampleDATA + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-dist_exampleDATA install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am uninstall-dist_exampleDATA + +.PRECIOUS: Makefile + + +@WITH_PYTHON_TRUE@tests: $(PYTESTS) +@WITH_PYTHON_TRUE@ @for f in $(XMLS) ; do test -f $$f || $(LN_S) $(srcdir)/$$f . ; done +@WITH_PYTHON_TRUE@ @echo "## running Python regression tests" +@WITH_PYTHON_TRUE@ @(export PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH" ; \ +@WITH_PYTHON_TRUE@ export LD_LIBRARY_PATH="$(top_builddir)/.libs:$$LD_LIBRARY_PATH" ; \ +@WITH_PYTHON_TRUE@ export PATH="$(top_builddir)/.libs:$$PATH" ; \ +@WITH_PYTHON_TRUE@ for test in $(PYTESTS) ; do \ +@WITH_PYTHON_TRUE@ log=`$(PYTHON) $(srcdir)/$$test` ; \ +@WITH_PYTHON_TRUE@ if [ "$$?" -ne 0 ] ; then \ +@WITH_PYTHON_TRUE@ echo "-- $$test" ; \ +@WITH_PYTHON_TRUE@ echo "$$log" ; \ +@WITH_PYTHON_TRUE@ exit 1 ; \ +@WITH_PYTHON_TRUE@ fi ; \ +@WITH_PYTHON_TRUE@ done) +@WITH_PYTHON_FALSE@tests: + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libxml2-2.9.10/python/tests/attribs.py b/libxml2-2.9.10/python/tests/attribs.py new file mode 100755 index 0000000..99132c2 --- /dev/null +++ b/libxml2-2.9.10/python/tests/attribs.py @@ -0,0 +1,34 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +# +# Testing XML document serialization +# +doc = libxml2.parseDoc( +""" + + + +]> + +""") +elem = doc.getRootElement() +attr = elem.hasNsProp('attr', 'http://abc.org') +if attr == None or attr.serialize()[:-1] != """""": + print("Failed to find defaulted attribute abc:attr") + sys.exit(1) + +doc.freeDoc() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/build.py b/libxml2-2.9.10/python/tests/build.py new file mode 100755 index 0000000..b2d3f78 --- /dev/null +++ b/libxml2-2.9.10/python/tests/build.py @@ -0,0 +1,59 @@ +#!/usr/bin/python -u +import libxml2 +import sys + +# Memory debug specific +libxml2.debugMemory(1) + +doc = libxml2.newDoc("1.0") +comment = doc.newDocComment("This is a generated document") +doc.addChild(comment) +pi = libxml2.newPI("test", "PI content") +doc.addChild(pi) +root = doc.newChild(None, "doc", None) +ns = root.newNs("http://example.com/doc", "my") +root.setNs(ns) +elem = root.newChild(None, "foo", "bar") +elem.setBase("http://example.com/imgs") +elem.setProp("img", "image.gif") +doc.saveFile("tmp.xml") +doc.freeDoc() + +doc = libxml2.parseFile("tmp.xml") +comment = doc.children +if comment.type != "comment" or \ + comment.content != "This is a generated document": + print("error rereading comment") + sys.exit(1) +pi = comment.next +if pi.type != "pi" or pi.name != "test" or pi.content != "PI content": + print("error rereading PI") + sys.exit(1) +root = pi.next +if root.name != "doc": + print("error rereading root") + sys.exit(1) +ns = root.ns() +if ns.name != "my" or ns.content != "http://example.com/doc": + print("error rereading namespace") + sys.exit(1) +elem = root.children +if elem.name != "foo": + print("error rereading elem") + sys.exit(1) +if elem.getBase(None) != "http://example.com/imgs": + print("error rereading base") + sys.exit(1) +if elem.prop("img") != "image.gif": + print("error rereading property") + sys.exit(1) + +doc.freeDoc() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/compareNodes.py b/libxml2-2.9.10/python/tests/compareNodes.py new file mode 100755 index 0000000..ca5a5a2 --- /dev/null +++ b/libxml2-2.9.10/python/tests/compareNodes.py @@ -0,0 +1,50 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +# +# Testing XML Node comparison and Node hash-value +# +doc = libxml2.parseDoc("""""") +root = doc.getRootElement() + +# Create two different objects which point to foo +foonode1 = root.children +foonode2 = root.children + +# Now check that [in]equality tests work ok +if not ( foonode1 == foonode2 ): + print("Error comparing nodes with ==, nodes should be equal but are unequal") + sys.exit(1) +if not ( foonode1 != root ): + print("Error comparing nodes with ==, nodes should not be equal but are equal") + sys.exit(1) +if not ( foonode1 != root ): + print("Error comparing nodes with !=, nodes should not be equal but are equal") +if ( foonode1 != foonode2 ): + print("Error comparing nodes with !=, nodes should be equal but are unequal") + +# Next check that the hash function for the objects also works ok +if not (hash(foonode1) == hash(foonode2)): + print("Error hash values for two equal nodes are different") + sys.exit(1) +if not (hash(foonode1) != hash(root)): + print("Error hash values for two unequal nodes are not different") + sys.exit(1) +if hash(foonode1) == hash(root): + print("Error hash values for two unequal nodes are equal") + sys.exit(1) + +# Basic tests successful +doc.freeDoc() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/ctxterror.py b/libxml2-2.9.10/python/tests/ctxterror.py new file mode 100755 index 0000000..416e384 --- /dev/null +++ b/libxml2-2.9.10/python/tests/ctxterror.py @@ -0,0 +1,56 @@ +#!/usr/bin/python -u +# +# This test exercise the redirection of error messages with a +# functions defined in Python. +# +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +expect="""--> (3) xmlns: URI foo is not absolute +--> (4) Opening and ending tag mismatch: x line 0 and y +""" + +err="" +def callback(arg,msg,severity,reserved): + global err + err = err + "%s (%d) %s" % (arg,severity,msg) + +s = """""" + +parserCtxt = libxml2.createPushParser(None,"",0,"test.xml") +parserCtxt.setErrorHandler(callback, "-->") +if parserCtxt.getErrorHandler() != (callback,"-->"): + print("getErrorHandler failed") + sys.exit(1) +parserCtxt.parseChunk(s,len(s),1) +doc = parserCtxt.doc() +doc.freeDoc() +parserCtxt = None + +if err != expect: + print("error") + print("received %s" %(err)) + print("expected %s" %(expect)) + sys.exit(1) + +i = 10000 +while i > 0: + parserCtxt = libxml2.createPushParser(None,"",0,"test.xml") + parserCtxt.setErrorHandler(callback, "-->") + parserCtxt.parseChunk(s,len(s),1) + doc = parserCtxt.doc() + doc.freeDoc() + parserCtxt = None + err = "" + i = i - 1 + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/cutnpaste.py b/libxml2-2.9.10/python/tests/cutnpaste.py new file mode 100755 index 0000000..7787246 --- /dev/null +++ b/libxml2-2.9.10/python/tests/cutnpaste.py @@ -0,0 +1,48 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +# +# Testing XML document serialization +# +source = libxml2.parseDoc(""" + + + + + +""") + +target = libxml2.parseDoc(""" +""") + +fragment = source.xpathEval("//*[name()='fragment']")[0] +dest = target.getRootElement() + +# do a cut and paste operation +fragment.unlinkNode() +dest.addChild(fragment) +# do the namespace fixup +dest.reconciliateNs(target) + +# The source tree can be freed at that point +source.freeDoc() + +# check the resulting tree +str = dest.serialize() +if str != """""": + print("reconciliateNs() failed") + sys.exit(1) +target.freeDoc() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/dtdvalid.py b/libxml2-2.9.10/python/tests/dtdvalid.py new file mode 100755 index 0000000..d4049b8 --- /dev/null +++ b/libxml2-2.9.10/python/tests/dtdvalid.py @@ -0,0 +1,32 @@ +#!/usr/bin/python -u +import libxml2 +import sys + +# Memory debug specific +libxml2.debugMemory(1) + +dtd="""""" +instance=""" +""" + +dtd = libxml2.parseDTD(None, 'test.dtd') +ctxt = libxml2.newValidCtxt() +doc = libxml2.parseDoc(instance) +ret = doc.validateDtd(ctxt, dtd) +if ret != 1: + print("error doing DTD validation") + sys.exit(1) + +doc.freeDoc() +dtd.freeDtd() +del dtd +del ctxt + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() + diff --git a/libxml2-2.9.10/python/tests/error.py b/libxml2-2.9.10/python/tests/error.py new file mode 100755 index 0000000..530c2ee --- /dev/null +++ b/libxml2-2.9.10/python/tests/error.py @@ -0,0 +1,51 @@ +#!/usr/bin/python -u +# +# This test exercise the redirection of error messages with a +# functions defined in Python. +# +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +expect='--> I/O --> warning : --> failed to load external entity "missing.xml"\n' +err="" +def callback(ctx, str): + global err + + err = err + "%s %s" % (ctx, str) + +got_exc = 0 +libxml2.registerErrorHandler(callback, "-->") +try: + doc = libxml2.parseFile("missing.xml") +except libxml2.parserError: + got_exc = 1 + +if got_exc == 0: + print("Failed to get a parser exception") + sys.exit(1) + +if err != expect: + print("error") + print("received %s" %(err)) + print("expected %s" %(expect)) + sys.exit(1) + +i = 10000 +while i > 0: + try: + doc = libxml2.parseFile("missing.xml") + except libxml2.parserError: + got_exc = 1 + err = "" + i = i - 1 + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/inbuf.py b/libxml2-2.9.10/python/tests/inbuf.py new file mode 100755 index 0000000..0c16674 --- /dev/null +++ b/libxml2-2.9.10/python/tests/inbuf.py @@ -0,0 +1,30 @@ +#!/usr/bin/python -u +import sys +import libxml2 +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +# Memory debug specific +libxml2.debugMemory(1) + +i = 0 +while i < 5000: + f = str_io("foobar") + buf = libxml2.inputBuffer(f) + i = i + 1 + +del f +del buf + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() + diff --git a/libxml2-2.9.10/python/tests/indexes.py b/libxml2-2.9.10/python/tests/indexes.py new file mode 100755 index 0000000..e41a0d9 --- /dev/null +++ b/libxml2-2.9.10/python/tests/indexes.py @@ -0,0 +1,113 @@ +#!/usr/bin/python -u +# -*- coding: ISO-8859-1 -*- +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +ctxt = None + +class callback: + def __init__(self, startd, starte, ende, delta, endd): + self.startd = startd + self.starte = starte + self.ende = ende + self.endd = endd + self.delta = delta + self.count = 0 + + def startDocument(self): + global ctxt + if ctxt.byteConsumed() != self.startd: + print("document start at wrong index: %d expecting %d\n" % ( + ctxt.byteConsumed(), self.startd)) + sys.exit(1) + + def endDocument(self): + global ctxt + expect = self.ende + self.delta * (self.count - 1) + self.endd + if ctxt.byteConsumed() != expect: + print("document end at wrong index: %d expecting %d\n" % ( + ctxt.byteConsumed(), expect)) + sys.exit(1) + + def startElement(self, tag, attrs): + global ctxt + if tag == "bar1": + expect = self.starte + self.delta * self.count + if ctxt.byteConsumed() != expect: + print("element start at wrong index: %d expecting %d\n" % ( + ctxt.byteConsumed(), expect)) + sys.exit(1) + + + def endElement(self, tag): + global ctxt + if tag == "bar1": + expect = self.ende + self.delta * self.count + if ctxt.byteConsumed() != expect: + print("element end at wrong index: %d expecting %d\n" % ( + ctxt.byteConsumed(), expect)) + sys.exit(1) + self.count = self.count + 1 + + def characters(self, data): + pass + +# +# First run a pure UTF-8 test +# +handler = callback(0, 13, 27, 198, 183) +ctxt = libxml2.createPushParser(handler, "\n", 6, "test.xml") +chunk = """ chars1 + chars2 + chars3 + chars4 + chars5 + <s6 + chars7 + &8 + chars9 +""" +i = 0 +while i < 10000: + ctxt.parseChunk(chunk, len(chunk), 0) + i = i + 1 +chunk = "" +ctxt.parseChunk(chunk, len(chunk), 1) +ctxt=None + +# +# Then run a test relying on ISO-Latin-1 +# +handler = callback(43, 57, 71, 198, 183) +chunk=""" + +""" +ctxt = libxml2.createPushParser(handler, chunk, len(chunk), "test.xml") +chunk = """ chars1 + chars2 + chars3 + chàrs4 + chars5 + <s6 + chars7 + &8 + très 9 +""" +i = 0 +while i < 10000: + ctxt.parseChunk(chunk, len(chunk), 0) + i = i + 1 +chunk = "" +ctxt.parseChunk(chunk, len(chunk), 1) +ctxt=None + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/input_callback.py b/libxml2-2.9.10/python/tests/input_callback.py new file mode 100755 index 0000000..495ab62 --- /dev/null +++ b/libxml2-2.9.10/python/tests/input_callback.py @@ -0,0 +1,148 @@ +#!/usr/bin/python -u +# +# This tests custom input callbacks +# +import sys +import libxml2 +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +# We implement a new scheme, py://strings/ that will reference this dictionary +pystrings = { + 'catalogs/catalog.xml' : +''' + + + +''', + + 'xml/sample.xml' : +''' + +&sample.entity;''', + + 'dtds/sample.dtd' : +''' + +''' +} + +prefix = "py://strings/" +startURL = prefix + "xml/sample.xml" +catURL = prefix + "catalogs/catalog.xml" + +def my_input_cb(URI): + if not(URI.startswith(prefix)): + return None + path = URI[len(prefix):] + if path not in pystrings: + return None + return str_io(pystrings[path]) + + +def run_test(desc, docpath, catalog, exp_status="verified", exp_err=[], test_callback=None, + root_name="root", root_content="replacement text"): + opts = libxml2.XML_PARSE_DTDLOAD | libxml2.XML_PARSE_NONET | libxml2.XML_PARSE_COMPACT + actual_err = [] + + def my_global_error_cb(ctx, msg): + actual_err.append((-1, msg)) + def my_ctx_error_cb(arg, msg, severity, reserved): + actual_err.append((severity, msg)) + + libxml2.registerErrorHandler(my_global_error_cb, None) + try: + parser = libxml2.createURLParserCtxt(docpath, opts) + parser.setErrorHandler(my_ctx_error_cb, None) + if catalog is not None: + parser.addLocalCatalog(catalog) + if test_callback is not None: + test_callback() + parser.parseDocument() + doc = parser.doc() + actual_status = "loaded" + e = doc.getRootElement() + if e.name == root_name and e.content == root_content: + actual_status = "verified" + doc.freeDoc() + except libxml2.parserError: + actual_status = "not loaded" + + if actual_status != exp_status: + print("Test '%s' failed: expect status '%s', actual '%s'" % (desc, exp_status, actual_status)) + sys.exit(1) + elif actual_err != exp_err: + print("Test '%s' failed" % desc) + print("Expect errors:") + for s,m in exp_err: print(" [%2d] '%s'" % (s,m)) + print("Actual errors:") + for s,m in actual_err: print(" [%2d] '%s'" % (s,m)) + sys.exit(1) + + +# Check that we cannot read custom schema without custom callback +run_test(desc="Loading entity without custom callback", + docpath=startURL, catalog=None, + exp_status="not loaded", exp_err=[ + (-1, "I/O "), + (-1, "warning : "), + (-1, "failed to load external entity \"py://strings/xml/sample.xml\"\n") + ]) + +# Register handler and try to load the same entity +libxml2.registerInputCallback(my_input_cb) +run_test(desc="Loading entity with custom callback", + docpath=startURL, catalog=None, + exp_status="loaded", exp_err=[ + (-1, "Attempt to load network entity http://example.com/dtds/sample.dtd"), + ( 4, "Entity 'sample.entity' not defined\n") + ]) + +# Register a catalog (also accessible via pystr://) and retry +run_test(desc="Loading entity with custom callback and catalog", + docpath=startURL, catalog=catURL) + +# Unregister custom callback when parser is already created +run_test(desc="Loading entity and unregistering callback", + docpath=startURL, catalog=catURL, + test_callback=lambda: libxml2.popInputCallbacks(), + exp_status="loaded", exp_err=[ + ( 3, "failed to load external entity \"py://strings/dtds/sample.dtd\"\n"), + ( 4, "Entity 'sample.entity' not defined\n") + ]) + +# Try to load the document again +run_test(desc="Retry loading document after unregistering callback", + docpath=startURL, catalog=catURL, + exp_status="not loaded", exp_err=[ + (-1, "I/O "), + (-1, "warning : "), + (-1, "failed to load external entity \"py://strings/xml/sample.xml\"\n") + ]) + +# But should be able to read standard I/O yet... +run_test(desc="Loading using standard i/o after unregistering callback", + docpath="tst.xml", catalog=None, + root_name='doc', root_content='bar') + +# Now pop ALL input callbacks, should fail to load even standard I/O +try: + while True: + libxml2.popInputCallbacks() +except IndexError: + pass + +run_test(desc="Loading using standard i/o after unregistering all callbacks", + docpath="tst.xml", catalog=None, + exp_status="not loaded", exp_err=[ + (-1, "I/O "), + (-1, "warning : "), + (-1, "failed to load external entity \"tst.xml\"\n") + ]) + +print("OK") +sys.exit(0); diff --git a/libxml2-2.9.10/python/tests/invalid.xml b/libxml2-2.9.10/python/tests/invalid.xml new file mode 100644 index 0000000..7c9b27e --- /dev/null +++ b/libxml2-2.9.10/python/tests/invalid.xml @@ -0,0 +1,6 @@ + + + +]> + diff --git a/libxml2-2.9.10/python/tests/nsdel.py b/libxml2-2.9.10/python/tests/nsdel.py new file mode 100755 index 0000000..079399a --- /dev/null +++ b/libxml2-2.9.10/python/tests/nsdel.py @@ -0,0 +1,62 @@ +#!/usr/bin/python -u +# +# this test exercise the XPath basic engine, parser, etc, and +# allows to detect memory leaks +# +import sys +import libxml2 + +instance=""" +""" + +def namespaceDefs(node): + n = node.nsDefs() + while n: + yield n + n = n.next + +def checkNamespaceDefs(node, count): + nsList = list(namespaceDefs(node)) + #print nsList + if len(nsList) != count : + raise Exception("Error: saw %d namespace declarations. Expected %d" % (len(nsList), count)) + +# Memory debug specific +libxml2.debugMemory(1) + +# Remove single namespace +doc = libxml2.parseDoc(instance) +node = doc.getRootElement() +checkNamespaceDefs(node, 3) +ns = node.removeNsDef('urn:bar') +checkNamespaceDefs(node, 2) +ns.freeNsList() +doc.freeDoc() + +# Remove all namespaces +doc = libxml2.parseDoc(instance) +node = doc.getRootElement() +checkNamespaceDefs(node, 3) +ns = node.removeNsDef(None) +checkNamespaceDefs(node, 0) +ns.freeNsList() +doc.freeDoc() + +# Remove a namespace refered to by a child +doc = libxml2.newDoc("1.0") +root = doc.newChild(None, "root", None) +namespace = root.newNs("http://example.com/sample", "s") +child = root.newChild(namespace, "child", None) +root.removeNsDef("http://example.com/sample") +doc.reconciliateNs(root) +namespace.freeNsList() +doc.serialize() # This should not segfault +doc.freeDoc() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/outbuf.py b/libxml2-2.9.10/python/tests/outbuf.py new file mode 100755 index 0000000..62761cc --- /dev/null +++ b/libxml2-2.9.10/python/tests/outbuf.py @@ -0,0 +1,110 @@ +#!/usr/bin/python -u +import sys +import libxml2 +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +def testSimpleBufferWrites(): + f = str_io() + buf = libxml2.createOutputBuffer(f, "ISO-8859-1") + buf.write(3, "foo") + buf.writeString("bar") + buf.close() + + if f.getvalue() != "foobar": + print("Failed to save to StringIO") + sys.exit(1) + +def testSaveDocToBuffer(): + """ + Regression test for bug #154294. + """ + input = 'Hello' + expected = '''\ + +Hello +''' + f = str_io() + buf = libxml2.createOutputBuffer(f, 'UTF-8') + doc = libxml2.parseDoc(input) + doc.saveFileTo(buf, 'UTF-8') + doc.freeDoc() + if f.getvalue() != expected: + print('xmlDoc.saveFileTo() call failed.') + print(' got: %s' % repr(f.getvalue())) + print('expected: %s' % repr(expected)) + sys.exit(1) + +def testSaveFormattedDocToBuffer(): + input = 'Some text' + # The formatted and non-formatted versions of the output. + expected = ('''\ + +Some text +''', '''\ + + + Some text + + +''') + doc = libxml2.parseDoc(input) + for i in (0, 1): + f = str_io() + buf = libxml2.createOutputBuffer(f, 'UTF-8') + doc.saveFormatFileTo(buf, 'UTF-8', i) + if f.getvalue() != expected[i]: + print('xmlDoc.saveFormatFileTo() call failed.') + print(' got: %s' % repr(f.getvalue())) + print('expected: %s' % repr(expected[i])) + sys.exit(1) + doc.freeDoc() + +def testSaveIntoOutputBuffer(): + """ + Similar to the previous two tests, except this time we invoke the save + methods on the output buffer object and pass in an XML node object. + """ + input = 'Hello' + expected = '''\ + +Hello +''' + f = str_io() + doc = libxml2.parseDoc(input) + buf = libxml2.createOutputBuffer(f, 'UTF-8') + buf.saveFileTo(doc, 'UTF-8') + if f.getvalue() != expected: + print('outputBuffer.saveFileTo() call failed.') + print(' got: %s' % repr(f.getvalue())) + print('expected: %s' % repr(expected)) + sys.exit(1) + f = str_io() + buf = libxml2.createOutputBuffer(f, 'UTF-8') + buf.saveFormatFileTo(doc, 'UTF-8', 1) + if f.getvalue() != expected: + print('outputBuffer.saveFormatFileTo() call failed.') + print(' got: %s' % repr(f.getvalue())) + print('expected: %s' % repr(expected)) + sys.exit(1) + doc.freeDoc() + +if __name__ == '__main__': + # Memory debug specific + libxml2.debugMemory(1) + + testSimpleBufferWrites() + testSaveDocToBuffer() + testSaveFormattedDocToBuffer() + testSaveIntoOutputBuffer() + + libxml2.cleanupParser() + if libxml2.debugMemory(1) == 0: + print("OK") + else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/push.py b/libxml2-2.9.10/python/tests/push.py new file mode 100755 index 0000000..0edd61d --- /dev/null +++ b/libxml2-2.9.10/python/tests/push.py @@ -0,0 +1,35 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +ctxt = libxml2.createPushParser(None, "", 2, 1) +doc = ctxt.doc() +ctxt=None +if doc.name != "test.xml": + print("document name error") + sys.exit(1) +root = doc.children +if root.name != "foo": + print("root element name error") + sys.exit(1) +doc.freeDoc() +i = 10000 +while i > 0: + ctxt = libxml2.createPushParser(None, "", 2, 1) + doc = ctxt.doc() + doc.freeDoc() + i = i -1 +ctxt=None + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/pushSAX.py b/libxml2-2.9.10/python/tests/pushSAX.py new file mode 100755 index 0000000..48f6e82 --- /dev/null +++ b/libxml2-2.9.10/python/tests/pushSAX.py @@ -0,0 +1,64 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +log = "" + +class callback: + def startDocument(self): + global log + log = log + "startDocument:" + + def endDocument(self): + global log + log = log + "endDocument:" + + def startElement(self, tag, attrs): + global log + log = log + "startElement %s %s:" % (tag, attrs) + + def endElement(self, tag): + global log + log = log + "endElement %s:" % (tag) + + def characters(self, data): + global log + log = log + "characters: %s:" % (data) + + def warning(self, msg): + global log + log = log + "warning: %s:" % (msg) + + def error(self, msg): + global log + log = log + "error: %s:" % (msg) + + def fatalError(self, msg): + global log + log = log + "fatalError: %s:" % (msg) + +handler = callback() + +ctxt = libxml2.createPushParser(handler, "content of c""") +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test1") +ret = reader.Read() +if ret != 1: + print("test1: Error reading to first element") + sys.exit(1) +if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \ + reader.NodeType() != 1 or reader.HasAttributes() != 0: + print("test1: Error reading the first element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test1: Error reading to second element") + sys.exit(1) +if reader.Name() != "b" or reader.IsEmptyElement() != 1 or \ + reader.NodeType() != 1 or reader.HasAttributes() != 1: + print("test1: Error reading the second element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test1: Error reading to third element") + sys.exit(1) +if reader.Name() != "c" or reader.IsEmptyElement() != 0 or \ + reader.NodeType() != 1 or reader.HasAttributes() != 0: + print("test1: Error reading the third element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test1: Error reading to text node") + sys.exit(1) +if reader.Name() != "#text" or reader.IsEmptyElement() != 0 or \ + reader.NodeType() != 3 or reader.HasAttributes() != 0 or \ + reader.Value() != "content of c": + print("test1: Error reading the text node") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test1: Error reading to end of third element") + sys.exit(1) +if reader.Name() != "c" or reader.IsEmptyElement() != 0 or \ + reader.NodeType() != 15 or reader.HasAttributes() != 0: + print("test1: Error reading the end of third element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test1: Error reading to end of first element") + sys.exit(1) +if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \ + reader.NodeType() != 15 or reader.HasAttributes() != 0: + print("test1: Error reading the end of first element") + sys.exit(1) +ret = reader.Read() +if ret != 0: + print("test1: Error reading to end of document") + sys.exit(1) + +# +# example from the XmlTextReader docs +# +f = str_io("""""") +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test2") + +ret = reader.Read() +if ret != 1: + print("Error reading test element") + sys.exit(1) +if reader.GetAttributeNo(0) != "urn:datatypes" or \ + reader.GetAttributeNo(1) != "int" or \ + reader.GetAttributeNs("type", "urn:datatypes") != "int" or \ + reader.GetAttribute("dt:type") != "int": + print("error reading test attributes") + sys.exit(1) + +# +# example from the XmlTextReader docs +# +f = str_io(""" + + + +""") +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test3") + +ret = reader.Read() +while ret == 1: + if reader.Name() == "ref": + if reader.LookupNamespace("a") != "urn:456": + print("error resolving namespace prefix") + sys.exit(1) + break + ret = reader.Read() +if ret != 1: + print("Error finding the ref element") + sys.exit(1) + +# +# Home made example for the various attribute access functions +# +f = str_io("""""") +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test4") +ret = reader.Read() +if ret != 1: + print("Error reading the testattr element") + sys.exit(1) +# +# Attribute exploration by index +# +if reader.MoveToAttributeNo(0) != 1: + print("Failed moveToAttribute(0)") + sys.exit(1) +if reader.Value() != "urn:1": + print("Failed to read attribute(0)") + sys.exit(1) +if reader.Name() != "xmlns": + print("Failed to read attribute(0) name") + sys.exit(1) +if reader.MoveToAttributeNo(1) != 1: + print("Failed moveToAttribute(1)") + sys.exit(1) +if reader.Value() != "urn:2": + print("Failed to read attribute(1)") + sys.exit(1) +if reader.Name() != "xmlns:a": + print("Failed to read attribute(1) name") + sys.exit(1) +if reader.MoveToAttributeNo(2) != 1: + print("Failed moveToAttribute(2)") + sys.exit(1) +if reader.Value() != "b": + print("Failed to read attribute(2)") + sys.exit(1) +if reader.Name() != "b": + print("Failed to read attribute(2) name") + sys.exit(1) +if reader.MoveToAttributeNo(3) != 1: + print("Failed moveToAttribute(3)") + sys.exit(1) +if reader.Value() != "a:b": + print("Failed to read attribute(3)") + sys.exit(1) +if reader.Name() != "a:b": + print("Failed to read attribute(3) name") + sys.exit(1) +# +# Attribute exploration by name +# +if reader.MoveToAttribute("xmlns") != 1: + print("Failed moveToAttribute('xmlns')") + sys.exit(1) +if reader.Value() != "urn:1": + print("Failed to read attribute('xmlns')") + sys.exit(1) +if reader.MoveToAttribute("xmlns:a") != 1: + print("Failed moveToAttribute('xmlns')") + sys.exit(1) +if reader.Value() != "urn:2": + print("Failed to read attribute('xmlns:a')") + sys.exit(1) +if reader.MoveToAttribute("b") != 1: + print("Failed moveToAttribute('b')") + sys.exit(1) +if reader.Value() != "b": + print("Failed to read attribute('b')") + sys.exit(1) +if reader.MoveToAttribute("a:b") != 1: + print("Failed moveToAttribute('a:b')") + sys.exit(1) +if reader.Value() != "a:b": + print("Failed to read attribute('a:b')") + sys.exit(1) +if reader.MoveToAttributeNs("b", "urn:2") != 1: + print("Failed moveToAttribute('b', 'urn:2')") + sys.exit(1) +if reader.Value() != "a:b": + print("Failed to read attribute('b', 'urn:2')") + sys.exit(1) +# +# Go back and read in sequence +# +if reader.MoveToElement() != 1: + print("Failed to move back to element") + sys.exit(1) +if reader.MoveToFirstAttribute() != 1: + print("Failed to move to first attribute") + sys.exit(1) +if reader.Value() != "urn:1": + print("Failed to read attribute(0)") + sys.exit(1) +if reader.Name() != "xmlns": + print("Failed to read attribute(0) name") + sys.exit(1) +if reader.MoveToNextAttribute() != 1: + print("Failed to move to next attribute") + sys.exit(1) +if reader.Value() != "urn:2": + print("Failed to read attribute(1)") + sys.exit(1) +if reader.Name() != "xmlns:a": + print("Failed to read attribute(1) name") + sys.exit(1) +if reader.MoveToNextAttribute() != 1: + print("Failed to move to next attribute") + sys.exit(1) +if reader.Value() != "b": + print("Failed to read attribute(2)") + sys.exit(1) +if reader.Name() != "b": + print("Failed to read attribute(2) name") + sys.exit(1) +if reader.MoveToNextAttribute() != 1: + print("Failed to move to next attribute") + sys.exit(1) +if reader.Value() != "a:b": + print("Failed to read attribute(3)") + sys.exit(1) +if reader.Name() != "a:b": + print("Failed to read attribute(3) name") + sys.exit(1) +if reader.MoveToNextAttribute() != 0: + print("Failed to detect last attribute") + sys.exit(1) + + +# +# a couple of tests for namespace nodes +# +f = str_io("""""") +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test6") +ret = reader.Read() +if ret != 1: + print("test6: failed to Read()") + sys.exit(1) +ret = reader.MoveToFirstAttribute() +if ret != 1: + print("test6: failed to MoveToFirstAttribute()") + sys.exit(1) +if reader.NamespaceUri() != "http://www.w3.org/2000/xmlns/" or \ + reader.LocalName() != "xmlns" or reader.Name() != "xmlns" or \ + reader.Value() != "http://example.com/foo" or reader.NodeType() != 2: + print("test6: failed to read the namespace node") + sys.exit(1) + +f = str_io("""""") +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test7") +ret = reader.Read() +if ret != 1: + print("test7: failed to Read()") + sys.exit(1) +ret = reader.MoveToFirstAttribute() +if ret != 1: + print("test7: failed to MoveToFirstAttribute()") + sys.exit(1) +if reader.NamespaceUri() != "http://www.w3.org/2000/xmlns/" or \ + reader.LocalName() != "prefix" or reader.Name() != "xmlns:prefix" or \ + reader.Value() != "http://example.com/foo" or reader.NodeType() != 2: + print("test7: failed to read the namespace node") + sys.exit(1) + +# +# Test for a limit case: +# +f = str_io("""""") +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test8") +ret = reader.Read() +if ret != 1: + print("test8: failed to read the node") + sys.exit(1) +if reader.Name() != "a" or reader.IsEmptyElement() != 1: + print("test8: failed to analyze the node") + sys.exit(1) +ret = reader.Read() +if ret != 0: + print("test8: failed to detect the EOF") + sys.exit(1) + +# +# Another test provided by Stéphane Bidoul and checked with C# +# +def tst_reader(s): + f = str_io(s) + input = libxml2.inputBuffer(f) + reader = input.newTextReader("tst") + res = "" + while reader.Read(): + res=res + "%s (%s) [%s] %d %d\n" % (reader.NodeType(),reader.Name(), + reader.Value(), reader.IsEmptyElement(), + reader.Depth()) + if reader.NodeType() == 1: # Element + while reader.MoveToNextAttribute(): + res = res + "-- %s (%s) [%s] %d %d\n" % (reader.NodeType(), + reader.Name(),reader.Value(), + reader.IsEmptyElement(), reader.Depth()) + return res + +doc="""content of c""" +expect="""1 (a) [None] 0 0 +1 (b) [None] 1 1 +-- 2 (b1) [b1] 0 2 +1 (c) [None] 0 1 +3 (#text) [content of c] 0 2 +15 (c) [None] 0 1 +15 (a) [None] 0 0 +""" +res = tst_reader(doc) +if res != expect: + print("test5 failed") + print(res) + sys.exit(1) + +doc="""""" +expect="""1 (test) [None] 0 0 +1 (b) [None] 1 1 +1 (c) [None] 1 1 +15 (test) [None] 0 0 +""" +res = tst_reader(doc) +if res != expect: + print("test9 failed") + print(res) + sys.exit(1) + +doc="""bbbccc""" +expect="""1 (a) [None] 0 0 +1 (b) [None] 0 1 +3 (#text) [bbb] 0 2 +15 (b) [None] 0 1 +1 (c) [None] 0 1 +3 (#text) [ccc] 0 2 +15 (c) [None] 0 1 +15 (a) [None] 0 0 +""" +res = tst_reader(doc) +if res != expect: + print("test10 failed") + print(res) + sys.exit(1) + +doc="""""" +expect="""1 (test) [None] 1 0 +-- 2 (a) [a] 0 1 +""" +res = tst_reader(doc) +if res != expect: + print("test11 failed") + print(res) + sys.exit(1) + +doc="""aaa""" +expect="""1 (test) [None] 0 0 +1 (a) [None] 0 1 +3 (#text) [aaa] 0 2 +15 (a) [None] 0 1 +1 (b) [None] 1 1 +15 (test) [None] 0 0 +""" +res = tst_reader(doc) +if res != expect: + print("test12 failed") + print(res) + sys.exit(1) + +doc="""

""" +expect="""1 (test) [None] 0 0 +1 (p) [None] 0 1 +15 (p) [None] 0 1 +15 (test) [None] 0 0 +""" +res = tst_reader(doc) +if res != expect: + print("test13 failed") + print(res) + sys.exit(1) + +doc="""

""" +expect="""1 (p) [None] 0 0 +15 (p) [None] 0 0 +""" +res = tst_reader(doc) +if res != expect: + print("test14 failed") + print(res) + sys.exit(1) + +# +# test from bug #108801 +# +doc=""" + + +
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +
+""" +expect="""10 (article) [None] 0 0 +1 (article) [None] 0 0 +3 (#text) [ +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +] 0 1 +15 (article) [None] 0 0 +""" +res = tst_reader(doc) +if res != expect: + print("test15 failed") + print(res) + sys.exit(1) + +# +# cleanup for memory allocation counting +# +del f +del input +del reader + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/reader2.py b/libxml2-2.9.10/python/tests/reader2.py new file mode 100755 index 0000000..8570575 --- /dev/null +++ b/libxml2-2.9.10/python/tests/reader2.py @@ -0,0 +1,265 @@ +#!/usr/bin/python -u +# +# this tests the DTD validation with the XmlTextReader interface +# +import sys +import glob +import string +import libxml2 +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +# Memory debug specific +libxml2.debugMemory(1) + +err="" +expect="""../../test/valid/rss.xml:177: element rss: validity error : Element rss does not carry attribute version + + ^ +../../test/valid/xlink.xml:450: element termdef: validity error : ID dt-arc already defined +

An + + + +xxx"> +]> + + &x; + bbb + +""" +expect="""10,test +1,test +14,#text +1,x +1,c +3,#text +15,c +15,x +14,#text +1,b +3,#text +15,b +14,#text +15,test +""" +res="" +err="" + +input = libxml2.inputBuffer(str_io(s)) +reader = input.newTextReader("test2") +reader.SetParserProp(libxml2.PARSER_LOADDTD,1) +reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) +reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) +reader.SetParserProp(libxml2.PARSER_VALIDATE,1) +while reader.Read() == 1: + res = res + "%s,%s\n" % (reader.NodeType(),reader.Name()) + +if res != expect: + print("test2 failed: unexpected output") + print(res) + sys.exit(1) +if err != "": + print("test2 failed: validation error found") + print(err) + sys.exit(1) + +# +# Another test for external entity parsing and validation +# + +s = """ + + +]> + + &e; + +""" +tst_ent = """hello""" +expect="""10 test +1 test +14 #text +1 x +3 #text +15 x +14 #text +15 test +""" +res="" + +def myResolver(URL, ID, ctxt): + if URL == "tst.ent": + return(str_io(tst_ent)) + return None + +libxml2.setEntityLoader(myResolver) + +input = libxml2.inputBuffer(str_io(s)) +reader = input.newTextReader("test3") +reader.SetParserProp(libxml2.PARSER_LOADDTD,1) +reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) +reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) +reader.SetParserProp(libxml2.PARSER_VALIDATE,1) +while reader.Read() == 1: + res = res + "%s %s\n" % (reader.NodeType(),reader.Name()) + +if res != expect: + print("test3 failed: unexpected output") + print(res) + sys.exit(1) +if err != "": + print("test3 failed: validation error found") + print(err) + sys.exit(1) + +# +# Another test for recursive entity parsing, validation, and replacement of +# entities, making sure the entity ref node doesn't show up in that case +# + +s = """ + + +&y;"> +yyy"> +]> + + &x; + &x; +""" +expect="""10 test 0 +1 test 0 +14 #text 1 +1 x 1 +1 y 2 +3 #text 3 +15 y 2 +15 x 1 +14 #text 1 +1 x 1 +1 y 2 +3 #text 3 +15 y 2 +15 x 1 +14 #text 1 +15 test 0 +""" +res="" +err="" + +input = libxml2.inputBuffer(str_io(s)) +reader = input.newTextReader("test4") +reader.SetParserProp(libxml2.PARSER_LOADDTD,1) +reader.SetParserProp(libxml2.PARSER_DEFAULTATTRS,1) +reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) +reader.SetParserProp(libxml2.PARSER_VALIDATE,1) +while reader.Read() == 1: + res = res + "%s %s %d\n" % (reader.NodeType(),reader.Name(),reader.Depth()) + +if res != expect: + print("test4 failed: unexpected output") + print(res) + sys.exit(1) +if err != "": + print("test4 failed: validation error found") + print(err) + sys.exit(1) + +# +# The same test but without entity substitution this time +# + +s = """ + + +&y;"> +yyy"> +]> + + &x; + &x; +""" +expect="""10 test 0 +1 test 0 +14 #text 1 +5 x 1 +14 #text 1 +5 x 1 +14 #text 1 +15 test 0 +""" +res="" +err="" + +input = libxml2.inputBuffer(str_io(s)) +reader = input.newTextReader("test5") +reader.SetParserProp(libxml2.PARSER_VALIDATE,1) +while reader.Read() == 1: + res = res + "%s %s %d\n" % (reader.NodeType(),reader.Name(),reader.Depth()) + +if res != expect: + print("test5 failed: unexpected output") + print(res) +if err != "": + print("test5 failed: validation error found") + print(err) + +# +# cleanup +# +del input +del reader + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/reader3.py b/libxml2-2.9.10/python/tests/reader3.py new file mode 100755 index 0000000..4302b6c --- /dev/null +++ b/libxml2-2.9.10/python/tests/reader3.py @@ -0,0 +1,160 @@ +#!/usr/bin/python -u +# +# this tests the entities substitutions with the XmlTextReader interface +# +import sys +import libxml2 +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +docstr=""" +test

"> +]> +&tst;""" + +# Memory debug specific +libxml2.debugMemory(1) + +# +# First test, normal don't substitute entities. +# +f = str_io(docstr) +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test_noent") +ret = reader.Read() +if ret != 1: + print("Error reading to root") + sys.exit(1) +if reader.Name() == "doc" or reader.NodeType() == 10: + ret = reader.Read() +if ret != 1: + print("Error reading to root") + sys.exit(1) +if reader.Name() != "doc" or reader.NodeType() != 1: + print("test_normal: Error reading the root element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test_normal: Error reading to the entity") + sys.exit(1) +if reader.Name() != "tst" or reader.NodeType() != 5: + print("test_normal: Error reading the entity") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test_normal: Error reading to the end of root") + sys.exit(1) +if reader.Name() != "doc" or reader.NodeType() != 15: + print("test_normal: Error reading the end of the root element") + sys.exit(1) +ret = reader.Read() +if ret != 0: + print("test_normal: Error detecting the end") + sys.exit(1) + +# +# Second test, completely substitute the entities. +# +f = str_io(docstr) +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test_noent") +reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES, 1) +ret = reader.Read() +if ret != 1: + print("Error reading to root") + sys.exit(1) +if reader.Name() == "doc" or reader.NodeType() == 10: + ret = reader.Read() +if ret != 1: + print("Error reading to root") + sys.exit(1) +if reader.Name() != "doc" or reader.NodeType() != 1: + print("test_noent: Error reading the root element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test_noent: Error reading to the entity content") + sys.exit(1) +if reader.Name() != "p" or reader.NodeType() != 1: + print("test_noent: Error reading the p element from entity") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test_noent: Error reading to the text node") + sys.exit(1) +if reader.NodeType() != 3 or reader.Value() != "test": + print("test_noent: Error reading the text node") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test_noent: Error reading to the end of p element") + sys.exit(1) +if reader.Name() != "p" or reader.NodeType() != 15: + print("test_noent: Error reading the end of the p element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test_noent: Error reading to the end of root") + sys.exit(1) +if reader.Name() != "doc" or reader.NodeType() != 15: + print("test_noent: Error reading the end of the root element") + sys.exit(1) +ret = reader.Read() +if ret != 0: + print("test_noent: Error detecting the end") + sys.exit(1) + +# +# third test, crazy stuff about empty element in external parsed entities +# +s = """ +]> +&simplestruct2.ent; +""" +expect="""10 struct 0 0 +1 struct 0 0 +1 descr 1 1 +15 struct 0 0 +""" +res="" +simplestruct2_ent="""""" + +def myResolver(URL, ID, ctxt): + if URL == "simplestruct2.ent": + return(str_io(simplestruct2_ent)) + return None + +libxml2.setEntityLoader(myResolver) + +input = libxml2.inputBuffer(str_io(s)) +reader = input.newTextReader("test3") +reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) +while reader.Read() == 1: + res = res + "%s %s %d %d\n" % (reader.NodeType(),reader.Name(), + reader.Depth(),reader.IsEmptyElement()) + +if res != expect: + print("test3 failed: unexpected output") + print(res) + sys.exit(1) + +# +# cleanup +# +del f +del input +del reader + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/reader4.py b/libxml2-2.9.10/python/tests/reader4.py new file mode 100755 index 0000000..0bb3e3f --- /dev/null +++ b/libxml2-2.9.10/python/tests/reader4.py @@ -0,0 +1,50 @@ +#!/usr/bin/python -u +# +# this tests the basic APIs of the XmlTextReader interface +# +import libxml2 +import sys +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +# Memory debug specific +libxml2.debugMemory(1) + +def tst_reader(s): + f = str_io(s) + input = libxml2.inputBuffer(f) + reader = input.newTextReader("tst") + res = "" + while reader.Read(): + res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(), + reader.Value(), reader.IsEmptyElement()) + if reader.NodeType() == 1: # Element + while reader.MoveToNextAttribute(): + res = res + "-- %s (%s) [%s]\n" % (reader.NodeType(), + reader.Name(),reader.Value()) + return res + +expect="""1 (test) [None] 0 +1 (b) [None] 1 +1 (c) [None] 1 +15 (test) [None] 0 +""" + +res = tst_reader("""""") + +if res != expect: + print("Did not get the expected error message:") + print(res) + sys.exit(1) + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/reader5.py b/libxml2-2.9.10/python/tests/reader5.py new file mode 100755 index 0000000..82d0dae --- /dev/null +++ b/libxml2-2.9.10/python/tests/reader5.py @@ -0,0 +1,47 @@ +#!/usr/bin/python -u +# +# this tests the Expand() API of the xmlTextReader interface +# this extract the Dragon bibliography entries from the XML specification +# +import libxml2 +import sys + +# Memory debug specific +libxml2.debugMemory(1) + +expect="""Aho, Alfred V., +Ravi Sethi, and Jeffrey D. Ullman. +Compilers: Principles, Techniques, and Tools. +Reading: Addison-Wesley, 1986, rpt. corr. 1988.""" + +f = open('../../test/valid/REC-xml-19980210.xml', 'rb') +input = libxml2.inputBuffer(f) +reader = input.newTextReader("REC") +res="" +while reader.Read() > 0: + while reader.Name() == 'bibl': + node = reader.Expand() # expand the subtree + if node.xpathEval("@id = 'Aho'"): # use XPath on it + res = res + node.serialize() + if reader.Next() != 1: # skip the subtree + break; + +if res != expect: + print("Error: didn't get the expected output") + print("got '%s'" % (res)) + print("expected '%s'" % (expect)) + + +# +# cleanup +# +del input +del reader + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/reader6.py b/libxml2-2.9.10/python/tests/reader6.py new file mode 100755 index 0000000..ef33b18 --- /dev/null +++ b/libxml2-2.9.10/python/tests/reader6.py @@ -0,0 +1,128 @@ +#!/usr/bin/python -u +# +# this tests the entities substitutions with the XmlTextReader interface +# +import sys +import libxml2 +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +schema=""" + + + + + + + + + + + + + + +""" +# Memory debug specific +libxml2.debugMemory(1) + +# +# Parse the Relax NG Schemas +# +rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema)) +rngs = rngp.relaxNGParse() +del rngp + +# +# Parse and validate the correct document +# +docstr=""" + +100 +""" + +f = str_io(docstr) +input = libxml2.inputBuffer(f) +reader = input.newTextReader("correct") +reader.RelaxNGSetSchema(rngs) +ret = reader.Read() +while ret == 1: + ret = reader.Read() + +if ret != 0: + print("Error parsing the document") + sys.exit(1) + +if reader.IsValid() != 1: + print("Document failed to validate") + sys.exit(1) + +# +# Parse and validate the incorrect document +# +docstr=""" + +1000 +""" + +err="" +# RNG errors are not as good as before , TODO +#expect="""RNG validity error: file error line 3 element text +#Type byte doesn't allow value '1000' +#RNG validity error: file error line 3 element text +#Error validating datatype byte +#RNG validity error: file error line 3 element text +#Element item failed to validate content +#""" +expect="""Type byte doesn't allow value '1000' +Error validating datatype byte +Element item failed to validate content +""" + +def callback(ctx, str): + global err + err = err + "%s" % (str) +libxml2.registerErrorHandler(callback, "") + +f = str_io(docstr) +input = libxml2.inputBuffer(f) +reader = input.newTextReader("error") +reader.RelaxNGSetSchema(rngs) +ret = reader.Read() +while ret == 1: + ret = reader.Read() + +if ret != 0: + print("Error parsing the document") + sys.exit(1) + +if reader.IsValid() != 0: + print("Document failed to detect the validation error") + sys.exit(1) + +if err != expect: + print("Did not get the expected error message:") + print(err) + sys.exit(1) + +# +# cleanup +# +del f +del input +del reader +del rngs +libxml2.relaxNGCleanupTypes() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/reader7.py b/libxml2-2.9.10/python/tests/reader7.py new file mode 100755 index 0000000..c88e370 --- /dev/null +++ b/libxml2-2.9.10/python/tests/reader7.py @@ -0,0 +1,101 @@ +#!/usr/bin/python -u +# +# this tests the entities substitutions with the XmlTextReader interface +# +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +result = "" +def processNode(reader): + global result + + result = result + "%d %d %s %d\n" % (reader.Depth(), reader.NodeType(), + reader.Name(), reader.IsEmptyElement()) + +# +# Parse a document testing the readerForxxx API +# +docstr=""" + +100 +""" +expect="""0 1 foo 0 +1 14 #text 0 +1 1 label 0 +2 3 #text 0 +1 15 label 0 +1 14 #text 0 +1 1 item 0 +2 3 #text 0 +1 15 item 0 +1 14 #text 0 +0 15 foo 0 +""" +result = "" + +reader = libxml2.readerForDoc(docstr, "test1", None, 0) +ret = reader.Read() +while ret == 1: + processNode(reader) + ret = reader.Read() + +if ret != 0: + print("Error parsing the document test1") + sys.exit(1) + +if result != expect: + print("Unexpected result for test1") + print(result) + sys.exit(1) + +# +# Reuse the reader for another document testing the ReaderNewxxx API +# +docstr=""" + +1000 +""" +expect="""0 1 foo 0 +1 14 #text 0 +1 1 label 0 +2 3 #text 0 +1 15 label 0 +1 14 #text 0 +1 1 item 0 +2 3 #text 0 +1 15 item 0 +1 14 #text 0 +0 15 foo 0 +""" +result = "" + +reader.NewDoc(docstr, "test2", None, 0) +ret = reader.Read() +while ret == 1: + processNode(reader) + ret = reader.Read() + +if ret != 0: + print("Error parsing the document test2") + sys.exit(1) + +if result != expect: + print("Unexpected result for test2") + print(result) + sys.exit(1) + +# +# cleanup +# +del reader + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/reader8.py b/libxml2-2.9.10/python/tests/reader8.py new file mode 100755 index 0000000..de2dcd6 --- /dev/null +++ b/libxml2-2.9.10/python/tests/reader8.py @@ -0,0 +1,36 @@ +#!/usr/bin/python -u +# +# this tests the entities substitutions with the XmlTextReader interface +# +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +# +# Parse a document testing the Close() API +# +docstr=""" + +100 +""" + +reader = libxml2.readerForDoc(docstr, "test1", None, 0) +ret = reader.Read() +ret = reader.Read() +ret = reader.Close() + +if ret != 0: + print("Error closing the document test1") + sys.exit(1) + +del reader + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/readererr.py b/libxml2-2.9.10/python/tests/readererr.py new file mode 100755 index 0000000..c8ceba5 --- /dev/null +++ b/libxml2-2.9.10/python/tests/readererr.py @@ -0,0 +1,56 @@ +#!/usr/bin/python -u +# +# this tests the basic APIs of the XmlTextReader interface +# +import libxml2 +import sys +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +# Memory debug specific +libxml2.debugMemory(1) + +expect="""--> (3) test1:1:xmlns: URI foo is not absolute +--> (4) test1:1:Opening and ending tag mismatch: c line 1 and a +""" +err="" +def myErrorHandler(arg,msg,severity,locator): + global err + err = err + "%s (%d) %s:%d:%s" % (arg,severity,locator.BaseURI(),locator.LineNumber(),msg) + +f = str_io("""content of c""") +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test1") +reader.SetErrorHandler(myErrorHandler,"-->") +while reader.Read() == 1: + pass + +if err != expect: + print("error") + print("received %s" %(err)) + print("expected %s" %(expect)) + sys.exit(1) + +reader.SetErrorHandler(None,None) +if reader.GetErrorHandler() != (None,None): + print("GetErrorHandler failed") + sys.exit(1) + +# +# cleanup for memory allocation counting +# +del f +del input +del reader + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/readernext.py b/libxml2-2.9.10/python/tests/readernext.py new file mode 100755 index 0000000..fcb9ae3 --- /dev/null +++ b/libxml2-2.9.10/python/tests/readernext.py @@ -0,0 +1,86 @@ +#!/usr/bin/python -u +# -*- coding: ISO-8859-1 -*- +# +# this tests the next API of the XmlTextReader interface +# +import libxml2 +import sys +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +# Memory debug specific +libxml2.debugMemory(1) + +f = str_io("""content of d""") +input = libxml2.inputBuffer(f) +reader = input.newTextReader("test_next") +ret = reader.Read() +if ret != 1: + print("test_next: Error reading to first element") + sys.exit(1) +if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \ + reader.NodeType() != 1 or reader.HasAttributes() != 0: + print("test_next: Error reading the first element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test_next: Error reading to second element") + sys.exit(1) +if reader.Name() != "b" or reader.IsEmptyElement() != 0 or \ + reader.NodeType() != 1 or reader.HasAttributes() != 0: + print("test_next: Error reading the second element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test_next: Error reading to third element") + sys.exit(1) +if reader.Name() != "c" or reader.NodeType() != 1 or \ + reader.HasAttributes() != 0: + print("test_next: Error reading the third element") + sys.exit(1) +ret = reader.Read() +if ret != 1: + print("test_next: Error reading to end of third element") + sys.exit(1) +if reader.Name() != "b" or reader.NodeType() != 15: + print("test_next: Error reading to end of second element") + sys.exit(1) +ret = reader.Next() +if ret != 1: + print("test_next: Error moving to third element") + sys.exit(1) +if reader.Name() != "d" or reader.IsEmptyElement() != 0 or \ + reader.NodeType() != 1 or reader.HasAttributes() != 0: + print("test_next: Error reading third element") + sys.exit(1) +ret = reader.Next() +if ret != 1: + print("test_next: Error reading to end of first element") + sys.exit(1) +if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \ + reader.NodeType() != 15 or reader.HasAttributes() != 0: + print("test_next: Error reading the end of first element") + sys.exit(1) +ret = reader.Read() +if ret != 0: + print("test_next: Error reading to end of document") + sys.exit(1) + +# +# cleanup for memory allocation counting +# +del f +del input +del reader + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/regexp.py b/libxml2-2.9.10/python/tests/regexp.py new file mode 100755 index 0000000..a03e459 --- /dev/null +++ b/libxml2-2.9.10/python/tests/regexp.py @@ -0,0 +1,32 @@ +#!/usr/bin/python -u +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +re = libxml2.regexpCompile("a|b") +if re.regexpExec("a") != 1: + print("error checking 'a'") + sys.exit(1) +if re.regexpExec("b") != 1: + print("error checking 'b'") + sys.exit(1) +if re.regexpExec("ab") != 0: + print("error checking 'ab'") + sys.exit(1) +if re.regexpExec("") != 0: + print("error checking 'ab'") + sys.exit(1) +if re.regexpIsDeterminist() != 1: + print("error checking determinism") + sys.exit(1) +del re + + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/relaxng.py b/libxml2-2.9.10/python/tests/relaxng.py new file mode 100755 index 0000000..fa3d327 --- /dev/null +++ b/libxml2-2.9.10/python/tests/relaxng.py @@ -0,0 +1,48 @@ +#!/usr/bin/python -u +import libxml2 +import sys + +# Memory debug specific +libxml2.debugMemory(1) + +schema=""" + + A foo element. + + + + + + + +""" +instance=""" +""" + +rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema)) +rngs = rngp.relaxNGParse() +ctxt = rngs.relaxNGNewValidCtxt() +doc = libxml2.parseDoc(instance) +ret = doc.relaxNGValidateDoc(ctxt) +if ret != 0: + print("error doing RelaxNG validation") + sys.exit(1) + +doc.freeDoc() +del rngp +del rngs +del ctxt +libxml2.relaxNGCleanupTypes() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() + diff --git a/libxml2-2.9.10/python/tests/resolver.py b/libxml2-2.9.10/python/tests/resolver.py new file mode 100755 index 0000000..6f21f52 --- /dev/null +++ b/libxml2-2.9.10/python/tests/resolver.py @@ -0,0 +1,44 @@ +#!/usr/bin/python -u +import sys +import libxml2 +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO + +# Memory debug specific +libxml2.debugMemory(1) + +def myResolver(URL, ID, ctxt): + return(str_io("")) + +libxml2.setEntityLoader(myResolver) + +doc = libxml2.parseFile("doesnotexist.xml") +root = doc.children +if root.name != "foo": + print("root element name error") + sys.exit(1) +doc.freeDoc() + +i = 0 +while i < 5000: + doc = libxml2.parseFile("doesnotexist.xml") + root = doc.children + if root.name != "foo": + print("root element name error") + sys.exit(1) + doc.freeDoc() + i = i + 1 + + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() + diff --git a/libxml2-2.9.10/python/tests/schema.py b/libxml2-2.9.10/python/tests/schema.py new file mode 100755 index 0000000..8089272 --- /dev/null +++ b/libxml2-2.9.10/python/tests/schema.py @@ -0,0 +1,52 @@ +#!/usr/bin/python -u +import libxml2 +import sys + +# Memory debug specific +libxml2.debugMemory(1) + +schema=""" + + + + + + + + + + + +""" + +instance=""" + + Raymond + G + Bayliss + +""" + +ctxt_parser = libxml2.schemaNewMemParserCtxt(schema, len(schema)) +ctxt_schema = ctxt_parser.schemaParse() +ctxt_valid = ctxt_schema.schemaNewValidCtxt() +doc = libxml2.parseDoc(instance) +ret = doc.schemaValidateDoc(ctxt_valid) +if ret != 0: + print("error doing schema validation") + sys.exit(1) + +doc.freeDoc() +del ctxt_parser +del ctxt_schema +del ctxt_valid +libxml2.schemaCleanupTypes() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() + diff --git a/libxml2-2.9.10/python/tests/serialize.py b/libxml2-2.9.10/python/tests/serialize.py new file mode 100755 index 0000000..80b901a --- /dev/null +++ b/libxml2-2.9.10/python/tests/serialize.py @@ -0,0 +1,150 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +# +# Testing XML document serialization +# +doc = libxml2.parseDoc("""hello""") +str = doc.serialize() +if str != """ +hello +""": + print("error serializing XML document 1") + sys.exit(1) +str = doc.serialize("iso-8859-1") +if str != """ +hello +""": + print("error serializing XML document 2") + sys.exit(1) +str = doc.serialize(format=1) +if str != """ + + hello + +""": + print("error serializing XML document 3") + sys.exit(1) +str = doc.serialize("iso-8859-1", 1) +if str != """ + + hello + +""": + print("error serializing XML document 4") + sys.exit(1) + +# +# Test serializing a subnode +# +root = doc.getRootElement() +str = root.serialize() +if str != """hello""": + print("error serializing XML root 1") + sys.exit(1) +str = root.serialize("iso-8859-1") +if str != """hello""": + print("error serializing XML root 2") + sys.exit(1) +str = root.serialize(format=1) +if str != """ + hello +""": + print("error serializing XML root 3") + sys.exit(1) +str = root.serialize("iso-8859-1", 1) +if str != """ + hello +""": + print("error serializing XML root 4") + sys.exit(1) +doc.freeDoc() + +# +# Testing HTML document serialization +# +doc = libxml2.htmlParseDoc("""Hello

hello""", None) +str = doc.serialize() +if str != """ +Hello

hello

+""": + print("error serializing HTML document 1") + sys.exit(1) +str = doc.serialize("ISO-8859-1") +if str != """ +Hello

hello

+""": + print("error serializing HTML document 2") + sys.exit(1) +str = doc.serialize(format=1) +if str != """ + + + +Hello + +

hello

+ +""": + print("error serializing HTML document 3") + sys.exit(1) +str = doc.serialize("iso-8859-1", 1) +if str != """ + + + +Hello + +

hello

+ +""": + print("error serializing HTML document 4") + sys.exit(1) + +# +# Test serializing a subnode +# +doc.htmlSetMetaEncoding(None) +root = doc.getRootElement() +str = root.serialize() +if str != """Hello

hello

""": + print("error serializing HTML root 1") + sys.exit(1) +str = root.serialize("ISO-8859-1") +if str != """Hello

hello

""": + print("error serializing HTML root 2") + sys.exit(1) +str = root.serialize(format=1) +if str != """ + + +Hello + +

hello

+""": + print("error serializing HTML root 3") + sys.exit(1) +str = root.serialize("iso-8859-1", 1) +if str != """ + + +Hello + +

hello

+""": + print("error serializing HTML root 4") + sys.exit(1) + +doc.freeDoc() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/sync.py b/libxml2-2.9.10/python/tests/sync.py new file mode 100755 index 0000000..5a8609e --- /dev/null +++ b/libxml2-2.9.10/python/tests/sync.py @@ -0,0 +1,138 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +log = "" + +class callback: + def startDocument(self): + global log + log = log + "startDocument:" + + def endDocument(self): + global log + log = log + "endDocument:" + + def startElement(self, tag, attrs): + global log + log = log + "startElement %s %s:" % (tag, attrs) + + def endElement(self, tag): + global log + log = log + "endElement %s:" % (tag) + + def characters(self, data): + global log + log = log + "characters: %s:" % (data) + + def warning(self, msg): + global log + log = log + "warning: %s:" % (msg) + + def error(self, msg): + global log + log = log + "error: %s:" % (msg) + + def fatalError(self, msg): + global log + log = log + "fatalError: %s:" % (msg) + +handler = callback() + +log="" +chunk="""""" +ctxt = libxml2.createPushParser(handler, None, 0, "test.xml") +ctxt.parseChunk(chunk, len(chunk), 0) +ctxt=None + +reference = "startDocument:startElement foo None:startElement bar2 None:endElement bar2:" +if log != reference: + print("Error got: %s" % log) + print("Expected: %s" % reference) + sys.exit(1) + +log="" +chunk="""""" +ctxt = libxml2.createPushParser(handler, None, 0, "test.xml") +ctxt.parseChunk(chunk, len(chunk), 0) +ctxt=None + +reference = "startDocument:startElement foo None:startElement bar2 None:endElement bar2:" +if log != reference: + print("Error got: %s" % log) + print("Expected: %s" % reference) + sys.exit(1) + +log="" +chunk="""""" +ctxt = libxml2.createPushParser(handler, None, 0, "test.xml") +ctxt.parseChunk(chunk, len(chunk), 0) +ctxt=None + +reference = "startDocument:startElement foo None:startElement bar2 None:" +if log != reference: + print("Error got: %s" % log) + print("Expected: %s" % reference) + sys.exit(1) + +log="" +chunk="""""" +ctxt = libxml2.createPushParser(handler, None, 0, "test.xml") +ctxt.parseChunk(chunk, len(chunk), 0) +ctxt=None + +reference1 = "startDocument:startElement foo None:startElement bar2 {'a': '1', 'b': '2'}:endElement bar2:" +reference2 = "startDocument:startElement foo None:startElement bar2 {'b': '2', 'a': '1'}:endElement bar2:" +if log not in (reference1, reference2): + print("Error got: %s" % log) + print("Expected: %s" % reference) + sys.exit(1) + +log="" +chunk="""""" +ctxt = libxml2.createPushParser(handler, None, 0, "test.xml") +ctxt.parseChunk(chunk, len(chunk), 0) +ctxt=None + +reference1 = "startDocument:startElement foo None:startElement bar2 {'a': '1', 'b': '2'}:" +reference2 = "startDocument:startElement foo None:startElement bar2 {'b': '2', 'a': '1'}:" +if log not in (reference1, reference2): + print("Error got: %s" % log) + print("Expected: %s" % reference) + sys.exit(1) + +log="" +chunk="""""" +ctxt = libxml2.createPushParser(handler, None, 0, "test.xml") +ctxt.parseChunk(chunk, len(chunk), 0) +ctxt=None + +reference1 = "startDocument:startElement foo None:startElement bar2 {'a': '1', 'b': '2'}:endElement bar2:" +reference2 = "startDocument:startElement foo None:startElement bar2 {'b': '2', 'a': '1'}:endElement bar2:" +if log not in (reference1, reference2): + print("Error got: %s" % log) + print("Expected: %s" % reference) + sys.exit(1) + +log="" +chunk=""" diff --git a/libxml2-2.9.10/python/tests/thread2.py b/libxml2-2.9.10/python/tests/thread2.py new file mode 100755 index 0000000..2749eb0 --- /dev/null +++ b/libxml2-2.9.10/python/tests/thread2.py @@ -0,0 +1,99 @@ +#!/usr/bin/python -u +import string, sys, time +try: + from _thread import get_ident +except: + from thread import get_ident +from threading import Thread, Lock + +import libxml2 + +THREADS_COUNT = 15 + +failed = 0 + +class ErrorHandler: + + def __init__(self): + self.errors = [] + self.lock = Lock() + + def handler(self,ctx,str): + self.lock.acquire() + self.errors.append(str) + self.lock.release() + +def getLineNumbersDefault(): + old = libxml2.lineNumbersDefault(0) + libxml2.lineNumbersDefault(old) + return old + +def test(expectedLineNumbersDefault): + time.sleep(1) + global failed + # check a per thread-global + if expectedLineNumbersDefault != getLineNumbersDefault(): + failed = 1 + print("FAILED to obtain correct value for " \ + "lineNumbersDefault in thread %d" % get_ident()) + # check ther global error handler + # (which is NOT per-thread in the python bindings) + try: + doc = libxml2.parseFile("bad.xml") + except: + pass + else: + assert "failed" + +# global error handler +eh = ErrorHandler() +libxml2.registerErrorHandler(eh.handler,"") + +# set on the main thread only +libxml2.lineNumbersDefault(1) +test(1) +ec = len(eh.errors) +if ec == 0: + print("FAILED: should have obtained errors") + sys.exit(1) + +ts = [] +for i in range(THREADS_COUNT): + # expect 0 for lineNumbersDefault because + # the new value has been set on the main thread only + ts.append(Thread(target=test,args=(0,))) +for t in ts: + t.start() +for t in ts: + t.join() + +if len(eh.errors) != ec+THREADS_COUNT*ec: + print("FAILED: did not obtain the correct number of errors") + sys.exit(1) + +# set lineNumbersDefault for future new threads +libxml2.thrDefLineNumbersDefaultValue(1) +ts = [] +for i in range(THREADS_COUNT): + # expect 1 for lineNumbersDefault + ts.append(Thread(target=test,args=(1,))) +for t in ts: + t.start() +for t in ts: + t.join() + +if len(eh.errors) != ec+THREADS_COUNT*ec*2: + print("FAILED: did not obtain the correct number of errors") + sys.exit(1) + +if failed: + print("FAILED") + sys.exit(1) + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/tst.py b/libxml2-2.9.10/python/tests/tst.py new file mode 100755 index 0000000..57a7318 --- /dev/null +++ b/libxml2-2.9.10/python/tests/tst.py @@ -0,0 +1,28 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +doc = libxml2.parseFile("tst.xml") +if doc.name != "tst.xml": + print("doc.name failed") + sys.exit(1) +root = doc.children +if root.name != "doc": + print("root.name failed") + sys.exit(1) +child = root.children +if child.name != "foo": + print("child.name failed") + sys.exit(1) +doc.freeDoc() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/tst.xml b/libxml2-2.9.10/python/tests/tst.xml new file mode 100644 index 0000000..751d46d --- /dev/null +++ b/libxml2-2.9.10/python/tests/tst.xml @@ -0,0 +1 @@ +bar diff --git a/libxml2-2.9.10/python/tests/tstLastError.py b/libxml2-2.9.10/python/tests/tstLastError.py new file mode 100755 index 0000000..81d0acc --- /dev/null +++ b/libxml2-2.9.10/python/tests/tstLastError.py @@ -0,0 +1,82 @@ +#!/usr/bin/python -u +import sys, unittest + +import libxml2 + +class TestCase(unittest.TestCase): + + def runTest(self): + self.test1() + self.test2() + + def setUp(self): + libxml2.debugMemory(1) + + def tearDown(self): + libxml2.cleanupParser() + if libxml2.debugMemory(1) != 0: + libxml2.dumpMemory() + self.fail("Memory leak %d bytes" % (libxml2.debugMemory(1),)) + else: + print("OK") + + def failUnlessXmlError(self,f,args,exc,domain,code,message,level,file,line): + """Run function f, with arguments args and expect an exception exc; + when the exception is raised, check the libxml2.lastError for + expected values.""" + # disable the default error handler + libxml2.registerErrorHandler(None,None) + try: + f(*args) + except exc: + e = libxml2.lastError() + if e is None: + self.fail("lastError not set") + if 0: + print("domain = ",e.domain()) + print("code = ",e.code()) + print("message =",repr(e.message())) + print("level =",e.level()) + print("file =",e.file()) + print("line =",e.line()) + print() + self.failUnlessEqual(domain,e.domain()) + self.failUnlessEqual(code,e.code()) + self.failUnlessEqual(message,e.message()) + self.failUnlessEqual(level,e.level()) + self.failUnlessEqual(file,e.file()) + self.failUnlessEqual(line,e.line()) + else: + self.fail("exception %s should have been raised" % exc) + + def test1(self): + """Test readFile with a file that does not exist""" + self.failUnlessXmlError(libxml2.readFile, + ("dummy.xml",None,0), + libxml2.treeError, + domain=libxml2.XML_FROM_IO, + code=libxml2.XML_IO_LOAD_ERROR, + message='failed to load external entity "dummy.xml"\n', + level=libxml2.XML_ERR_WARNING, + file=None, + line=0) + + def test2(self): + """Test a well-formedness error: we get the last error only""" + s = "\n\n" + self.failUnlessXmlError(libxml2.readMemory, + (s,len(s),"dummy.xml",None,0), + libxml2.treeError, + domain=libxml2.XML_FROM_PARSER, + code=libxml2.XML_ERR_LTSLASH_REQUIRED, + message='EndTag: \'""" +instance=""" +""" + +dtd = libxml2.parseDTD(None, 'test.dtd') +ctxt = libxml2.newValidCtxt() +libxml2mod.xmlSetValidErrors(ctxt._o, error, error) +doc = libxml2.parseDoc(instance) +ret = doc.validateDtd(ctxt, dtd) +if ret != 1: + print("error doing DTD validation") + sys.exit(1) + +doc.freeDoc() +dtd.freeDtd() +del dtd +del ctxt + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/tstxpath.py b/libxml2-2.9.10/python/tests/tstxpath.py new file mode 100755 index 0000000..0ba5a6d --- /dev/null +++ b/libxml2-2.9.10/python/tests/tstxpath.py @@ -0,0 +1,63 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +#memory debug specific +libxml2.debugMemory(1) + +called = "" + +def foo(ctx, x): + global called + + # + # test that access to the XPath evaluation contexts + # + pctxt = libxml2.xpathParserContext(_obj=ctx) + ctxt = pctxt.context() + called = ctxt.function() + return x + 1 + +def bar(ctxt, x): + return "%d" % (x + 2) + +doc = libxml2.parseFile("tst.xml") +ctxt = doc.xpathNewContext() +res = ctxt.xpathEval("//*") +if len(res) != 2: + print("xpath query: wrong node set size") + sys.exit(1) +if res[0].name != "doc" or res[1].name != "foo": + print("xpath query: wrong node set value") + sys.exit(1) +libxml2.registerXPathFunction(ctxt._o, "foo", None, foo) +libxml2.registerXPathFunction(ctxt._o, "bar", None, bar) +i = 10000 +while i > 0: + res = ctxt.xpathEval("foo(1)") + if res != 2: + print("xpath extension failure") + sys.exit(1) + i = i - 1 +i = 10000 +while i > 0: + res = ctxt.xpathEval("bar(1)") + if res != "3": + print("xpath extension failure got %s expecting '3'") + sys.exit(1) + i = i - 1 +doc.freeDoc() +ctxt.xpathFreeContext() + +if called != "foo": + print("xpath function: failed to access the context") + print("xpath function: %s" % (called)) + sys.exit(1) + +#memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/valid.xml b/libxml2-2.9.10/python/tests/valid.xml new file mode 100644 index 0000000..8a7f679 --- /dev/null +++ b/libxml2-2.9.10/python/tests/valid.xml @@ -0,0 +1,4 @@ + +]> + diff --git a/libxml2-2.9.10/python/tests/validDTD.py b/libxml2-2.9.10/python/tests/validDTD.py new file mode 100755 index 0000000..4b03b8e --- /dev/null +++ b/libxml2-2.9.10/python/tests/validDTD.py @@ -0,0 +1,59 @@ +#!/usr/bin/python -u +import libxml2 +import sys + +ARG = 'test string' + +class ErrorHandler: + + def __init__(self): + self.errors = [] + + def handler(self, msg, data): + if data != ARG: + raise Exception("Error handler did not receive correct argument") + self.errors.append(msg) + + +# Memory debug specific +libxml2.debugMemory(1) + +dtd="""""" +valid=""" +""" + +invalid=""" +""" + +dtd = libxml2.parseDTD(None, 'test.dtd') +ctxt = libxml2.newValidCtxt() +e = ErrorHandler() +ctxt.setValidityErrorHandler(e.handler, e.handler, ARG) + +# Test valid document +doc = libxml2.parseDoc(valid) +ret = doc.validateDtd(ctxt, dtd) +if ret != 1 or e.errors: + print("error doing DTD validation") + sys.exit(1) +doc.freeDoc() + +# Test invalid document +doc = libxml2.parseDoc(invalid) +ret = doc.validateDtd(ctxt, dtd) +if ret != 0 or not e.errors: + print("Error: document supposed to be invalid") +doc.freeDoc() + +dtd.freeDtd() +del dtd +del ctxt + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() + diff --git a/libxml2-2.9.10/python/tests/validRNG.py b/libxml2-2.9.10/python/tests/validRNG.py new file mode 100755 index 0000000..57f13a4 --- /dev/null +++ b/libxml2-2.9.10/python/tests/validRNG.py @@ -0,0 +1,76 @@ +#!/usr/bin/python -u +import libxml2 +import sys + +ARG = 'test string' + +class ErrorHandler: + + def __init__(self): + self.errors = [] + + def handler(self, msg, data): + if data != ARG: + raise Exception("Error handler did not receive correct argument") + self.errors.append(msg) + +# Memory debug specific +libxml2.debugMemory(1) + +schema=""" + + A foo element. + + + + + + + +""" + +valid=""" +""" + +invalid=""" +bad""" + +rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema)) +rngs = rngp.relaxNGParse() +ctxt = rngs.relaxNGNewValidCtxt() +e = ErrorHandler() +ctxt.setValidityErrorHandler(e.handler, e.handler, ARG) + +# Test valid document +doc = libxml2.parseDoc(valid) +ret = doc.relaxNGValidateDoc(ctxt) +if ret != 0 or e.errors: + print("error doing RelaxNG validation") + sys.exit(1) +doc.freeDoc() + +# Test invalid document +doc = libxml2.parseDoc(invalid) +ret = doc.relaxNGValidateDoc(ctxt) +if ret == 0 or not e.errors: + print("Error: document supposed to be RelaxNG invalid") + sys.exit(1) +doc.freeDoc() + +del rngp +del rngs +del ctxt +libxml2.relaxNGCleanupTypes() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() + diff --git a/libxml2-2.9.10/python/tests/validSchemas.py b/libxml2-2.9.10/python/tests/validSchemas.py new file mode 100755 index 0000000..cc543f3 --- /dev/null +++ b/libxml2-2.9.10/python/tests/validSchemas.py @@ -0,0 +1,83 @@ +#!/usr/bin/python -u +import libxml2 +import sys + +ARG = 'test string' + +class ErrorHandler: + + def __init__(self): + self.errors = [] + + def handler(self, msg, data): + if data != ARG: + raise Exception("Error handler did not receive correct argument") + self.errors.append(msg) + +# Memory debug specific +libxml2.debugMemory(1) + +schema=""" + + + + + + + + + + + +""" + +valid=""" + + Raymond + G + Bayliss + +""" + +invalid=""" + + G + Bayliss + +""" + +e = ErrorHandler() +ctxt_parser = libxml2.schemaNewMemParserCtxt(schema, len(schema)) +ctxt_schema = ctxt_parser.schemaParse() +ctxt_valid = ctxt_schema.schemaNewValidCtxt() +ctxt_valid.setValidityErrorHandler(e.handler, e.handler, ARG) + +# Test valid document +doc = libxml2.parseDoc(valid) +ret = doc.schemaValidateDoc(ctxt_valid) +if ret != 0 or e.errors: + print("error doing schema validation") + sys.exit(1) +doc.freeDoc() + +# Test invalid document +doc = libxml2.parseDoc(invalid) +ret = doc.schemaValidateDoc(ctxt_valid) +if ret == 0 or not e.errors: + print("Error: document supposer to be schema invalid") + sys.exit(1) +doc.freeDoc() + +del ctxt_parser +del ctxt_schema +del ctxt_valid +libxml2.schemaCleanupTypes() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() + diff --git a/libxml2-2.9.10/python/tests/validate.py b/libxml2-2.9.10/python/tests/validate.py new file mode 100755 index 0000000..16c0386 --- /dev/null +++ b/libxml2-2.9.10/python/tests/validate.py @@ -0,0 +1,82 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +ctxt = libxml2.createFileParserCtxt("valid.xml") +ctxt.validate(1) +ctxt.parseDocument() +doc = ctxt.doc() +valid = ctxt.isValid() + +if doc.name != "valid.xml": + print("doc.name failed") + sys.exit(1) +root = doc.children +if root.name != "doc": + print("root.name failed") + sys.exit(1) +if valid != 1: + print("validity chec failed") + sys.exit(1) +doc.freeDoc() + +i = 1000 +while i > 0: + ctxt = libxml2.createFileParserCtxt("valid.xml") + ctxt.validate(1) + ctxt.parseDocument() + doc = ctxt.doc() + valid = ctxt.isValid() + doc.freeDoc() + if valid != 1: + print("validity check failed") + sys.exit(1) + i = i - 1 + +#desactivate error messages from the validation +def noerr(ctx, str): + pass + +libxml2.registerErrorHandler(noerr, None) + +ctxt = libxml2.createFileParserCtxt("invalid.xml") +ctxt.validate(1) +ctxt.parseDocument() +doc = ctxt.doc() +valid = ctxt.isValid() +if doc.name != "invalid.xml": + print("doc.name failed") + sys.exit(1) +root = doc.children +if root.name != "doc": + print("root.name failed") + sys.exit(1) +if valid != 0: + print("validity chec failed") + sys.exit(1) +doc.freeDoc() + +i = 1000 +while i > 0: + ctxt = libxml2.createFileParserCtxt("invalid.xml") + ctxt.validate(1) + ctxt.parseDocument() + doc = ctxt.doc() + valid = ctxt.isValid() + doc.freeDoc() + if valid != 0: + print("validity check failed") + sys.exit(1) + i = i - 1 +del ctxt + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/walker.py b/libxml2-2.9.10/python/tests/walker.py new file mode 100755 index 0000000..47f0557 --- /dev/null +++ b/libxml2-2.9.10/python/tests/walker.py @@ -0,0 +1,144 @@ +#!/usr/bin/python -u +# +# this tests the entities substitutions with the XmlTextReader interface +# +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +result = "" +def processNode(reader): + global result + + result = result + "%d %d %s %d\n" % (reader.Depth(), reader.NodeType(), + reader.Name(), reader.IsEmptyElement()) + +# +# Parse a document testing the readerForxxx API +# +docstr=""" + +100 +""" +expect="""0 1 foo 0 +1 14 #text 0 +1 1 label 0 +2 3 #text 0 +1 15 label 0 +1 14 #text 0 +1 1 item 0 +2 3 #text 0 +1 15 item 0 +1 14 #text 0 +0 15 foo 0 +""" +result = "" + +doc = libxml2.parseDoc(docstr) +reader = doc.readerWalker(); +ret = reader.Read() +while ret == 1: + processNode(reader) + ret = reader.Read() + +if ret != 0: + print("Error parsing the document test1") + sys.exit(1) + +if result != expect: + print("Unexpected result for test1") + print(result) + sys.exit(1) + +doc.freeDoc() + +# +# Reuse the reader for another document testing the ReaderNewWalker API +# +docstr=""" + +1000 +""" +expect="""0 1 foo 0 +1 14 #text 0 +1 1 label 0 +2 3 #text 0 +1 15 label 0 +1 14 #text 0 +1 1 item 0 +2 3 #text 0 +1 15 item 0 +1 14 #text 0 +0 15 foo 0 +""" +result = "" + +doc = libxml2.parseDoc(docstr) +reader.NewWalker(doc) + +ret = reader.Read() +while ret == 1: + processNode(reader) + ret = reader.Read() + +if ret != 0: + print("Error parsing the document test2") + sys.exit(1) + +if result != expect: + print("Unexpected result for test2") + print(result) + sys.exit(1) + +doc.freeDoc() + +# +# Reuse the reader for another document testing the ReaderNewxxx API +# +docstr=""" + +1000 +""" +expect="""0 1 foo 0 +1 14 #text 0 +1 1 label 0 +2 3 #text 0 +1 15 label 0 +1 14 #text 0 +1 1 item 0 +2 3 #text 0 +1 15 item 0 +1 14 #text 0 +0 15 foo 0 +""" +result = "" + +reader.NewDoc(docstr, "test3", None, 0) +ret = reader.Read() +while ret == 1: + processNode(reader) + ret = reader.Read() + +if ret != 0: + print("Error parsing the document test3") + sys.exit(1) + +if result != expect: + print("Unexpected result for test3") + print(result) + sys.exit(1) + +# +# cleanup +# +del reader + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/xpath.py b/libxml2-2.9.10/python/tests/xpath.py new file mode 100755 index 0000000..72e6c9d --- /dev/null +++ b/libxml2-2.9.10/python/tests/xpath.py @@ -0,0 +1,51 @@ +#!/usr/bin/python -u +# +# this test exercise the XPath basic engine, parser, etc, and +# allows to detect memory leaks +# +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +doc = libxml2.parseFile("tst.xml") +if doc.name != "tst.xml": + print("doc.name error") + sys.exit(1); + +ctxt = doc.xpathNewContext() +res = ctxt.xpathEval("//*") +if len(res) != 2: + print("xpath query: wrong node set size") + sys.exit(1) +if res[0].name != "doc" or res[1].name != "foo": + print("xpath query: wrong node set value") + sys.exit(1) +ctxt.setContextNode(res[0]) +res = ctxt.xpathEval("foo") +if len(res) != 1: + print("xpath query: wrong node set size") + sys.exit(1) +if res[0].name != "foo": + print("xpath query: wrong node set value") + sys.exit(1) +doc.freeDoc() +ctxt.xpathFreeContext() +i = 1000 +while i > 0: + doc = libxml2.parseFile("tst.xml") + ctxt = doc.xpathNewContext() + res = ctxt.xpathEval("//*") + doc.freeDoc() + ctxt.xpathFreeContext() + i = i -1 +del ctxt + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/xpathext.py b/libxml2-2.9.10/python/tests/xpathext.py new file mode 100755 index 0000000..b83d283 --- /dev/null +++ b/libxml2-2.9.10/python/tests/xpathext.py @@ -0,0 +1,49 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +# Memory debug specific +libxml2.debugMemory(1) + +def foo(ctx, x): + return x + 1 + +def bar(ctx, x): + return "%d" % (x + 2) + +doc = libxml2.parseFile("tst.xml") +ctxt = doc.xpathNewContext() +res = ctxt.xpathEval("//*") +if len(res) != 2: + print("xpath query: wrong node set size") + sys.exit(1) +if res[0].name != "doc" or res[1].name != "foo": + print("xpath query: wrong node set value") + sys.exit(1) + +libxml2.registerXPathFunction(ctxt._o, "foo", None, foo) +libxml2.registerXPathFunction(ctxt._o, "bar", None, bar) +i = 10000 +while i > 0: + res = ctxt.xpathEval("foo(1)") + if res != 2: + print("xpath extension failure") + sys.exit(1) + i = i - 1 +i = 10000 +while i > 0: + res = ctxt.xpathEval("bar(1)") + if res != "3": + print("xpath extension failure got %s expecting '3'") + sys.exit(1) + i = i - 1 +doc.freeDoc() +ctxt.xpathFreeContext() + +# Memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/xpathleak.py b/libxml2-2.9.10/python/tests/xpathleak.py new file mode 100755 index 0000000..6940b79 --- /dev/null +++ b/libxml2-2.9.10/python/tests/xpathleak.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +import sys, libxml2 + +libxml2.debugMemory(True) + +expect="""--> Invalid expression +--> Invalid expression +--> Invalid expression +--> Invalid expression +--> Invalid expression +--> Invalid expression +--> Invalid expression +--> Invalid expression +--> Invalid expression +--> Invalid expression +""" +err="" +def callback(ctx, str): + global err + + err = err + "%s %s" % (ctx, str) + +libxml2.registerErrorHandler(callback, "-->") + +doc = libxml2.parseDoc("") +ctxt = doc.xpathNewContext() +ctxt.setContextNode(doc) +badexprs = ( + ":false()", "bad:()", "bad(:)", ":bad(:)", "bad:(:)", "bad:bad(:)", + "a:/b", "/c:/d", "//e:/f", "g://h" + ) +for expr in badexprs: + try: + ctxt.xpathEval(expr) + except libxml2.xpathError: + pass + else: + print("Unexpectedly legal expression:", expr) +ctxt.xpathFreeContext() +doc.freeDoc() + +if err != expect: + print("error") + print("received %s" %(err)) + print("expected %s" %(expect)) + sys.exit(1) + +libxml2.cleanupParser() +leakedbytes = libxml2.debugMemory(True) +if leakedbytes == 0: + print("OK") +else: + print("Memory leak", leakedbytes, "bytes") + # drop file to .memdump file in cwd, but won't work if not compiled in + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/xpathns.py b/libxml2-2.9.10/python/tests/xpathns.py new file mode 100755 index 0000000..379535e --- /dev/null +++ b/libxml2-2.9.10/python/tests/xpathns.py @@ -0,0 +1,29 @@ +#!/usr/bin/python -u +# +import libxml2 + +expect=' xmlns:a="urn:whatevar"' + +# Memory debug specific +libxml2.debugMemory(1) + +d = libxml2.parseDoc("") +res="" +for n in d.xpathEval("//namespace::*"): + res = res + n.serialize() +d.freeDoc() + +if res != expect: + print("test5 failed: unexpected output") + print(res) +del res +del d +del n +# Memory debug specific +libxml2.cleanupParser() + +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() diff --git a/libxml2-2.9.10/python/tests/xpathret.py b/libxml2-2.9.10/python/tests/xpathret.py new file mode 100755 index 0000000..11c8b32 --- /dev/null +++ b/libxml2-2.9.10/python/tests/xpathret.py @@ -0,0 +1,57 @@ +#!/usr/bin/python -u +import sys +import libxml2 + +#memory debug specific +libxml2.debugMemory(1) + +# +# A document hosting the nodes returned from the extension function +# +mydoc = libxml2.newDoc("1.0") + +def foo(ctx, str): + global mydoc + + # + # test returning a node set works as expected + # + parent = mydoc.newDocNode(None, 'p', None) + mydoc.addChild(parent) + node = mydoc.newDocText(str) + parent.addChild(node) + return [parent] + +doc = libxml2.parseFile("tst.xml") +ctxt = doc.xpathNewContext() +libxml2.registerXPathFunction(ctxt._o, "foo", None, foo) +res = ctxt.xpathEval("foo('hello')") +if type(res) != type([]): + print("Failed to return a nodeset") + sys.exit(1) +if len(res) != 1: + print("Unexpected nodeset size") + sys.exit(1) +node = res[0] +if node.name != 'p': + print("Unexpected nodeset element result") + sys.exit(1) +node = node.children +if node.type != 'text': + print("Unexpected nodeset element children type") + sys.exit(1) +if node.content != 'hello': + print("Unexpected nodeset element children content") + sys.exit(1) + +doc.freeDoc() +mydoc.freeDoc() +ctxt.xpathFreeContext() + +#memory debug specific +libxml2.cleanupParser() +if libxml2.debugMemory(1) == 0: + print("OK") +else: + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) + libxml2.dumpMemory() -- cgit v1.2.3