xref: /aosp_15_r20/external/libxml2/test/catalogs/test.sh (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1#!/bin/sh
2
3set -e
4
5echo "## Catalog regression tests"
6
7if [ -n "$1" ]; then
8    xmlcatalog=$1
9else
10    xmlcatalog=./xmlcatalog
11fi
12
13exitcode=0
14
15for i in test/catalogs/*.script ; do
16    name=$(basename $i .script)
17    xml="./test/catalogs/$name.xml"
18
19    if [ -f $xml ] ; then
20        if [ ! -f result/catalogs/$name ] ; then
21            echo New test file $name
22            $xmlcatalog --shell $xml < $i 2>&1 > result/catalogs/$name
23        else
24            $xmlcatalog --shell $xml < $i 2>&1 > catalog.out
25            log=$(diff result/catalogs/$name catalog.out)
26            if [ -n "$log" ] ; then
27                echo $name result
28                echo "$log"
29                exitcode=1
30            fi
31            rm catalog.out
32        fi
33    fi
34done
35
36for i in test/catalogs/*.script ; do
37    name=$(basename $i .script)
38    sgml="./test/catalogs/$name.sgml"
39
40    if [ -f $sgml ] ; then
41        if [ ! -f result/catalogs/$name ] ; then
42            echo New test file $name
43            $xmlcatalog --shell $sgml < $i > result/catalogs/$name
44        else
45            $xmlcatalog --shell $sgml < $i > catalog.out
46            log=$(diff result/catalogs/$name catalog.out)
47            if [ -n "$log" ] ; then
48                echo $name result
49                echo "$log"
50                exitcode=1
51            fi
52            rm catalog.out
53        fi
54    fi
55done
56
57# Add and del operations on XML Catalogs
58
59$xmlcatalog --create --noout mycatalog
60$xmlcatalog --noout --add public Pubid sysid mycatalog
61$xmlcatalog --noout --add public Pubid2 sysid2 mycatalog
62$xmlcatalog --noout --add public Pubid3 sysid3 mycatalog
63diff result/catalogs/mycatalog.full mycatalog
64$xmlcatalog --noout --del sysid mycatalog
65$xmlcatalog --noout --del sysid3 mycatalog
66$xmlcatalog --noout --del sysid2 mycatalog
67diff result/catalogs/mycatalog.empty mycatalog
68rm -f mycatalog
69
70exit $exitcode
71