[libxml2] Move regexp tests to runtest
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Move regexp tests to runtest
- Date: Mon, 4 Apr 2022 02:33:56 +0000 (UTC)
commit 5ce893c0c462582c15a388b05db258b6dba07c6a
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Thu Jul 9 03:21:07 2020 +0200
Move regexp tests to runtest
.gitignore | 1 -
CMakeLists.txt | 1 -
Makefile.am | 44 ------
configure.ac | 2 +-
doc/apibuild.py | 1 -
runtest.c | 112 ++++++++++++++
testRegexp.c | 402 ---------------------------------------------------
vms/build_libxml.com | 2 +-
win32/Makefile.bcb | 1 -
win32/Makefile.mingw | 1 -
win32/Makefile.msvc | 1 -
11 files changed, 114 insertions(+), 454 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 50e44639..5053db20 100644
--- a/.gitignore
+++ b/.gitignore
@@ -98,7 +98,6 @@ tags
test.out
testAutomata
testModule
-testRegexp
testThreads
testapi
testapi.c.new
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7fbec6d6..3a9c8177 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -511,7 +511,6 @@ if(LIBXML2_WITH_TESTS)
testModule
testlimits
testrecurse
- testRegexp
)
foreach(TEST ${TESTS})
add_executable(${TEST} ${TEST}.c)
diff --git a/Makefile.am b/Makefile.am
index a3ff6c4a..6d8b70ac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,6 @@ check_PROGRAMS = \
runtest \
runxmlconf \
testAutomata \
- testRegexp \
testModule \
testThreads \
testapi \
@@ -117,11 +116,6 @@ testThreads_LDFLAGS =
testThreads_DEPENDENCIES = $(DEPS)
testThreads_LDADD= $(BASE_THREAD_LIBS) $(THREAD_LIBS) $(LDADDS)
-testRegexp_SOURCES=testRegexp.c
-testRegexp_LDFLAGS =
-testRegexp_DEPENDENCIES = $(DEPS)
-testRegexp_LDADD= $(LDADDS)
-
testAutomata_SOURCES=testAutomata.c
testAutomata_LDFLAGS =
testAutomata_DEPENDENCIES = $(DEPS)
@@ -273,44 +267,6 @@ Catatests : xmlcatalog$(EXEEXT)
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0"; \
rm -f $(srcdir)/result/catalogs/mycatalog)
-Regexptests: testRegexp$(EXEEXT)
- @(echo > .memdump)
- @echo "## Regexp regression tests"
- -@(for i in $(srcdir)/test/regexp/* ; do \
- name=`basename $$i`; \
- if [ ! -d $$i ] ; then \
- if [ ! -f $(srcdir)/result/regexp/$$name ] ; then \
- echo New test file $$name ; \
- $(CHECKER) $(top_builddir)/testRegexp -i $$i > $(srcdir)/result/regexp/$$name 2>
$(srcdir)/result/regexp/$$name.err ; \
- if [ ! -s "$(srcdir)/result/regexp/$$name.err" ] ; then rm $(srcdir)/result/regexp/$$name.err;
fi ; \
- grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
- else \
- log=`$(CHECKER) $(top_builddir)/testRegexp -i $$i > result.$$name 2> error.$$name ; \
- grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
- diff $(srcdir)/result/regexp/$$name result.$$name ; \
- if [ -s "$(srcdir)/result/regexp/$$name.err" -o -s "error.$$name" ] ; then diff
$(srcdir)/result/regexp/$$name.err error.$$name ; fi` ; \
- if [ -n "$$log" ] ; then echo $$name result ; echo $$log ; fi ; \
- rm result.$$name error.$$name ; \
- fi ; fi ; done)
-
-# Disabled for now
-Exptests: testRegexp$(EXEEXT)
- @echo "## Formal expressions regression tests"
- -@(for i in $(srcdir)/test/expr/* ; do \
- name=`basename $$i`; \
- if [ ! -d $$i ] ; then \
- if [ ! -f $(srcdir)/result/expr/$$name ] ; then \
- echo New test file $$name ; \
- $(CHECKER) $(top_builddir)/testRegexp --expr -i $$i > $(srcdir)/result/expr/$$name; \
- grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
- else \
- log=`$(CHECKER) $(top_builddir)/testRegexp --expr -i $$i 2>&1 > result.$$name ; \
- grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
- diff $(srcdir)/result/expr/$$name result.$$name` ; \
- if [ -n "$$log" ] ; then echo $$name result ; echo "$$log" ; fi ; \
- rm result.$$name ; \
- fi ; fi ; done)
-
Automatatests: testAutomata$(EXEEXT)
@(echo > .memdump)
@echo "## Automata regression tests"
diff --git a/configure.ac b/configure.ac
index 44bfce9f..d029dccc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1299,7 +1299,7 @@ if test "$with_regexps" = "no" ; then
TEST_REGEXPS=
else
WITH_REGEXPS=1
- TEST_REGEXPS="Regexptests Automatatests"
+ TEST_REGEXPS="Automatatests"
fi
AC_SUBST(WITH_REGEXPS)
AC_SUBST(TEST_REGEXPS)
diff --git a/doc/apibuild.py b/doc/apibuild.py
index 18ac9417..ecbb9617 100755
--- a/doc/apibuild.py
+++ b/doc/apibuild.py
@@ -33,7 +33,6 @@ ignored_files = {
"rngparser.h": "not yet integrated",
"testAutomata.c": "test tool",
"testModule.c": "test tool",
- "testRegexp.c": "test tool",
"testThreads.c": "test tool",
"testapi.c": "generated regression tests",
"runtest.c": "regression tests program",
diff --git a/runtest.c b/runtest.c
index 30013efd..c51d8d5e 100644
--- a/runtest.c
+++ b/runtest.c
@@ -4298,6 +4298,113 @@ threadsTest(const char *filename ATTRIBUTE_UNUSED,
return(testThread());
}
#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+/************************************************************************
+ * *
+ * Regexp tests *
+ * *
+ ************************************************************************/
+
+static void testRegexp(FILE *output, xmlRegexpPtr comp, const char *value) {
+ int ret;
+
+ ret = xmlRegexpExec(comp, (const xmlChar *) value);
+ if (ret == 1)
+ fprintf(output, "%s: Ok\n", value);
+ else if (ret == 0)
+ fprintf(output, "%s: Fail\n", value);
+ else
+ fprintf(output, "%s: Error: %d\n", value, ret);
+}
+
+static int
+regexpTest(const char *filename, const char *result, const char *err,
+ int options ATTRIBUTE_UNUSED) {
+ xmlRegexpPtr comp = NULL;
+ FILE *input, *output;
+ char *temp;
+ char expression[5000];
+ int len, ret, res = 0;
+
+ input = fopen(filename, "r");
+ if (input == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "Cannot open %s for reading\n", filename);
+ return(-1);
+ }
+ temp = resultFilename(filename, "", ".res");
+ if (temp == NULL) {
+ fprintf(stderr, "Out of memory\n");
+ fatalError();
+ }
+ output = fopen(temp, "wb");
+ if (output == NULL) {
+ fprintf(stderr, "failed to open output file %s\n", temp);
+ free(temp);
+ return(-1);
+ }
+ while (fgets(expression, 4500, input) != NULL) {
+ len = strlen(expression);
+ len--;
+ while ((len >= 0) &&
+ ((expression[len] == '\n') || (expression[len] == '\t') ||
+ (expression[len] == '\r') || (expression[len] == ' '))) len--;
+ expression[len + 1] = 0;
+ if (len >= 0) {
+ if (expression[0] == '#')
+ continue;
+ if ((expression[0] == '=') && (expression[1] == '>')) {
+ char *pattern = &expression[2];
+
+ if (comp != NULL) {
+ xmlRegFreeRegexp(comp);
+ comp = NULL;
+ }
+ fprintf(output, "Regexp: %s\n", pattern) ;
+ comp = xmlRegexpCompile((const xmlChar *) pattern);
+ if (comp == NULL) {
+ fprintf(output, " failed to compile\n");
+ break;
+ }
+ } else if (comp == NULL) {
+ fprintf(output, "Regexp: %s\n", expression) ;
+ comp = xmlRegexpCompile((const xmlChar *) expression);
+ if (comp == NULL) {
+ fprintf(output, " failed to compile\n");
+ break;
+ }
+ } else if (comp != NULL) {
+ testRegexp(output, comp, expression);
+ }
+ }
+ }
+ fclose(output);
+ fclose(input);
+ if (comp != NULL)
+ xmlRegFreeRegexp(comp);
+
+ ret = compareFiles(temp, result);
+ if (ret) {
+ fprintf(stderr, "Result for %s failed in %s\n", filename, result);
+ res = 1;
+ }
+ if (temp != NULL) {
+ unlink(temp);
+ free(temp);
+ }
+
+ ret = compareFileMem(err, testErrors, testErrorsSize);
+ if (ret != 0) {
+ fprintf(stderr, "Error for %s failed\n", filename);
+ res = 1;
+ }
+
+ return(res);
+}
+
+#endif
+
/************************************************************************
* *
* Tests Descriptions *
@@ -4495,6 +4602,11 @@ testDesc testDescriptions[] = {
{ "SVG parsing regression tests" ,
oldParseTest, "./test/SVG/*.xml", "result/SVG/", "", NULL,
0 },
+#if defined(LIBXML_REGEXP_ENABLED)
+ { "Regexp regression tests" ,
+ regexpTest, "./test/regexp/*", "result/regexp/", "", ".err",
+ 0 },
+#endif
{NULL, NULL, NULL, NULL, NULL, NULL, 0}
};
diff --git a/vms/build_libxml.com b/vms/build_libxml.com
index 2db561f3..374a877e 100755
--- a/vms/build_libxml.com
+++ b/vms/build_libxml.com
@@ -64,7 +64,7 @@ $!
$!- list of test modules to compile and link. Compare this list to the
$! definition of check_PROGRAMS in MAKEFILE.
$!
-$ check_PROGRAMS = "testThreads testAutomata testRegexp"
+$ check_PROGRAMS = "testThreads testAutomata"
$!
$!- set up build logicals -----------------------------------------------------\
$!
diff --git a/win32/Makefile.bcb b/win32/Makefile.bcb
index 0fe8eae0..c4b51259 100644
--- a/win32/Makefile.bcb
+++ b/win32/Makefile.bcb
@@ -206,7 +206,6 @@ XML_OBJS_A = $(XML_INTDIR_A)\buf.obj\
UTILS = $(BINDIR)\xmllint.exe\
$(BINDIR)\xmlcatalog.exe\
$(BINDIR)\testAutomata.exe\
- $(BINDIR)\testRegexp.exe\
$(BINDIR)\testModule.exe\
$(BINDIR)\runtest.exe\
$(BINDIR)\runsuite.exe\
diff --git a/win32/Makefile.mingw b/win32/Makefile.mingw
index 3f6069b8..13f2d96f 100644
--- a/win32/Makefile.mingw
+++ b/win32/Makefile.mingw
@@ -202,7 +202,6 @@ XML_SRCS_A = $(subst .o,.c,$(subst $(XML_INTDIR_A)/,$(XML_SRCDIR)/,$(XML_OBJS_A)
UTILS = $(BINDIR)/xmllint.exe\
$(BINDIR)/xmlcatalog.exe\
$(BINDIR)/testAutomata.exe\
- $(BINDIR)/testRegexp.exe\
$(BINDIR)/testModule.exe\
$(BINDIR)/runtest.exe\
$(BINDIR)/runsuite.exe\
diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc
index 233251c2..80e64e22 100644
--- a/win32/Makefile.msvc
+++ b/win32/Makefile.msvc
@@ -256,7 +256,6 @@ XML_OBJS_A_DLL = $(XML_OBJS_A_DLL) $(XML_INTDIR_A_DLL)\xzlib.obj
UTILS = $(BINDIR)\xmllint.exe\
$(BINDIR)\xmlcatalog.exe\
$(BINDIR)\testAutomata.exe\
- $(BINDIR)\testRegexp.exe\
$(BINDIR)\testModule.exe\
$(BINDIR)\runtest.exe\
$(BINDIR)\runsuite.exe\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]