summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-08-12 14:29:04 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2016-08-12 14:29:04 (GMT)
commit091d1a1f15aab463054f637d6830808bbe893af8 (patch)
tree8908159321edcc5e9644f8dd6945acb851093a0b
parentb017792feaa0c28ef22d0d60e11612846e8e1db5 (diff)
downloadlibnsbmp-091d1a1f15aab463054f637d6830808bbe893af8.tar.gz
libnsbmp-091d1a1f15aab463054f637d6830808bbe893af8.tar.bz2
Improve test runner and prevent generation of excessively large output
-rw-r--r--test/decode_bmp.c5
-rwxr-xr-xtest/runtest.sh75
2 files changed, 70 insertions, 10 deletions
diff --git a/test/decode_bmp.c b/test/decode_bmp.c
index e5dc572..e90515a 100644
--- a/test/decode_bmp.c
+++ b/test/decode_bmp.c
@@ -70,6 +70,11 @@ int main(int argc, char *argv[])
res = 1;
goto cleanup;
}
+ /* skip if the decoded image would be ridiculously large */
+ if ((bmp.width * bmp.height) > 2000000) {
+ res = 1;
+ goto cleanup;
+ }
}
printf("P3\n");
diff --git a/test/runtest.sh b/test/runtest.sh
index 23d792e..c3e504c 100755
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -1,33 +1,88 @@
#!/bin/sh
+# run test images through libnsbmp and count results
+
TEST_PATH=$1
TEST_OUT=${TEST_PATH}/ppm
+TEST_LOG=${TEST_PATH}/test.log
mkdir -p ${TEST_OUT}
+# bitmap test directories
+
+# standard bitmap suite
+BMPTESTS="test/bmpsuite/*.bmp"
+
+# netsurf test bitmaps
+BMPTESTS="${BMPTESTS} test/bmp/*.bmp"
+
+# icon test directories
+ICOTESTS="test/icons/*.ico"
+
bmpdecode()
{
OUTF=$(basename ${1} .bmp)
- ${TEST_PATH}/test_decode_bmp ${1} > ${TEST_OUT}/${OUTF}.ppm
+ echo "Bitmap:${1}" >> ${TEST_LOG}
+ ${TEST_PATH}/test_decode_bmp ${1} > ${TEST_OUT}/${OUTF}.ppm 2>> ${TEST_LOG}
+ ECODE=$?
+ echo "Exit code:${ECODE}" >> ${TEST_LOG}
+ return ${ECODE}
}
icodecode()
{
OUTF=$(basename ${1} .ico)
- ${TEST_PATH}/test_decode_ico ${1} > ${TEST_OUT}/${OUTF}.ppm
+ echo "Icon:${1}" >> ${TEST_LOG}
+ ${TEST_PATH}/test_decode_ico ${1} > ${TEST_OUT}/${OUTF}.ppm 2>> ${TEST_LOG}
}
-# standard bitmap suite
-for BMP in $(ls test/bmpsuite/*.bmp);do
+# bitmap tests
+
+BMPTESTTOTC=0
+BMPTESTPASSC=0
+BMPTESTERRC=0
+
+for BMP in $(ls ${BMPTESTS});do
+ BMPTESTTOTC=$((BMPTESTTOTC+1))
bmpdecode ${BMP}
+ ECODE=$?
+ if [ "${ECODE}" -gt 128 ];then
+ BMPTESTERRC=$((BMPTESTERRC+1))
+ else
+ BMPTESTPASSC=$((BMPTESTPASSC+1))
+ fi
done
-# test bitmaps
-for ICO in $(ls test/bmp/*.bmp);do
- bmpdecode ${ICO}
-done
+echo "Test bitmap decode"
+echo "Tests:${BMPTESTTOTC} Pass:${BMPTESTPASSC} Error:${BMPTESTERRC}"
+
+
+# icon tests
-# test icons
-for ICO in $(ls test/icons/*.ico);do
+ICOTESTTOTC=0
+ICOTESTPASSC=0
+ICOTESTERRC=0
+
+# netsurf test icons
+for ICO in $(ls ${ICOTESTS});do
+ ICOTESTTOTC=$((BMPTESTTOTC+1))
icodecode ${ICO}
+ ECODE=$?
+ if [ "${ECODE}" -gt 128 ];then
+ ICOTESTERRC=$((ICOTESTERRC+1))
+ else
+ ICOTESTPASSC=$((ICOTESTPASSC+1))
+ fi
done
+
+echo "Test icon decode"
+echo "Tests:${ICOTESTTOTC} Pass:${ICOTESTPASSC} Error:${ICOTESTERRC}"
+
+
+
+# exit code
+if [ "${BMPTESTERRC}" -gt 0 -o "${ICOTESTERRC}" -gt 0 ]; then
+ exit 1
+fi
+
+exit 0