From 3d1e13378f4e3cd29bd2698fed4552024f87e9c2 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 22 Jun 2013 10:01:39 -0400 Subject: [PATCH] tests: Migrate the mainmenu.lbx tests to the TAP system. This moves the first set of regress.zsh tests to the new framework. --- Makefile.am | 2 +- configure.ac | 6 ++++ gnulib | 2 +- m4/md5sum.m4 | 20 ++++++++++++ tests/moo2-mainmenu.tap | 62 ++++++++++++++++++++++++++++++++++++++ tests/util/test-defs.sh.in | 3 ++ 6 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 m4/md5sum.m4 create mode 100755 tests/moo2-mainmenu.tap diff --git a/Makefile.am b/Makefile.am index c3aecbb..374cc2a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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: diff --git a/configure.ac b/configure.ac index 5d30173..af2b64f 100644 --- a/configure.ac +++ b/configure.ac @@ -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 162b3eb..68f90af 160000 --- 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 index 0000000..d3926ba --- /dev/null +++ b/m4/md5sum.m4 @@ -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 index 0000000..1e8c075 --- /dev/null +++ b/tests/moo2-mainmenu.tap @@ -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 . + +. "$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 diff --git a/tests/util/test-defs.sh.in b/tests/util/test-defs.sh.in index 4e65a61..d56b97c 100644 --- a/tests/util/test-defs.sh.in +++ b/tests/util/test-defs.sh.in @@ -4,4 +4,7 @@ srcdir='@abs_top_srcdir@' builddir='@abs_top_builddir@' MKDIR_P='@MKDIR_P@' +HAVE_MD5SUM='@HAVE_MD5SUM@' +MD5SUM='@MD5SUM@' + EXEEXT='@EXEEXT@' -- 2.43.0