From: Nick Bowler Date: Tue, 1 Jan 2008 04:48:27 +0000 (-0500) Subject: Add a basic regression test tool. X-Git-Url: http://git.draconx.ca/gitweb/liblbx.git/commitdiff_plain/8325f5adeef29ffc7032c832d525a0822e19d74c Add a basic regression test tool. --- diff --git a/tests/regress.sh b/tests/regress.sh new file mode 100755 index 0000000..9c56d77 --- /dev/null +++ b/tests/regress.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Simple test which decodes some images from LBX archives and compares against +# known md5sums to find regressions. Unforuntately depends on the output +# format of lbximg; this may change in the future. + +# Image/tool paths. Adjust to taste. The DATADIR must contain the original +# Moo2 LBX archives, with filenames in lower case. +DATADIR=$HOME/.2oom/game +LBXTOOL="`readlink -f ../src/lbxtool`" +LBXIMG="`readlink -f ../src/lbximg`" + +# Status vars +FAILED="" + +if ! SCRATCH="`mktemp -d`"; then + exit 1 +fi + +cd "$SCRATCH" +echo "Working in $SCRATCH" + +# Palettes +$LBXTOOL -xf $DATADIR/fonts.lbx + +compare() +{ + echo -n " Frame $1 " + FILE="$(printf 'out.%03d.png' $1)" + MD5="$(md5sum "$FILE" | cut -d ' ' -f 1)" + if [ "$MD5" = "$2" ]; then + echo "OK" + rm -f "$FILE" + else + echo "FAILED" + FAILED="yes" + fi +} + +# Main menu +$LBXTOOL -xf $DATADIR/mainmenu.lbx mainmenu.lbx.{000,007,021} + +echo "mainmenu.lbx.021: single frame, embedded palette:" +$LBXIMG -df mainmenu.lbx.021 +compare 0 390c49cfd1fe5e2ac0490be976f20936 + +echo "mainmenu.lbx.007: single frame, external palette:" +$LBXIMG -dp fonts.lbx.006 < mainmenu.lbx.007 +compare 0 76def3e188f666025c62e621e23ab0d0 + +echo "mainmenu.lbx.000: multi frame, external palette:" +$LBXIMG -dp fonts.lbx.006 < mainmenu.lbx.000 0 15 49 +compare 0 cc4ae6d96f6233f3b50bdce8b7ca74ee +compare 15 cad158da9a015adfcea7809a8a3b6f4b +compare 49 390c49cfd1fe5e2ac0490be976f20936 + +# Logos +$LBXTOOL -xf $DATADIR/logo.lbx + +echo "logo.lbx.000: single frame, embedded palette:" +$LBXIMG -df logo.lbx.000 +compare 0 75f9e5a7205192b414f009424ffb7dc3 + +echo "logo.lbx.001: multi frame, embedded palette:" +$LBXIMG -df logo.lbx.001 0 30 63 +compare 0 f3f0859b39f2e76091842c8a7276b2a1 +compare 30 8fb41356a20c68c3be0939ad49256cf9 +compare 63 156f381c5d4bf6178affd3d6a4720118 + +# Clean up +[ -z "$FAILED" ] && rm -rf -- "$SCRATCH"