]> git.draconx.ca Git - liblbx.git/commitdiff
tests: Migrate the mainmenu.lbx tests to the TAP system.
authorNick Bowler <nbowler@draconx.ca>
Sat, 22 Jun 2013 14:01:39 +0000 (10:01 -0400)
committerNick Bowler <nbowler@draconx.ca>
Sat, 22 Jun 2013 14:01:39 +0000 (10:01 -0400)
This moves the first set of regress.zsh tests to the new framework.

Makefile.am
configure.ac
gnulib
m4/md5sum.m4 [new file with mode: 0644]
tests/moo2-mainmenu.tap [new file with mode: 0755]
tests/util/test-defs.sh.in

index c3aecbb5161a2bbbeb15aa2fb1b619b869acd9c6..374cc2a387392b39646af2a7c21f4d6ea6da828c 100644 (file)
@@ -55,7 +55,7 @@ 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 = tests/empty-image.tap tests/pam-formats.tap tests/moo2-mainmenu.tap
 
 mostlyclean-local: clean-testdirs
 clean-testdirs:
index 5d30173aa985b00f53479a46898a1fffd6b202a1..af2b64f3d789dac4723e99aeff29b6f2b49c7bcc 100644 (file)
@@ -51,6 +51,12 @@ AS_CASE([$enable_lbxgui],
 
 AM_CONDITIONAL([BUILD_LBXGUI], [$have_gtk])
 
+DX_PROG_MD5SUM
+AS_IF([test x"$dx_cv_md5sum_works" = x"yes"],
+       [AC_SUBST([HAVE_MD5SUM], [true])],
+       [AC_SUBST([HAVE_MD5SUM], [false])])
+AC_SUBST([MD5SUM])
+
 AC_CONFIG_FILES([
        tests/util/test-defs.sh
        Makefile
diff --git a/gnulib b/gnulib
index 162b3eb8ff8eca18d7c6cfbe3a4b98aa4e5972ce..68f90afdb82204c27a50e7bce169d2b3795a1ddd 160000 (submodule)
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 162b3eb8ff8eca18d7c6cfbe3a4b98aa4e5972ce
+Subproject commit 68f90afdb82204c27a50e7bce169d2b3795a1ddd
diff --git a/m4/md5sum.m4 b/m4/md5sum.m4
new file mode 100644 (file)
index 0000000..d3926ba
--- /dev/null
@@ -0,0 +1,20 @@
+AC_DEFUN([DX_PROG_MD5SUM], [dnl
+AC_CHECK_PROGS([MD5SUM], [md5sum], [false])
+AC_CACHE_CHECK([whether md5sum works], [dx_cv_md5sum_works], [dnl
+       dx_cv_md5sum_works=yes
+       # Positive test
+       cat >conftest.md5 <<'EOF'
+d41d8cd98f00b204e9800998ecf8427e  /dev/null
+EOF
+       if $MD5SUM -c conftest.md5 >/dev/null 2>&1; then :; else
+               dx_cv_md5sum_works=no
+       fi
+       # Negative test
+       cat >conftest.md5 <<'EOF'
+d41d8cd98f00b204e9810998ecf8427e  /dev/null
+EOF
+       if $MD5SUM -c conftest.md5 >/dev/null 2>&1; then
+               dx_cv_md5sum_works=no
+       fi
+       rm -f conftest.md5
+])])
diff --git a/tests/moo2-mainmenu.tap b/tests/moo2-mainmenu.tap
new file mode 100755 (executable)
index 0000000..1e8c075
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# 2ooM: The Master of Orion II Reverse Engineering Project
+# Test correct decoding of various images in mainmenu.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_ 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
+
+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
+
+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
index 4e65a61534fcf57f26f981f54f438694e46c7a04..d56b97ca7afd2fbf277f14254d14ddaa1c085af7 100644 (file)
@@ -4,4 +4,7 @@ srcdir='@abs_top_srcdir@'
 builddir='@abs_top_builddir@'
 
 MKDIR_P='@MKDIR_P@'
+HAVE_MD5SUM='@HAVE_MD5SUM@'
+MD5SUM='@MD5SUM@'
+
 EXEEXT='@EXEEXT@'