X-Git-Url: http://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/d1c92ce9f559ece233cb82425d634bf6484aff2f..9969a6cd8e946ea3bbcd7f4b357b0e60fc02fe43:/tests/util/test-init.sh diff --git a/tests/util/test-init.sh b/tests/util/test-init.sh deleted file mode 100644 index 2c72bf3..0000000 --- a/tests/util/test-init.sh +++ /dev/null @@ -1,180 +0,0 @@ -# 2ooM: The Master of Orion II Reverse Engineering Project -# Common test suite initialization functions. -# Copyright © 2013-2014 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 file incorporates work covered by the following copyright and -# permission notice: -# -# Copyright (C) 1996-2013 Free Software Foundation, Inc. -# -# 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 2, 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 . - -test ${test_lib_sourced-no} = yes && return 0 -test_lib_sourced=yes - -# CDPATH is evil if used in non-interactive scripts (and even more -# evil if exported in the environment). -CDPATH=; unset CDPATH - -# Be more Bourne compatible. -# (Snippet inspired to configure's initialization in Autoconf 2.64) -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - setopt NO_GLOB_SUBST - # If Zsh is not started directly in POSIX-compatibility mode, it has - # some incompatibilities in the handling of $0 that conflict with our - # usage; i.e., $0 inside a file sourced with the '.' builtin is - # temporarily set to the name of the sourced file. Work around that. - # Note that a bug in some versions of Zsh prevents us from resetting $0 - # in a sourced script, so the use of $argv0. For more info see: - # - # The apparently useless 'eval' here is needed by at least dash 0.5.2, - # to prevent it from bailing out with an error like: - # "Syntax error: Bad substitution". - eval 'argv0=${functrace[-1]%:*}' && test -f "$argv0" || { - echo "Cannot determine the path of running test script." >&2 - echo "Your Zsh (version $ZSH_VERSION) is probably too old." >&2 - exit 99 - } -else - argv0=$0 - # Ignore command substitution failure, for it might cause problems - # with "set -e" on some shells. - am_shell_opts=$(set -o) || : - case $am_shell_opts in *posix*) set -o posix;; esac - unset am_shell_opts -fi - -# A single whitespace character. -sp=' ' -# A tabulation character. -tab=' ' -# A newline character. -nl=' -' - -# As autoconf-generated configure scripts do, ensure that IFS -# is defined initially, so that saving and restoring $IFS works. -IFS=$sp$tab$nl - -. "$srcdir/tests/util/tap-functions.sh" -. "$srcdir/tests/util/test-defs.sh" - -testdata=$srcdir/tests/testdata - -# We need a scratch directory for most tests, so set that up now. -dx_testname=`expr x"$argv0" : x'.*/\(.*\)\.'` -dx_testdir=tests/$dx_testname.dir - -dx_cleanup_testdir() { - exitstatus=$1 - - cd "$builddir" || return - if test "$exitstatus" -eq 0 && - test $tap_pass_count_ -eq $tap_count_ - then - rm -rf "$dx_testdir" - fi -} - -dx_create_testdir_() { - $MKDIR_P "$dx_testdir" || return - trap 'dx_cleanup_testdir $?' 0 - cd "$dx_testdir" -} - -dx_create_testdir() { - dx_create_testdir_ || bailout_ "failed to create test directory" -} - -dx_pam_header() { - awk 'BEGIN { ret=1 } - NR==1 { if (!/^P7$/) exit 1 } - /^P7$/,/^ENDHDR$/ { ret=0; if ($2) print $1"="$2 } - /^ENDHDR$/ { print $1"="NR+1; exit } - END { exit ret }' ${1+"$@"} -} - -# Set all transparent pixels in a PAM image to black. This assumes (fine for -# LBX images) that all pixels are either fully-transparent or fully-opaque. -dx_pam_normalize() { - dx_pam_header "$1" > "$1.sh" || return - ( . "./$1.sh" || exit - case $TUPLTYPE in - GRAYSCALE_ALPHA) $PAMCHANNEL -infile "$1" 1 > "$1.alpha" ;; - RGB_ALPHA) $PAMCHANNEL -infile "$1" 3 > "$1.alpha" ;; - *) rm -f "$1.alpha" ;; - esac - ) || return - - if test -e "$1.alpha"; then - $PAMARITH -and "$1" "$1.alpha" - else - cat "$1" - fi -} - -dx_check_pam_md5_() { - ( dx_pam_header "$1" > "$1.sh" || exit - . "./$1.sh" || exit - tail -n +"$ENDHDR" "$1" > "$1.px" - ) || return 55 - - $MD5SUM -c < "$1.tmp"; then - mv -f "$1.tmp" "$1" - dx_md5_reliable=true - else - dx_md5_reliable=false - fi - - dx_check_pam_md5_ "$1" "$2" - case $? in - 0) ok_ "$1" ;; - 55) not_ok_ "$1" ;; - *) if $dx_md5_reliable; then - not_ok_ "$1" - else - skip_ -r "netpbm unavailable or broken" "$1" - fi ;; - esac - else - skip_ -r "md5sum unavailable or broken" "$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}" -: "${LBXIMG=$builddir/lbximg$EXEEXT}" - -# Set MALLOC_CHECK_ in the environment of the test programs which will enable -# malloc instrumentation on glibc-based systems to hopefully catch some forms -# of memory corruption. -dx_test_wrapper="$builddir/libtool --mode=execute env MALLOC_CHECK_=3" -LBXTOOL="$dx_test_wrapper $LBXTOOL" -LBXIMG="$dx_test_wrapper $LBXIMG"