1#!/bin/sh
2# svg.test
3#
4# Copyright (C) 2020 Free Software Foundation, Inc.
5#
6# This program is free software, licensed under the terms of the GNU
7# General Public License as published by the Free Software Foundation,
8# either version 3 of the License, or (at your option) any later version.
9# You should have received a copy of the GNU General Public License
10# along with this program.  If not, see <http://www.gnu.org/licenses/>.
11#
12# Author: Reini Urban
13
14[ -z "$DATADIR" ] && DATADIR="../../test/test-data"
15top_builddir=".."
16EXEEXT=""
17# artefact for "shellcheck"
18[ -z "$top_builddir" ] && echo $top_builddir
19
20i=0
21DATA="sample_2000 example_2000 example_2004 example_2007 example_2010"
22DATA="$DATA example_2013 example_2018 example_r14"
23
24for d in $DATA; do
25    b="$(basename "$d")"
26    rm "./$b.svg" 2>/dev/null
27done
28
29for dwg in $DATA; do
30    svg="$(basename "$dwg" .dwg).svg"
31    log="$svg.log"
32    dwg="${DATADIR}/$dwg.dwg"
33    echo "dwg2SVG${EXEEXT} $dwg >$svg &&"
34    echo "  jing /usr/local/share/relaxng/svg11/svg11-basic.rng $svg"
35    if timeout 10 ${top_builddir}/libtool --mode=execute ./dwg2SVG${EXEEXT} "$dwg" >"$svg" 2>"$log" && \
36       jing /usr/local/share/relaxng/svg11/svg11-basic.rng "$svg"
37    then
38        rm "./$svg.log" "./$svg"
39    else
40        cat "$svg.log"
41        i=$((i+1))
42    fi
43done
44
45if test "0" = "$i" ; then
46    exit 0
47else
48    echo "$(basename "$0"): $i failures"
49    ls -l ./*svg.log
50    exit 1
51fi
52