mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-31 06:50:06 +03:00
tests: Port Schematron tests to C
This commit is contained in:
parent
811373e221
commit
e68ccfa988
35
Makefile.am
35
Makefile.am
@ -196,41 +196,6 @@ asan:
|
||||
@echo '## rebuilding for ASAN'
|
||||
./configure CFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security -Werror=array-bounds -g" CXXFLAGS="-fsanitize=address,undefined -Wformat -Werror=format-security -Werror=array-bounds -g" LDFLAGS="-fsanitize=address,undefined" CC="clang" CXX="clang++" --disable-shared ; OptimOff ; $(MAKE) clean ; $(MAKE)
|
||||
|
||||
# Old test suite. This should be ported to C.
|
||||
|
||||
OLD_TESTS =
|
||||
if WITH_SCHEMATRON_SOURCES
|
||||
OLD_TESTS += Schematrontests
|
||||
endif
|
||||
|
||||
tests: $(OLD_TESTS)
|
||||
|
||||
Schematrontests: xmllint$(EXEEXT)
|
||||
@echo "## Schematron regression tests"
|
||||
-@(for i in $(srcdir)/test/schematron/*.sct ; do \
|
||||
name=`basename $$i | sed 's+\.sct++'`; \
|
||||
for j in $(srcdir)/test/schematron/"$$name"_*.xml ; do \
|
||||
if [ -f $$j ] ; then \
|
||||
xno=`basename $$j | sed 's+.*_\(.*\).xml+\1+'`; \
|
||||
if [ ! -f $(srcdir)/result/schematron/"$$name"_"$$xno" ]; \
|
||||
then \
|
||||
echo New test file "$$name"_"$$xno" ; \
|
||||
$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --schematron $$i $$j \
|
||||
> $(srcdir)/result/schematron/"$$name"_"$$xno" \
|
||||
2> $(srcdir)/result/schematron/"$$name"_"$$xno".err; \
|
||||
else \
|
||||
log=`$(CHECKER) $(top_builddir)/xmllint$(EXEEXT) --schematron $$i $$j \
|
||||
> res.$$name 2> err.$$name;\
|
||||
diff $(srcdir)/result/schematron/"$$name"_"$$xno" \
|
||||
res.$$name;\
|
||||
diff $(srcdir)/result/schematron/"$$name"_"$$xno".err \
|
||||
err.$$name | grep -v "error detected at";\
|
||||
grep Unimplemented err.$$name`; \
|
||||
if [ -n "$$log" ] ; then echo "$$name"_"$$xno" result ; echo "$$log" ; fi ; \
|
||||
rm res.$$name err.$$name ; \
|
||||
fi ; fi ; \
|
||||
done; done)
|
||||
|
||||
cleanup:
|
||||
-@(find . -name .\#\* -exec rm {} \;)
|
||||
-@(find . -name \*.gcda -o -name \*.gcno -exec rm -f {} \;)
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB/>
|
||||
</AAA>
|
@ -1,5 +1,3 @@
|
||||
Pattern: Open model
|
||||
/AAA line 1: CCC element is not present
|
||||
Pattern: Closed model
|
||||
/AAA line 1: CCC element is not present
|
||||
./test/schematron/zvon10_0.xml:1: element AAA: schematron error : /AAA line 1: CCC element is not present
|
||||
./test/schematron/zvon10_0.xml:1: element AAA: schematron error : /AAA line 1: CCC element is not present
|
||||
./test/schematron/zvon10_0.xml fails to validate
|
||||
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB/>
|
||||
<DDD/>
|
||||
</AAA>
|
@ -1,6 +1,4 @@
|
||||
Pattern: Open model
|
||||
/AAA line 1: CCC element is not present
|
||||
Pattern: Closed model
|
||||
/AAA line 1: CCC element is not present
|
||||
/AAA line 1: There is an extra element
|
||||
./test/schematron/zvon10_1.xml:1: element AAA: schematron error : /AAA line 1: CCC element is not present
|
||||
./test/schematron/zvon10_1.xml:1: element AAA: schematron error : /AAA line 1: CCC element is not present
|
||||
./test/schematron/zvon10_1.xml:1: element AAA: schematron error : /AAA line 1: There is an extra element
|
||||
./test/schematron/zvon10_1.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB aaa="A" bbb="B"/>
|
||||
</AAA>
|
@ -1,2 +1 @@
|
||||
Pattern: Attributes present
|
||||
./test/schematron/zvon11_0.xml validates
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB bbb="B"/>
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Attributes present
|
||||
/AAA/BBB line 2: The element must not have an isolated bbb attribute
|
||||
./test/schematron/zvon11_1.xml:2: element BBB: schematron error : /AAA/BBB line 2: The element must not have an isolated bbb attribute
|
||||
./test/schematron/zvon11_1.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB aaa="A"/>
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Attributes present
|
||||
/AAA/BBB line 2: The element must not have an isolated aaa attribute
|
||||
./test/schematron/zvon11_2.xml:2: element BBB: schematron error : /AAA/BBB line 2: The element must not have an isolated aaa attribute
|
||||
./test/schematron/zvon11_2.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB/>
|
||||
</AAA>
|
@ -1,2 +1 @@
|
||||
Pattern: Attributes present
|
||||
./test/schematron/zvon11_3.xml validates
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB bbb="C"/>
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Number of characters in an abbreviation
|
||||
/AAA/BBB line 2: There is not enough letters in the abbreviation
|
||||
./test/schematron/zvon12_0.xml:2: element BBB: schematron error : /AAA/BBB line 2: There is not enough letters in the abbreviation
|
||||
./test/schematron/zvon12_0.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB bbb="CZ"/>
|
||||
</AAA>
|
@ -1,2 +1 @@
|
||||
Pattern: Number of characters in an abbreviation
|
||||
./test/schematron/zvon12_1.xml validates
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB bbb="CZCZ"/>
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Number of characters in an abbreviation
|
||||
/AAA/BBB line 2: There is too much letters in the abbreviation
|
||||
./test/schematron/zvon12_2.xml:2: element BBB: schematron error : /AAA/BBB line 2: There is too much letters in the abbreviation
|
||||
./test/schematron/zvon12_2.xml fails to validate
|
||||
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<Total>
|
||||
<Percent>20</Percent>
|
||||
<Percent>30</Percent>
|
||||
<Percent>10</Percent>
|
||||
<Percent>50</Percent>
|
||||
</Total>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Sum equals 100%.
|
||||
/Total line 1: The values do not sum to 100%.
|
||||
./test/schematron/zvon13_0.xml:1: element Total: schematron error : /Total line 1: The values do not sum to 100%.
|
||||
./test/schematron/zvon13_0.xml fails to validate
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<Total>
|
||||
<Percent>20</Percent>
|
||||
<Percent>10</Percent>
|
||||
<Percent>50</Percent>
|
||||
</Total>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Sum equals 100%.
|
||||
/Total line 1: The values do not sum to 100%.
|
||||
./test/schematron/zvon13_1.xml:1: element Total: schematron error : /Total line 1: The values do not sum to 100%.
|
||||
./test/schematron/zvon13_1.xml fails to validate
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<Total>
|
||||
<Percent>20</Percent>
|
||||
<Percent>30</Percent>
|
||||
<Percent>50</Percent>
|
||||
</Total>
|
@ -1,2 +1 @@
|
||||
Pattern: Sum equals 100%.
|
||||
./test/schematron/zvon13_2.xml validates
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB>
|
||||
<CCC/>
|
||||
</BBB>
|
||||
<CCC/>
|
||||
<DDD>
|
||||
<CCC/>
|
||||
<EEE>
|
||||
<CCC/>
|
||||
</EEE>
|
||||
</DDD>
|
||||
</AAA>
|
@ -1,4 +1,3 @@
|
||||
Pattern: a child of selected elements
|
||||
/AAA/CCC line 5: Element CCC must not be a child of element AAA
|
||||
/AAA/DDD/EEE/CCC line 9: Element CCC must not be a child of element EEE
|
||||
./test/schematron/zvon14_0.xml:5: element CCC: schematron error : /AAA/CCC line 5: Element CCC must not be a child of element AAA
|
||||
./test/schematron/zvon14_0.xml:9: element CCC: schematron error : /AAA/DDD/EEE/CCC line 9: Element CCC must not be a child of element EEE
|
||||
./test/schematron/zvon14_0.xml fails to validate
|
||||
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA name="aaa">
|
||||
<BBB id="bbb"/>
|
||||
<CCC color="ccc"/>
|
||||
</AAA>
|
@ -1,4 +1,3 @@
|
||||
Pattern: id is the only permited attribute name
|
||||
/AAA line 1: Attribute name is forbidden in element AAA
|
||||
/AAA/CCC line 3: Attribute color is forbidden in element CCC
|
||||
./test/schematron/zvon15_0.xml:1: element AAA: schematron error : /AAA line 1: Attribute name is forbidden in element AAA
|
||||
./test/schematron/zvon15_0.xml:3: element CCC: schematron error : /AAA/CCC line 3: Attribute color is forbidden in element CCC
|
||||
./test/schematron/zvon15_0.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB/>
|
||||
</AAA>
|
@ -1,8 +1,5 @@
|
||||
Pattern: Print both cases
|
||||
/AAA line 1: BBB element is present.
|
||||
/AAA line 1: AAA misses attribute name.
|
||||
Pattern: Print positive result only
|
||||
/AAA line 1: BBB element is present.
|
||||
Pattern: Print negative result only
|
||||
/AAA line 1: AAA misses attribute name.
|
||||
./test/schematron/zvon1_0.xml:1: element AAA: schematron error : /AAA line 1: BBB element is present.
|
||||
./test/schematron/zvon1_0.xml:1: element AAA: schematron error : /AAA line 1: AAA misses attribute name.
|
||||
./test/schematron/zvon1_0.xml:1: element AAA: schematron error : /AAA line 1: BBB element is present.
|
||||
./test/schematron/zvon1_0.xml:1: element AAA: schematron error : /AAA line 1: AAA misses attribute name.
|
||||
./test/schematron/zvon1_0.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<CCC/>
|
||||
</AAA>
|
@ -1,8 +1,5 @@
|
||||
Pattern: Print both cases
|
||||
/AAA line 1: BBB element is missing.
|
||||
/AAA line 1: AAA misses attribute name.
|
||||
Pattern: Print positive result only
|
||||
Pattern: Print negative result only
|
||||
/AAA line 1: BBB element is missing.
|
||||
/AAA line 1: AAA misses attribute name.
|
||||
./test/schematron/zvon1_1.xml:1: element AAA: schematron error : /AAA line 1: BBB element is missing.
|
||||
./test/schematron/zvon1_1.xml:1: element AAA: schematron error : /AAA line 1: AAA misses attribute name.
|
||||
./test/schematron/zvon1_1.xml:1: element AAA: schematron error : /AAA line 1: BBB element is missing.
|
||||
./test/schematron/zvon1_1.xml:1: element AAA: schematron error : /AAA line 1: AAA misses attribute name.
|
||||
./test/schematron/zvon1_1.xml fails to validate
|
||||
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB>bbbb</BBB>
|
||||
<CCC>cccc</CCC>
|
||||
</AAA>
|
@ -1,2 +1 @@
|
||||
Pattern: Character @ forbidden
|
||||
./test/schematron/zvon2_0.xml validates
|
||||
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB>bbbb@bbb.com</BBB>
|
||||
<CCC>ccc@ccc.com</CCC>
|
||||
</AAA>
|
@ -1,5 +1,4 @@
|
||||
Pattern: Character @ forbidden
|
||||
/AAA line 1: Text in element AAA must not contain character @
|
||||
/AAA/BBB line 2: Text in element BBB must not contain character @
|
||||
/AAA/CCC line 3: Text in element CCC must not contain character @
|
||||
./test/schematron/zvon2_1.xml:1: element AAA: schematron error : /AAA line 1: Text in element AAA must not contain character @
|
||||
./test/schematron/zvon2_1.xml:2: element BBB: schematron error : /AAA/BBB line 2: Text in element BBB must not contain character @
|
||||
./test/schematron/zvon2_1.xml:3: element CCC: schematron error : /AAA/CCC line 3: Text in element CCC must not contain character @
|
||||
./test/schematron/zvon2_1.xml fails to validate
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB>bbbb</BBB>
|
||||
<CCC>cccc</CCC>
|
||||
aaa@aaa.net
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Character @ forbidden
|
||||
/AAA line 1: Text in element AAA must not contain character @
|
||||
./test/schematron/zvon2_2.xml:1: element AAA: schematron error : /AAA line 1: Text in element AAA must not contain character @
|
||||
./test/schematron/zvon2_2.xml fails to validate
|
||||
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB>
|
||||
<CCC/>
|
||||
<CCC/>
|
||||
</BBB>
|
||||
<CCC name="c1"/>
|
||||
<CCC name="c2"/>
|
||||
</AAA>
|
@ -1,6 +1,5 @@
|
||||
Pattern: Attribute test
|
||||
/AAA/BBB/CCC[1] line 3: attribute name is not present
|
||||
/AAA/BBB/CCC[2] line 4: attribute name is not present
|
||||
/AAA/CCC[1] line 6: attribute name is present
|
||||
/AAA/CCC[2] line 7: attribute name is present
|
||||
./test/schematron/zvon3_0.xml:3: element CCC: schematron error : /AAA/BBB/CCC[1] line 3: attribute name is not present
|
||||
./test/schematron/zvon3_0.xml:4: element CCC: schematron error : /AAA/BBB/CCC[2] line 4: attribute name is not present
|
||||
./test/schematron/zvon3_0.xml:6: element CCC: schematron error : /AAA/CCC[1] line 6: attribute name is present
|
||||
./test/schematron/zvon3_0.xml:7: element CCC: schematron error : /AAA/CCC[2] line 7: attribute name is present
|
||||
./test/schematron/zvon3_0.xml fails to validate
|
||||
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB>
|
||||
<CCC/>
|
||||
<CCC/>
|
||||
</BBB>
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Root test
|
||||
/AAA line 1: Root element is AAA
|
||||
./test/schematron/zvon4_0.xml:1: element AAA: schematron error : /AAA line 1: Root element is AAA
|
||||
./test/schematron/zvon4_0.xml fails to validate
|
||||
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<XXX>
|
||||
<BBB>
|
||||
<CCC/>
|
||||
<CCC/>
|
||||
</BBB>
|
||||
</XXX>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Root test
|
||||
/XXX line 1: Root element is XXX, not AAA
|
||||
./test/schematron/zvon4_1.xml:1: element XXX: schematron error : /XXX line 1: Root element is XXX, not AAA
|
||||
./test/schematron/zvon4_1.xml fails to validate
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB>
|
||||
<CCC/>
|
||||
</BBB>
|
||||
</AAA>
|
@ -1,7 +1,6 @@
|
||||
Pattern: Select empty elements CCC
|
||||
/AAA/BBB/CCC line 3: Source contains an empty element CCC
|
||||
/AAA/BBB/CCC line 3: [1]An element CCC does not contain any text
|
||||
/AAA/BBB/CCC line 3: [2]An element CCC does not contain any text
|
||||
/AAA/BBB/CCC line 3: [1]An element CCC does not contain any child element
|
||||
/AAA/BBB/CCC line 3: [2]An element CCC does not contain any child element
|
||||
./test/schematron/zvon5_0.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: Source contains an empty element CCC
|
||||
./test/schematron/zvon5_0.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: [1]An element CCC does not contain any text
|
||||
./test/schematron/zvon5_0.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: [2]An element CCC does not contain any text
|
||||
./test/schematron/zvon5_0.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: [1]An element CCC does not contain any child element
|
||||
./test/schematron/zvon5_0.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: [2]An element CCC does not contain any child element
|
||||
./test/schematron/zvon5_0.xml fails to validate
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB>
|
||||
<CCC>I am CCC element</CCC>
|
||||
</BBB>
|
||||
</AAA>
|
@ -1,5 +1,4 @@
|
||||
Pattern: Select empty elements CCC
|
||||
/AAA/BBB/CCC line 3: Source contains an empty element CCC
|
||||
/AAA/BBB/CCC line 3: [1]An element CCC does not contain any child element
|
||||
/AAA/BBB/CCC line 3: [2]An element CCC does not contain any child element
|
||||
./test/schematron/zvon5_1.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: Source contains an empty element CCC
|
||||
./test/schematron/zvon5_1.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: [1]An element CCC does not contain any child element
|
||||
./test/schematron/zvon5_1.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: [2]An element CCC does not contain any child element
|
||||
./test/schematron/zvon5_1.xml fails to validate
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<BBB>
|
||||
<CCC>
|
||||
<DDD/>
|
||||
</CCC>
|
||||
</BBB>
|
||||
</AAA>
|
@ -1,5 +1,4 @@
|
||||
Pattern: Select empty elements CCC
|
||||
/AAA/BBB/CCC line 3: Source contains an empty element CCC
|
||||
/AAA/BBB/CCC line 3: [1]An element CCC does not contain any text
|
||||
/AAA/BBB/CCC line 3: [2]An element CCC does not contain any text
|
||||
./test/schematron/zvon5_2.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: Source contains an empty element CCC
|
||||
./test/schematron/zvon5_2.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: [1]An element CCC does not contain any text
|
||||
./test/schematron/zvon5_2.xml:3: element CCC: schematron error : /AAA/BBB/CCC line 3: [2]An element CCC does not contain any text
|
||||
./test/schematron/zvon5_2.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
aaa
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Predefined values
|
||||
/AAA line 1: O.K.
|
||||
./test/schematron/zvon6_0.xml:1: element AAA: schematron error : /AAA line 1: O.K.
|
||||
./test/schematron/zvon6_0.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
bbb
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Predefined values
|
||||
/AAA line 1: O.K.
|
||||
./test/schematron/zvon6_1.xml:1: element AAA: schematron error : /AAA line 1: O.K.
|
||||
./test/schematron/zvon6_1.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
ccc
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Predefined values
|
||||
/AAA line 1: The AAA value is not permitted.
|
||||
./test/schematron/zvon6_2.xml:1: element AAA: schematron error : /AAA line 1: The AAA value is not permitted.
|
||||
./test/schematron/zvon6_2.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
aaa
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test integer
|
||||
/AAA line 1: The AAA value is not an integer.
|
||||
./test/schematron/zvon7_0.xml:1: element AAA: schematron error : /AAA line 1: The AAA value is not an integer.
|
||||
./test/schematron/zvon7_0.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
12.234
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test integer
|
||||
/AAA line 1: The AAA value is not an integer.
|
||||
./test/schematron/zvon7_1.xml:1: element AAA: schematron error : /AAA line 1: The AAA value is not an integer.
|
||||
./test/schematron/zvon7_1.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
45
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test integer
|
||||
/AAA line 1: O.K.
|
||||
./test/schematron/zvon7_2.xml:1: element AAA: schematron error : /AAA line 1: O.K.
|
||||
./test/schematron/zvon7_2.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
0
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test integer
|
||||
/AAA line 1: O.K.
|
||||
./test/schematron/zvon7_3.xml:1: element AAA: schematron error : /AAA line 1: O.K.
|
||||
./test/schematron/zvon7_3.xml fails to validate
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
-45
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test integer
|
||||
/AAA line 1: O.K.
|
||||
./test/schematron/zvon7_4.xml:1: element AAA: schematron error : /AAA line 1: O.K.
|
||||
./test/schematron/zvon7_4.xml fails to validate
|
||||
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<XXX>
|
||||
<BBB/>
|
||||
<BBB/>
|
||||
<AAA/>
|
||||
<BBB/>
|
||||
<AAA/>
|
||||
<AAA/>
|
||||
</XXX>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test count
|
||||
/XXX line 1: O.K.
|
||||
./test/schematron/zvon8_0.xml:1: element XXX: schematron error : /XXX line 1: O.K.
|
||||
./test/schematron/zvon8_0.xml fails to validate
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<XXX>
|
||||
<BBB/>
|
||||
<AAA/>
|
||||
<BBB/>
|
||||
<AAA/>
|
||||
<AAA/>
|
||||
</XXX>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test count
|
||||
/XXX line 1: Some BBB are missing
|
||||
./test/schematron/zvon8_1.xml:1: element XXX: schematron error : /XXX line 1: Some BBB are missing
|
||||
./test/schematron/zvon8_1.xml fails to validate
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<XXX>
|
||||
<BBB/>
|
||||
<BBB/>
|
||||
<AAA/>
|
||||
<BBB/>
|
||||
<AAA/>
|
||||
</XXX>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test count
|
||||
/XXX line 1: Some AAA are missing
|
||||
./test/schematron/zvon8_2.xml:1: element XXX: schematron error : /XXX line 1: Some AAA are missing
|
||||
./test/schematron/zvon8_2.xml fails to validate
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<CCC/>
|
||||
<CCC/>
|
||||
<BBB>
|
||||
<CCC id="Q1"/>
|
||||
</BBB>
|
||||
</AAA>
|
@ -1,2 +1 @@
|
||||
Pattern: Test attribute
|
||||
./test/schematron/zvon9_0.xml validates
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<CCC id="Q2"/>
|
||||
<CCC/>
|
||||
<BBB>
|
||||
<CCC id="Q1"/>
|
||||
</BBB>
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test attribute
|
||||
/AAA/CCC[1] line 2: Attribute id is used in wrong context
|
||||
./test/schematron/zvon9_1.xml:2: element CCC: schematron error : /AAA/CCC[1] line 2: Attribute id is used in wrong context
|
||||
./test/schematron/zvon9_1.xml fails to validate
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<AAA>
|
||||
<CCC/>
|
||||
<CCC/>
|
||||
<BBB>
|
||||
<CCC/>
|
||||
</BBB>
|
||||
</AAA>
|
@ -1,3 +1,2 @@
|
||||
Pattern: Test attribute
|
||||
/AAA/BBB/CCC line 5: Attribute id is missing
|
||||
./test/schematron/zvon9_2.xml:5: element CCC: schematron error : /AAA/BBB/CCC line 5: Attribute id is missing
|
||||
./test/schematron/zvon9_2.xml fails to validate
|
||||
|
134
runtest.c
134
runtest.c
@ -57,6 +57,10 @@
|
||||
#include <libxml/xmlschemastypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_SCHEMATRON_ENABLED
|
||||
#include <libxml/schematron.h>
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
#include <libxml/pattern.h>
|
||||
#endif
|
||||
@ -3626,6 +3630,131 @@ rngStreamTest(const char *filename,
|
||||
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Schematron tests *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
#ifdef LIBXML_SCHEMATRON_ENABLED
|
||||
static int
|
||||
schematronOneTest(const char *sch, const char *filename, int options,
|
||||
xmlSchematronPtr schematron) {
|
||||
xmlDocPtr doc;
|
||||
xmlSchematronValidCtxtPtr ctxt;
|
||||
int ret;
|
||||
|
||||
doc = xmlReadFile(filename, NULL, options);
|
||||
if (doc == NULL) {
|
||||
fprintf(stderr, "failed to parse instance %s for %s\n", filename, sch);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
ctxt = xmlSchematronNewValidCtxt(schematron, XML_SCHEMATRON_OUT_ERROR);
|
||||
xmlSchematronSetValidStructuredErrors(ctxt, testStructuredErrorHandler,
|
||||
NULL);
|
||||
ret = xmlSchematronValidateDoc(ctxt, doc);
|
||||
if (ret == 0) {
|
||||
testErrorHandler(NULL, "%s validates\n", filename);
|
||||
} else if (ret > 0) {
|
||||
testErrorHandler(NULL, "%s fails to validate\n", filename);
|
||||
} else {
|
||||
testErrorHandler(NULL, "%s validation generated an internal error\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
xmlSchematronFreeValidCtxt(ctxt);
|
||||
xmlFreeDoc(doc);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* schematronTest:
|
||||
* @filename: the schemas file
|
||||
* @result: the file with expected result
|
||||
* @err: the file with error messages
|
||||
*
|
||||
* Returns 0 in case of success, an error code otherwise
|
||||
*/
|
||||
static int
|
||||
schematronTest(const char *filename,
|
||||
const char *resul ATTRIBUTE_UNUSED,
|
||||
const char *errr ATTRIBUTE_UNUSED,
|
||||
int options) {
|
||||
const char *base = baseFilename(filename);
|
||||
const char *base2;
|
||||
const char *instance;
|
||||
xmlSchematronParserCtxtPtr pctxt;
|
||||
xmlSchematronPtr schematron;
|
||||
int res = 0, len, ret = 0;
|
||||
int parseErrorsSize;
|
||||
char pattern[500];
|
||||
char prefix[500];
|
||||
char err[500];
|
||||
glob_t globbuf;
|
||||
size_t i;
|
||||
char count = 0;
|
||||
|
||||
pctxt = xmlSchematronNewParserCtxt(filename);
|
||||
schematron = xmlSchematronParse(pctxt);
|
||||
xmlSchematronFreeParserCtxt(pctxt);
|
||||
if (schematron == NULL)
|
||||
testErrorHandler(NULL, "Schematron schema %s failed to compile\n",
|
||||
filename);
|
||||
parseErrorsSize = testErrorsSize;
|
||||
|
||||
/*
|
||||
* most of the mess is about the output filenames generated by the Makefile
|
||||
*/
|
||||
len = strlen(base);
|
||||
if ((len > 499) || (len < 5)) {
|
||||
xmlSchematronFree(schematron);
|
||||
return(-1);
|
||||
}
|
||||
len -= 4; /* remove trailing .sct */
|
||||
memcpy(prefix, base, len);
|
||||
prefix[len] = 0;
|
||||
|
||||
if (snprintf(pattern, 499, "./test/schematron/%s_?.xml", prefix) >= 499)
|
||||
pattern[499] = 0;
|
||||
|
||||
globbuf.gl_offs = 0;
|
||||
glob(pattern, GLOB_DOOFFS, NULL, &globbuf);
|
||||
for (i = 0;i < globbuf.gl_pathc;i++) {
|
||||
testErrorsSize = parseErrorsSize;
|
||||
testErrors[parseErrorsSize] = 0;
|
||||
instance = globbuf.gl_pathv[i];
|
||||
base2 = baseFilename(instance);
|
||||
len = strlen(base2);
|
||||
if ((len > 6) && (base2[len - 6] == '_')) {
|
||||
count = base2[len - 5];
|
||||
res = snprintf(err, 499, "result/schematron/%s_%c.err",
|
||||
prefix, count);
|
||||
if (res >= 499)
|
||||
err[499] = 0;
|
||||
} else {
|
||||
fprintf(stderr, "don't know how to process %s\n", instance);
|
||||
continue;
|
||||
}
|
||||
if (schematron != NULL) {
|
||||
nb_tests++;
|
||||
res = schematronOneTest(filename, instance, options, schematron);
|
||||
if (res != 0)
|
||||
ret = res;
|
||||
}
|
||||
if (compareFileMem(err, testErrors, testErrorsSize)) {
|
||||
fprintf(stderr, "Error for %s on %s failed\n", instance,
|
||||
filename);
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
globfree(&globbuf);
|
||||
xmlSchematronFree(schematron);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
#endif /* LIBXML_SCHEMATRON_ENABLED */
|
||||
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
/************************************************************************
|
||||
@ -4869,6 +4998,11 @@ testDesc testDescriptions[] = {
|
||||
XML_PARSE_DTDATTR | XML_PARSE_NOENT },
|
||||
#endif
|
||||
#endif
|
||||
#if defined(LIBXML_SCHEMATRON_ENABLED)
|
||||
{ "Schematron regression tests" ,
|
||||
schematronTest, "./test/schematron/*.sct", NULL, NULL, NULL,
|
||||
0 },
|
||||
#endif
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
{ "Pattern regression tests" ,
|
||||
|
Loading…
x
Reference in New Issue
Block a user