X-Git-Url: http://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/06f665a8e8809982e6649d0ed55990581122f4bf..abebb179629944e7c956857be2f6d6705fb33309:/tests/util/test-init.sh diff --git a/tests/util/test-init.sh b/tests/util/test-init.sh index e8a53da..d59b853 100644 --- a/tests/util/test-init.sh +++ b/tests/util/test-init.sh @@ -1,6 +1,6 @@ # 2ooM: The Master of Orion II Reverse Engineering Project # Common test suite initialization functions. -# Copyright © 2013 Nick Bowler +# 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 @@ -25,8 +25,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -set -e - test ${test_lib_sourced-no} = yes && return 0 test_lib_sourced=yes @@ -86,11 +84,10 @@ testdata=$srcdir/tests/testdata dx_testname=`expr x"$argv0" : x'.*/\(.*\)\.'` dx_testdir=tests/$dx_testname.dir -dx_cleanup_testdir() -{ +dx_cleanup_testdir() { exitstatus=$1 - cd "$builddir" + cd "$builddir" || return if test "$exitstatus" -eq 0 && test $tap_pass_count_ -eq $tap_count_ then @@ -98,13 +95,41 @@ dx_cleanup_testdir() fi } -dx_create_testdir() -{ - $MKDIR_P "$dx_testdir" +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+"$@"} +} + +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}"