msgndebug() { msgprintf "${CDEBUG}D: %s" '%s' "${CNORMAL}" "$@"; }
msgtest() { msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@"; }
msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; }
-msgskip() {
+msgreportheader() {
if [ -n "$MSGTEST_MSG" ]; then
+ test "$1" != 'msgfailoutput' || echo
if [ -n "$MSGTEST_MSGMSG" ]; then
echo "$MSGTEST_MSGMSG"
fi
if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
- echo "Part of the test group: $MSGTEST_GRP"
+ echo "${CFAIL}Part of the test group: $MSGTEST_GRP"
fi
echo -n "$MSGTEST_MSG"
unset MSGTEST_MSG
fi
+}
+msgskip() {
+ msgreportheader 'msgskip'
if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2;
else printf "${CWARNING}SKIP${CNORMAL}\n" >&2; fi
}
msgfail() {
- if [ -n "$MSGTEST_MSG" ]; then
- if [ -n "$MSGTEST_MSGMSG" ]; then
- echo "$MSGTEST_MSGMSG"
- fi
- if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
- echo "Part of the test group: $MSGTEST_GRP"
- fi
- echo -n "$MSGTEST_MSG"
- unset MSGTEST_MSG
- fi
+ msgreportheader 'msgfail'
if [ $# -gt 0 ] && [ -n "$1" ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
if [ -n "$APT_DEBUG_TESTS" ]; then
}
testfileequal() {
- msggroup "$0"
+ msggroup 'testfileequal'
local MSG='Test for correctness of file'
if [ "$1" = '--nomsg' ]; then
MSG=''
}
testempty() {
- msggroup "$0"
+ msggroup 'testempty'
msgtest "Test for no output of" "$*"
local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
}
testequal() {
- msggroup "$0"
+ msggroup 'testequal'
local MSG='Test of equality of'
if [ "$1" = '--nomsg' ]; then
MSG=''
}
testequalor2() {
- msggroup "$0"
+ msggroup 'testequalor2'
local COMPAREFILE1="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
local COMPAREFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
local COMPAREAGAINST="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
}
testshowvirtual() {
- msggroup "$0"
+ msggroup 'testshowvirtual'
local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual"
local PACKAGE="$1"
shift
}
testnopackage() {
- msggroup "$0"
+ msggroup 'testnopackage'
msgtest "Test for non-existent packages" "apt-cache show $*"
local SHOWPKG="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
if [ -n "$SHOWPKG" ]; then
}
testdpkgstatus() {
- msggroup "$0"
+ msggroup 'testdpkgstatus'
local STATE="$1"
local NR="$2"
shift 2
}
testdpkginstalled() {
- msggroup "$0"
+ msggroup 'testdpkginstalled'
testdpkgstatus 'ii' "$#" "$@"
msggroup
}
testdpkgnotinstalled() {
- msggroup "$0"
+ msggroup 'testdpkgnotinstalled'
testdpkgstatus 'ii' '0' "$@"
msggroup
}
testmarkedauto() {
- msggroup "$0"
+ msggroup 'testmarkedauto'
local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
if [ -n "$1" ]; then
msgtest 'Test for correctly marked as auto-installed' "$*"
msggroup
}
testmarkedmanual() {
- msggroup "$0"
+ msggroup 'testmarkedmanual'
local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedmanual.comparefile"
if [ -n "$1" ]; then
msgtest 'Test for correctly marked as manually installed' "$*"
}
msgfailoutput() {
- if [ -n "$MSGTEST_MSG" ]; then
- echo
- if [ -n "$MSGTEST_MSGMSG" ]; then
- echo "$MSGTEST_MSGMSG"
- fi
- if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
- echo "${CFAIL}Part of the test group: $MSGTEST_GRP"
- fi
- echo -n "$MSGTEST_MSG"
- unset MSGTEST_MSG
- fi
+ msgreportheader 'msgfailoutput'
local MSG="$1"
local OUTPUT="$2"
shift 2
}
testsuccess() {
- msggroup "$0"
+ msggroup 'testsuccess'
if [ "$1" = '--nomsg' ]; then
shift
else
msggroup
}
testwarning() {
- msggroup "$0"
+ msggroup 'testwarning'
if [ "$1" = '--nomsg' ]; then
shift
else
msggroup
}
testfailure() {
- msggroup "$0"
+ msggroup 'testfailure'
if [ "$1" = '--nomsg' ]; then
shift
else
}
testsuccessequal() {
- msggroup "$0"
+ msggroup 'testsuccessequal'
local CMP="$1"
shift
testsuccess "$@"
msggroup
}
testwarningequal() {
- msggroup "$0"
+ msggroup 'testwarningequal'
local CMP="$1"
shift
testwarning "$@"
msggroup
}
testfailureequal() {
- msggroup "$0"
+ msggroup 'testfailureequal'
local CMP="$1"
shift
testfailure "$@"
}
testfailuremsg() {
- msggroup "$0"
+ msggroup 'testfailuremsg'
local CMP="$1"
shift
testfailure "$@"
}
testfilestats() {
- msggroup "$0"
+ msggroup 'testfilestats'
msgtest "Test that file $1 has $2 $3" "$4"
if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
msgpass
msggroup
}
testaccessrights() {
- msggroup "$0"
+ msggroup 'testaccessrights'
testfilestats "$1" '%a' '=' "$2"
msggroup
}
testwebserverlaststatuscode() {
- msggroup "$0"
+ msggroup 'testwebserverlaststatuscode'
local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log'
local STATUS='downloaded/webserverstatus-statusfile.log'
rm -f "$DOWNLOG" "$STATUS"