-#!/bin/sh
+#!/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`"
+LBXTOOL=`readlink -f ../lbxtool`
+LBXIMG=`readlink -f ../lbximg`
# Status vars
FAILED=0
-if ! SCRATCH="`mktemp -d`"; then
+if ! SCRATCH=`mktemp -d`; then
exit 1
fi
-cd "$SCRATCH"
+cd $SCRATCH || exit 1
echo "Working in $SCRATCH"
# Palettes
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"
+
+ 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"
+ echo FAILED
FAILED=`expr $FAILED + 1`
fi
}
compare 49 390c49cfd1fe5e2ac0490be976f20936
# Logos
-$LBXTOOL -xf $DATADIR/logo.lbx
+$LBXTOOL -xf $DATADIR/logo.lbx
echo "logo.lbx.000: single frame, embedded palette, transparency:"
$LBXIMG -df logo.lbx.000
compare 0 bd643736d46ef387bcffcc8803aabb83
# Clean up
-if [ $FAILED -eq 0 ]; then
+if [[ $FAILED -eq 0 ]]; then
echo "All tests completed successfully."
- rm -rf -- "$SCRATCH"
+ rm -rf -- $SCRATCH
else
echo "$FAILED test(s) FAILED"
fi