]> git.draconx.ca Git - liblbx.git/blobdiff - tests/regress.zsh
test: Fix up regression test script.
[liblbx.git] / tests / regress.zsh
diff --git a/tests/regress.zsh b/tests/regress.zsh
new file mode 100755 (executable)
index 0000000..20239b5
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/env zsh
+# 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 ../lbxtool`
+LBXIMG=`readlink -f ../lbximg`
+
+# Status vars
+FAILED=0
+
+if ! SCRATCH=`mktemp -d`; then
+       exit 1
+fi
+
+cd $SCRATCH || exit 1
+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=`expr $FAILED + 1`
+       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, transparency:"
+$LBXIMG -df logo.lbx.000
+compare 0 5cc8d2b761390d15be2738030c658bfc
+
+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
+
+# Ships
+$LBXTOOL -xf $DATADIR/ships.lbx ships.lbx.{042,049}
+
+echo "ships.lbx.042: single frame, external+override palette, transparency:"
+$LBXIMG -df ships.lbx.042 -p fonts.lbx.012 -O ships.lbx.049
+compare 0 bd643736d46ef387bcffcc8803aabb83
+
+# Clean up
+if [[ $FAILED -eq 0 ]]; then
+       echo "All tests completed successfully."
+       rm -rf -- $SCRATCH
+else
+       echo "$FAILED test(s) FAILED"
+fi