]> gitweb.michael.orlitzky.com - libsvgtiny.git/blob - test/runtest.sh
src/svgtiny_css.c: use our userdata handler in set_libcss_node_data()
[libsvgtiny.git] / test / runtest.sh
1 #!/bin/sh
2 #
3 # run test images through libnssvg and count results
4 # This file is part of libsvgtiny
5 #
6 # Licensed under the MIT License,
7 # http://opensource.org/licenses/mit-license.php
8 # Copyright 2016 Vincent Sanders <vince@netsurf-browser.org>
9
10 TEST_PATH=$1
11 TEST_OUT=${TEST_PATH}/mvg
12 TEST_LOG=${TEST_PATH}/test.log
13
14 mkdir -p ${TEST_OUT}
15
16 echo "SVG tests" > ${TEST_LOG}
17
18 # svg test directories
19
20 # netsurf test svg
21 SVGTESTS="test/data/*.svg"
22
23 # netsurf afl generated svg suite
24 SVGTESTS="${SVGTESTS} test/ns-afl-svg/*.svg"
25
26 svgdecode()
27 {
28 OUTF=$(basename ${1} .svg)
29 CMPF=$(dirname ${1})/${OUTF}.mvg
30 echo "SVG:${1}" >> ${TEST_LOG}
31 ${TEST_PATH}/test_decode_svg ${1} 1.0 ${TEST_OUT}/${OUTF}.mvg 2>> ${TEST_LOG}
32 ECODE=$?
33
34 echo "Exit code:${ECODE}" >> ${TEST_LOG}
35 if [ "${ECODE}" -gt 0 ];then
36 return ${ECODE}
37 fi
38
39 if [ -f "${CMPF}" ]; then
40 cmp ${CMPF} ${TEST_OUT}/${OUTF}.ppm >> ${TEST_LOG} 2>> ${TEST_LOG}
41 if [ "$?" -ne 0 ]; then
42 return 128
43 fi
44 fi
45
46 #convert mvg:${TEST_OUT}/${OUTF}.mvg png:${TEST_OUT}/${OUTF}.png
47
48 return 0
49 }
50
51 SVGTESTTOTC=0
52 SVGTESTPASSC=0
53 SVGTESTFAILC=0
54 SVGTESTERRC=0
55
56 echo "Testing SVG decode"
57
58 for SVG in $(ls ${SVGTESTS});do
59 SVGTESTTOTC=$((SVGTESTTOTC+1))
60 svgdecode ${SVG}
61 ECODE=$?
62 if [ "${ECODE}" -gt 127 ];then
63 SVGTESTERRC=$((SVGTESTERRC+1))
64 else
65 if [ "${ECODE}" -gt 0 ];then
66 SVGTESTFAILC=$((SVGTESTFAILC+1))
67 else
68 SVGTESTPASSC=$((SVGTESTPASSC+1))
69 fi
70 fi
71 done
72
73 echo "Tests:${SVGTESTTOTC} Pass:${SVGTESTPASSC} Fail:${SVGTESTFAILC} Error:${SVGTESTERRC}"
74
75 # exit code
76 if [ "${SVGTESTFAILC}" -gt 0 ]; then
77 exit 1
78 fi
79 if [ "${SVGTESTERRC}" -gt 0 ]; then
80 exit 2
81 fi
82
83 exit 0