Quellcode durchsuchen

test: show the highlevel test for lowerranking ones

testsuccess checks the return code, but it does also some autotests
based on the command like grepping for dpkg warnings in a apt-get
install call – but if this finds something it is just showing the grep
command. With this change it will additionally show the first msgtest
which in this case will detail the actual apt-get install call.

Git-Dch: Ignore
David Kalnischkies vor 11 Jahren
Ursprung
Commit
9beb11aae4
1 geänderte Dateien mit 68 neuen und 1 gelöschten Zeilen
  1. 68 1
      test/integration/framework

+ 68 - 1
test/integration/framework

@@ -74,6 +74,9 @@ msgskip() {
 }
 }
 msgfail() {
 msgfail() {
 	if [ -n "$MSGTEST_MSG" ]; then
 	if [ -n "$MSGTEST_MSG" ]; then
+		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"
 		echo -n "$MSGTEST_MSG"
 		unset MSGTEST_MSG
 		unset MSGTEST_MSG
 	fi
 	fi
@@ -84,6 +87,20 @@ msgfail() {
 	fi
 	fi
 	EXIT_CODE=$((EXIT_CODE+1));
 	EXIT_CODE=$((EXIT_CODE+1));
 }
 }
+MSGGROUP_LEVEL=0
+msggroup() {
+	if [ -n "$1" ]; then
+		if [ $MSGGROUP_LEVEL = 0 ]; then
+			MSGTEST_GRP='NEXT'
+		fi
+		MSGGROUP_LEVEL=$((MSGGROUP_LEVEL+1));
+	else
+		MSGGROUP_LEVEL=$((MSGGROUP_LEVEL-1));
+		if [ $MSGGROUP_LEVEL = 0 ]; then
+			unset MSGTEST_GRP
+		fi
+	fi
+}
 
 
 # enable / disable Debugging
 # enable / disable Debugging
 if [ $MSGLEVEL -le 0 ]; then
 if [ $MSGLEVEL -le 0 ]; then
@@ -96,7 +113,12 @@ fi
 if [ $MSGLEVEL -le 2 ]; then
 if [ $MSGLEVEL -le 2 ]; then
 	msgmsg() { true; }
 	msgmsg() { true; }
 	msgnmsg() { true; }
 	msgnmsg() { true; }
-	msgtest() { MSGTEST_MSG="$(msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@")"; }
+	msgtest() {
+		MSGTEST_MSG="$(msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@")"
+		if [ "$MSGTEST_GRP" = 'NEXT' ]; then
+			MSGTEST_GRP="$MSGTEST_MSG"
+		fi
+	}
 	msgpass() { printf " ${CPASS}P${CNORMAL}"; }
 	msgpass() { printf " ${CPASS}P${CNORMAL}"; }
 fi
 fi
 if [ $MSGLEVEL -le 3 ]; then
 if [ $MSGLEVEL -le 3 ]; then
@@ -1217,6 +1239,7 @@ checkdiff() {
 }
 }
 
 
 testfileequal() {
 testfileequal() {
+	msggroup "$0"
 	local MSG='Test for correctness of file'
 	local MSG='Test for correctness of file'
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		MSG=''
 		MSG=''
@@ -1241,9 +1264,11 @@ testfileequal() {
 			msgfailoutput '' "$OUTPUT"
 			msgfailoutput '' "$OUTPUT"
 		fi
 		fi
 	fi
 	fi
+	msggroup
 }
 }
 
 
 testempty() {
 testempty() {
+	msggroup "$0"
 	msgtest "Test for no output of" "$*"
 	msgtest "Test for no output of" "$*"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
 	if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
 	if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
@@ -1252,9 +1277,11 @@ testempty() {
 		msgfailoutput '' "$COMPAREFILE"
 		msgfailoutput '' "$COMPAREFILE"
 	fi
 	fi
 	aptautotest 'testempty' "$@"
 	aptautotest 'testempty' "$@"
+	msggroup
 }
 }
 
 
 testequal() {
 testequal() {
+	msggroup "$0"
 	local MSG='Test of equality of'
 	local MSG='Test of equality of'
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		MSG=''
 		MSG=''
@@ -1275,9 +1302,11 @@ testequal() {
 		msgfailoutput '' "$OUTPUT"
 		msgfailoutput '' "$OUTPUT"
 	fi
 	fi
 	aptautotest 'testequal' "$@"
 	aptautotest 'testequal' "$@"
+	msggroup
 }
 }
 
 
 testequalor2() {
 testequalor2() {
+	msggroup "$0"
 	local COMPAREFILE1="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
 	local COMPAREFILE1="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
 	local COMPAREFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
 	local COMPAREFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
 	local COMPAREAGAINST="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
 	local COMPAREAGAINST="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
@@ -1299,9 +1328,11 @@ testequalor2() {
 		msgfailoutput '' "$OUTPUT"
 		msgfailoutput '' "$OUTPUT"
 	fi
 	fi
 	aptautotest 'testequalor2' "$@"
 	aptautotest 'testequalor2' "$@"
+	msggroup
 }
 }
 
 
 testshowvirtual() {
 testshowvirtual() {
+	msggroup "$0"
 	local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual"
 	local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual"
 	local PACKAGE="$1"
 	local PACKAGE="$1"
 	shift
 	shift
@@ -1323,9 +1354,11 @@ N: No packages found"
 	else
 	else
 		msgfailoutput '' "$OUTPUT"
 		msgfailoutput '' "$OUTPUT"
 	fi
 	fi
+	msggroup
 }
 }
 
 
 testnopackage() {
 testnopackage() {
+	msggroup "$0"
 	msgtest "Test for non-existent packages" "apt-cache show $*"
 	msgtest "Test for non-existent packages" "apt-cache show $*"
 	local SHOWPKG="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
 	local SHOWPKG="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
 	if [ -n "$SHOWPKG" ]; then
 	if [ -n "$SHOWPKG" ]; then
@@ -1335,9 +1368,11 @@ testnopackage() {
 	else
 	else
 		msgpass
 		msgpass
 	fi
 	fi
+	msggroup
 }
 }
 
 
 testdpkgstatus() {
 testdpkgstatus() {
+	msggroup "$0"
 	local STATE="$1"
 	local STATE="$1"
 	local NR="$2"
 	local NR="$2"
 	shift 2
 	shift 2
@@ -1351,17 +1386,23 @@ testdpkgstatus() {
 	else
 	else
 		msgpass
 		msgpass
 	fi
 	fi
+	msggroup
 }
 }
 
 
 testdpkginstalled() {
 testdpkginstalled() {
+	msggroup "$0"
 	testdpkgstatus 'ii' "$#" "$@"
 	testdpkgstatus 'ii' "$#" "$@"
+	msggroup
 }
 }
 
 
 testdpkgnotinstalled() {
 testdpkgnotinstalled() {
+	msggroup "$0"
 	testdpkgstatus 'ii' '0' "$@"
 	testdpkgstatus 'ii' '0' "$@"
+	msggroup
 }
 }
 
 
 testmarkedauto() {
 testmarkedauto() {
+	msggroup "$0"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
 	if [ -n "$1" ]; then
 	if [ -n "$1" ]; then
 		msgtest 'Test for correctly marked as auto-installed' "$*"
 		msgtest 'Test for correctly marked as auto-installed' "$*"
@@ -1376,8 +1417,10 @@ testmarkedauto() {
 	else
 	else
 		msgfailoutput '' "$OUTPUT"
 		msgfailoutput '' "$OUTPUT"
 	fi
 	fi
+	msggroup
 }
 }
 testmarkedmanual() {
 testmarkedmanual() {
+	msggroup "$0"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedmanual.comparefile"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedmanual.comparefile"
 	if [ -n "$1" ]; then
 	if [ -n "$1" ]; then
 		msgtest 'Test for correctly marked as manually installed' "$*"
 		msgtest 'Test for correctly marked as manually installed' "$*"
@@ -1392,11 +1435,15 @@ testmarkedmanual() {
 	else
 	else
 		msgfailoutput '' "$OUTPUT"
 		msgfailoutput '' "$OUTPUT"
 	fi
 	fi
+	msggroup
 }
 }
 
 
 msgfailoutput() {
 msgfailoutput() {
 	if [ -n "$MSGTEST_MSG" ]; then
 	if [ -n "$MSGTEST_MSG" ]; then
 		echo
 		echo
+		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"
 		echo -n "$MSGTEST_MSG"
 		unset MSGTEST_MSG
 		unset MSGTEST_MSG
 	fi
 	fi
@@ -1431,6 +1478,7 @@ msgfailoutput() {
 }
 }
 
 
 testsuccess() {
 testsuccess() {
+	msggroup "$0"
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		shift
 		shift
 	else
 	else
@@ -1463,8 +1511,10 @@ testsuccess() {
 		msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@"
 		msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@"
 	fi
 	fi
 	aptautotest 'testsuccess' "$@"
 	aptautotest 'testsuccess' "$@"
+	msggroup
 }
 }
 testwarning() {
 testwarning() {
+	msggroup "$0"
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		shift
 		shift
 	else
 	else
@@ -1490,8 +1540,10 @@ testwarning() {
 		msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@"
 		msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@"
 	fi
 	fi
 	aptautotest 'testwarning' "$@"
 	aptautotest 'testwarning' "$@"
+	msggroup
 }
 }
 testfailure() {
 testfailure() {
+	msggroup "$0"
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		shift
 		shift
 	else
 	else
@@ -1527,28 +1579,36 @@ testfailure() {
 		fi
 		fi
 	fi
 	fi
 	aptautotest 'testfailure' "$@"
 	aptautotest 'testfailure' "$@"
+	msggroup
 }
 }
 
 
 testsuccessequal() {
 testsuccessequal() {
+	msggroup "$0"
 	local CMP="$1"
 	local CMP="$1"
 	shift
 	shift
 	testsuccess "$@"
 	testsuccess "$@"
 	testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" "$CMP"
 	testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" "$CMP"
+	msggroup
 }
 }
 testwarningequal() {
 testwarningequal() {
+	msggroup "$0"
 	local CMP="$1"
 	local CMP="$1"
 	shift
 	shift
 	testwarning "$@"
 	testwarning "$@"
 	testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" "$CMP"
 	testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" "$CMP"
+	msggroup
 }
 }
 testfailureequal() {
 testfailureequal() {
+	msggroup "$0"
 	local CMP="$1"
 	local CMP="$1"
 	shift
 	shift
 	testfailure "$@"
 	testfailure "$@"
 	testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" "$CMP"
 	testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" "$CMP"
+	msggroup
 }
 }
 
 
 testfailuremsg() {
 testfailuremsg() {
+	msggroup "$0"
 	local CMP="$1"
 	local CMP="$1"
 	shift
 	shift
 	testfailure "$@"
 	testfailure "$@"
@@ -1563,9 +1623,11 @@ testfailuremsg() {
 		cat "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" >"$OUTPUT"
 		cat "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" >"$OUTPUT"
 		msgfailoutput '' "$OUTPUT"
 		msgfailoutput '' "$OUTPUT"
 	fi
 	fi
+	msggroup
 }
 }
 
 
 testfilestats() {
 testfilestats() {
+	msggroup "$0"
 	msgtest "Test that file $1 has $2 $3" "$4"
 	msgtest "Test that file $1 has $2 $3" "$4"
 	if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
 	if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
 		msgpass
 		msgpass
@@ -1578,12 +1640,16 @@ testfilestats() {
 		} >"$OUTPUT" 2>&1
 		} >"$OUTPUT" 2>&1
 		msgfailoutput '' "$OUTPUT"
 		msgfailoutput '' "$OUTPUT"
 	fi
 	fi
+	msggroup
 }
 }
 testaccessrights() {
 testaccessrights() {
+	msggroup "$0"
 	testfilestats "$1" '%a' '=' "$2"
 	testfilestats "$1" '%a' '=' "$2"
+	msggroup
 }
 }
 
 
 testwebserverlaststatuscode() {
 testwebserverlaststatuscode() {
+	msggroup "$0"
 	local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log'
 	local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log'
 	local STATUS='downloaded/webserverstatus-statusfile.log'
 	local STATUS='downloaded/webserverstatus-statusfile.log'
 	rm -f "$DOWNLOG" "$STATUS"
 	rm -f "$DOWNLOG" "$STATUS"
@@ -1603,6 +1669,7 @@ testwebserverlaststatuscode() {
 		} >"$OUTPUT" 2>&1
 		} >"$OUTPUT" 2>&1
 		msgfailoutput "Status was $(cat "$STATUS")" "$OUTPUT"
 		msgfailoutput "Status was $(cat "$STATUS")" "$OUTPUT"
 	fi
 	fi
+	msggroup
 }
 }
 
 
 pause() {
 pause() {