]> git.draconx.ca Git - liblbx.git/commitdiff
tests: Migrate remaining regress.zsh tests to TAP.
authorNick Bowler <nbowler@draconx.ca>
Sun, 23 Jun 2013 19:11:14 +0000 (15:11 -0400)
committerNick Bowler <nbowler@draconx.ca>
Sun, 23 Jun 2013 19:11:14 +0000 (15:11 -0400)
Makefile.am
tests/moo2-logo.tap [new file with mode: 0755]
tests/moo2-mainmenu.tap
tests/moo2-monster.tap [new file with mode: 0755]
tests/moo2-ships.tap [new file with mode: 0755]
tests/moo2-starbg.tap [new file with mode: 0755]
tests/regress.zsh [deleted file]
tests/util/test-init.sh

index 374cc2a387392b39646af2a7c21f4d6ea6da828c..101f774649d2bcf717b10229f8f49f04eaa84bb5 100644 (file)
@@ -55,7 +55,9 @@ TAP_LOG_COMPILER = $(SHELL)
 TAP_LOG_DRIVER = AM_TAP_AWK='$(AWK)' \
        $(SHELL) $(srcdir)/tests/util/tap-driver.sh
 
-TESTS = tests/empty-image.tap tests/pam-formats.tap tests/moo2-mainmenu.tap
+TESTS = tests/empty-image.tap tests/pam-formats.tap tests/moo2-mainmenu.tap \
+       tests/moo2-logo.tap tests/moo2-starbg.tap tests/moo2-ships.tap \
+       tests/moo2-monster.tap
 
 mostlyclean-local: clean-testdirs
 clean-testdirs:
diff --git a/tests/moo2-logo.tap b/tests/moo2-logo.tap
new file mode 100755 (executable)
index 0000000..64524bf
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# 2ooM: The Master of Orion II Reverse Engineering Project
+# Test correct decoding of various images in logo.lbx
+# Copyright © 2013 Nick Bowler
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "$srcdir/tests/util/test-init.sh" || exit 99
+
+test x"${MOO2DATA+set}" = x"set" ||
+       skip_all_ "test requires original data files"
+dx_create_testdir
+
+plan_ 7
+
+command_ok_ "unpacking logo.lbx" $LBXTOOL -xf "$MOO2DATA/logo.lbx"
+
+command_ok_ "decoding logo.lbx.000" \
+       $LBXIMG -F pam --output-prefix test0 -df logo.lbx.000
+dx_check_pam_md5 "test0.000.pam" e51c564aa638dc62dd1fd79e6f6cc375
+
+command_ok_ "decoding logo.lbx.001" \
+       $LBXIMG -F pam --output-prefix test1 -df logo.lbx.001
+dx_check_pam_md5 "test1.000.pam" 13a60ede277eebe8fec69f03c5cb5843
+dx_check_pam_md5 "test1.030.pam" c687fc35b940d0bfdaea5b6d51aa03c4
+dx_check_pam_md5 "test1.063.pam" 7c694409997fe15272abe71f3fea2759
index 1e8c0757fe32f76510d0628ce786f579db365efe..168c815785f30cca1914de16e2d1c17585504e2e 100755 (executable)
@@ -25,38 +25,21 @@ dx_create_testdir
 
 plan_ 10
 
-check_image_() {
-       dx_pam_header "$1" > "$1.sh" || return
-       . "./$1.sh" || return
-
-       tail -n +"$ENDHDR" "$1" > "$1.px" || return
-       echo "$2  $1.px" > "$1.md5" || return
-       $MD5SUM -c "$1.md5"
-}
-
-check_image() {
-       if $HAVE_MD5SUM; then
-               command_ok_ "$1" check_image_ "$1" "$2"
-       else
-               skip_ "$1"
-       fi
-}
-
 command_ok_ "unpacking fonts.lbx"    $LBXTOOL -xf "$MOO2DATA/fonts.lbx"
 command_ok_ "unpacking mainmenu.lbx" $LBXTOOL -xf "$MOO2DATA/mainmenu.lbx"
 
 command_ok_ "decoding mainmenu.lbx.021" \
        $LBXIMG -F pam --output-prefix test0 -df mainmenu.lbx.021
-check_image "test0.000.pam" 848e33a0addc6e9acdc4fee6cbd56639
+dx_check_pam_md5 "test0.000.pam" 848e33a0addc6e9acdc4fee6cbd56639
 
 command_ok_ "decoding mainmenu.lbx.007" \
        $LBXIMG -F pam --output-prefix test1 --palette fonts.lbx.006 \
                -df mainmenu.lbx.007
-check_image "test1.000.pam" f301ffcc1a2faa3a0aa68514784012ec
+dx_check_pam_md5 "test1.000.pam" f301ffcc1a2faa3a0aa68514784012ec
 
 command_ok_ "decoding mainmenu.lbx.000" \
        $LBXIMG -F pam --output-prefix test2 --palette fonts.lbx.006 \
                -df mainmenu.lbx.000
-check_image "test2.000.pam" 7c3b347e03d42cd7bd1597f9dd58594e
-check_image "test2.015.pam" 2a66f4c30ca315cc061606b27cef4adf
-check_image "test2.049.pam" 848e33a0addc6e9acdc4fee6cbd56639
+dx_check_pam_md5 "test2.000.pam" 7c3b347e03d42cd7bd1597f9dd58594e
+dx_check_pam_md5 "test2.015.pam" 2a66f4c30ca315cc061606b27cef4adf
+dx_check_pam_md5 "test2.049.pam" 848e33a0addc6e9acdc4fee6cbd56639
diff --git a/tests/moo2-monster.tap b/tests/moo2-monster.tap
new file mode 100755 (executable)
index 0000000..337daab
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# 2ooM: The Master of Orion II Reverse Engineering Project
+# Test correct decoding of various images in monster.lbx
+# Copyright © 2013 Nick Bowler
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "$srcdir/tests/util/test-init.sh" || exit 99
+
+test x"${MOO2DATA+set}" = x"set" ||
+       skip_all_ "test requires original data files"
+dx_create_testdir
+
+plan_ 6
+
+command_ok_ "unpacking fonts.lbx"   $LBXTOOL -xf "$MOO2DATA/fonts.lbx"
+command_ok_ "unpacking monster.lbx" $LBXTOOL -xf "$MOO2DATA/monster.lbx"
+
+command_ok_ "decoding monster.lbx.007" \
+       $LBXIMG -F pam --output-prefix test0 --palette fonts.lbx.004 \
+               -df monster.lbx.007 --override monster.lbx.014
+dx_check_pam_md5 "test0.000.pam" 35d32459bfce6b19df14cafd2faf398b
+dx_check_pam_md5 "test0.005.pam" 924fafdc83e0414331e0c627c3f9b3c7
+dx_check_pam_md5 "test0.019.pam" 272ca2d13132a1b0497e47225ee680e2
diff --git a/tests/moo2-ships.tap b/tests/moo2-ships.tap
new file mode 100755 (executable)
index 0000000..7a64d88
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# 2ooM: The Master of Orion II Reverse Engineering Project
+# Test correct decoding of various images in ships.lbx
+# Copyright © 2013 Nick Bowler
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "$srcdir/tests/util/test-init.sh" || exit 99
+
+test x"${MOO2DATA+set}" = x"set" ||
+       skip_all_ "test requires original data files"
+dx_create_testdir
+
+plan_ 4
+
+command_ok_ "unpacking fonts.lbx" $LBXTOOL -xf "$MOO2DATA/fonts.lbx"
+command_ok_ "unpacking ships.lbx" $LBXTOOL -xf "$MOO2DATA/ships.lbx"
+
+command_ok_ "decoding ships.lbx.042" \
+       $LBXIMG -F pam --output-prefix test0 --palette fonts.lbx.012 \
+               -df ships.lbx.042 --override ships.lbx.049
+dx_check_pam_md5 "test0.000.pam" 4ababc13ae860494d4f512f8ebeca834
diff --git a/tests/moo2-starbg.tap b/tests/moo2-starbg.tap
new file mode 100755 (executable)
index 0000000..bb33372
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# 2ooM: The Master of Orion II Reverse Engineering Project
+# Test correct decoding of various images in starbg.lbx
+# Copyright © 2013 Nick Bowler
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "$srcdir/tests/util/test-init.sh" || exit 99
+
+test x"${MOO2DATA+set}" = x"set" ||
+       skip_all_ "test requires original data files"
+dx_create_testdir
+
+plan_ 4
+
+command_ok_ "unpacking fonts.lbx"  $LBXTOOL -xf "$MOO2DATA/fonts.lbx"
+command_ok_ "unpacking starbg.lbx" $LBXTOOL -xf "$MOO2DATA/starbg.lbx"
+
+command_ok_ "decoding starbg.lbx.009" \
+       $LBXIMG -F pam --output-prefix test0 --palette fonts.lbx.005 \
+               -df starbg.lbx.009
+dx_check_pam_md5 "test0.000.pam" 3b6ccbe3fc46e13c1fa80edf611d7a62
diff --git a/tests/regress.zsh b/tests/regress.zsh
deleted file mode 100755 (executable)
index a3a5adf..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/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 b5d488667bed557a089c5d8f8b0a3d64
-
-echo "mainmenu.lbx.007: single frame, external palette:"
-$LBXIMG -dp fonts.lbx.006 < mainmenu.lbx.007
-compare 0 5b9a1a10e4979531e91a41f02ee40537
-
-echo "mainmenu.lbx.000: multi frame, external palette:"
-$LBXIMG -dp fonts.lbx.006 < mainmenu.lbx.000 0 15 49
-compare  0 6556baafebe441498f33865f2e9eb0de
-compare 15 76a6e8fe18614423f8780ee80f513e8c
-compare 49 b5d488667bed557a089c5d8f8b0a3d64
-
-# Logos
-$LBXTOOL -xf $DATADIR/logo.lbx
-
-echo "logo.lbx.000: single frame, embedded palette, transparency:"
-$LBXIMG -df logo.lbx.000
-compare 0 cf4cbcb834ef35890d1283928b0187bf
-
-echo "logo.lbx.001: multi frame, embedded palette:"
-$LBXIMG -df logo.lbx.001 0 30 63
-compare  0 542778cde51dc821e225ddd4a16dc197
-compare 30 609c2b9be5a1e18f5c36398554f9f2ec
-compare 63 664b12c7259948900ded3ff93e1f4ec7
-
-# 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 3426ef9c5c8e3dfbd1a95ed9211e2342
-
-# Nebulae
-$LBXTOOL -xf $DATADIR/starbg.lbx starbg.lbx.009
-
-echo "starbg.lbx.009: single frame, raw data:"
-$LBXIMG -df starbg.lbx.009 -p fonts.lbx.005
-compare 0 2e430234f410ef208f78d99a64fa449f
-
-# Monsters
-$LBXTOOL -xf $DATADIR/monster.lbx monster.lbx.{007,014}
-
-echo "monster.lbx.007: multi frame, chunked:"
-$LBXIMG -df monster.lbx.007 -p fonts.lbx.004 -O monster.lbx.014 0 5 19
-compare  0 20eb7d52abb3cd718426d4732d9e2286
-compare  5 ea8c7a5fbeb9043fd8f30ae91b13550a
-compare 19 d501ecf1599ea724846625a9711c6ccb
-
-# Clean up
-if [[ $FAILED -eq 0 ]]; then
-       echo "All tests completed successfully."
-       rm -rf -- $SCRATCH
-else
-       echo "$FAILED test(s) FAILED"
-       exit 1
-fi
index 5cd161a2d6d8ddfe4d8caa22b3a49d59bfb5b430..52625c0d199f86f66f14957a42cb4ffdbfc68e3a 100644 (file)
@@ -114,6 +114,23 @@ dx_pam_header()
                END { exit ret }' ${1+"$@"}
 }
 
+dx_check_pam_md5_() {
+       dx_pam_header "$1" > "$1.sh" || return
+       . "./$1.sh" || return
+
+       tail -n +"$ENDHDR" "$1" > "$1.px" || return
+       echo "$2  $1.px" > "$1.md5" || return
+       $MD5SUM -c "$1.md5"
+}
+
+dx_check_pam_md5() {
+       if $HAVE_MD5SUM; then
+               command_ok_ "$1" dx_check_pam_md5_ "$1" "$2"
+       else
+               skip_ "$1"
+       fi
+}
+
 # Variables to run the LBX tools.  Default to the build tree, but can also be
 # set explicitly to test installed tools.
 : "${LBXTOOL=$builddir/lbxtool$EXEEXT}"