From f9924c6636791410d89c2ec015e25de55449de12 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 31 Aug 2016 15:18:58 +0100 Subject: [PATCH] improve test suite runner --- test/runtest.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/test/runtest.sh b/test/runtest.sh index 3cd5e8c..cb5bc47 100755 --- a/test/runtest.sh +++ b/test/runtest.sh @@ -1,20 +1,77 @@ #!/bin/sh +# +# run test images through libnssvg and count results +# This file is part of libsvgtiny +# +# Licensed under the MIT License, +# http://opensource.org/licenses/mit-license.php +# Copyright 2016 Vincent Sanders TEST_PATH=$1 -TEST_OUT=${TEST_PATH}/test +TEST_OUT=${TEST_PATH}/mvg +TEST_LOG=${TEST_PATH}/test.log mkdir -p ${TEST_OUT} +echo "SVG tests" > ${TEST_LOG} + +# svg test directories + +# netsurf test svg +SVGTESTS="test/data/*.svg" + svgdecode() { OUTF=$(basename ${1} .svg) - echo "TEST: ${OUTF}" - ${TEST_PATH}/test_decode_svg ${1} > ${TEST_OUT}/${OUTF}.mvg + CMPF=$(dirname ${1})/${OUTF}.mvg + echo "SVG:${1}" >> ${TEST_LOG} + ${TEST_PATH}/test_decode_svg ${1} 1.0 ${TEST_OUT}/${OUTF}.mvg 2>> ${TEST_LOG} + ECODE=$? + + echo "Exit code:${ECODE}" >> ${TEST_LOG} + if [ "${ECODE}" -gt 0 ];then + return ${ECODE} + fi + + if [ -f "${CMPF}" ]; then + cmp ${CMPF} ${TEST_OUT}/${OUTF}.ppm >> ${TEST_LOG} 2>> ${TEST_LOG} + if [ "$?" -ne 0 ]; then + return 128 + fi + fi + #convert mvg:${TEST_OUT}/${OUTF}.mvg png:${TEST_OUT}/${OUTF}.png + + return 0 } +SVGTESTTOTC=0 +SVGTESTPASSC=0 +SVGTESTFAILC=0 +SVGTESTERRC=0 + +echo "Testing SVG decode" -for SVG in $(ls test/data/*.svg);do +for SVG in $(ls ${SVGTESTS});do + SVGTESTTOTC=$((SVGTESTTOTC+1)) svgdecode ${SVG} + ECODE=$? + if [ "${ECODE}" -gt 127 ];then + SVGTESTERRC=$((SVGTESTERRC+1)) + else + if [ "${ECODE}" -gt 0 ];then + SVGTESTFAILC=$((SVGTESTFAILC+1)) + else + SVGTESTPASSC=$((SVGTESTPASSC+1)) + fi + fi done +echo "Tests:${SVGTESTTOTC} Pass:${SVGTESTPASSC} Fail:${SVGTESTFAILC} Error:${SVGTESTERRC}" + +# exit code +if [ "${SVGTESTERRC}" -gt 0 ]; then + exit 1 +fi + +exit 0 -- 2.44.2