diff --git a/CHANGES b/CHANGES index 1bdbaadd00..3efc4d3941 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4745. [test] Add color-coded pass/fail messages to system + tests when running on terminals that support them. + [RT #45977] + 4744. [bug] Suppress trust-anchor-telementry queries if validation is disabled. [RT #46131] diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index b0cff4f30c..1c53bb1da3 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -136,6 +136,43 @@ ZLIB=@ZLIB@ . ${TOP}/version +# +# Set up color-coded test output +# +if test -t 1 && type tput > /dev/null; then + COLOR_FAIL=`tput setaf 1` # red + COLOR_WARN=`tput setaf 3` # yellow + COLOR_PASS=`tput setaf 2` # green + COLOR_INFO=`tput bold` # bold + COLOR_NONE=`tput sgr0` +else + # set to empty strings so printf succeeds + COLOR_FAIL='' + COLOR_WARN='' + COLOR_PASS='' + COLOR_INFO='' + COLOR_NONE='' +fi + +echofail () { + printf "${COLOR_FAIL}%s${COLOR_NONE}\n" "$*" +} + +echowarn () { + printf "${COLOR_WARN}%s${COLOR_NONE}\n" "$*" +} + +echopass () { + printf "${COLOR_PASS}%s${COLOR_NONE}\n" "$*" +} + +echoinfo () { + printf "${COLOR_INFO}%s${COLOR_NONE}\n" "$*" +} + +# +# Export command paths +# export ARPANAME export BIGKEY export CHECKZONE diff --git a/bin/tests/system/run.sh b/bin/tests/system/run.sh index bcf613a6d2..fe915a1a05 100644 --- a/bin/tests/system/run.sh +++ b/bin/tests/system/run.sh @@ -37,22 +37,22 @@ shift test -d $test || { echo "$0: $test: no such test" >&2; exit 1; } -echo "S:$test:`date`" >&2 -echo "T:$test:1:A" >&2 -echo "A:System test $test" >&2 +echoinfo "S:$test:`date`" >&2 +echoinfo "T:$test:1:A" >&2 +echoinfo "A:System test $test" >&2 if [ x${PERL:+set} = x ] then - echo "I:Perl not available. Skipping test." >&2 - echo "R:UNTESTED" >&2 - echo "E:$test:`date`" >&2 + echowarn "I:Perl not available. Skipping test." >&2 + echowarn "R:UNTESTED" >&2 + echoinfo "E:$test:`date`" >&2 exit 0; fi $PERL testsock.pl || { - echo "I:Network interface aliases not set up. Skipping test." >&2; - echo "R:UNTESTED" >&2; - echo "E:$test:`date`" >&2; + echowarn "I:Network interface aliases not set up. Skipping test." >&2; + echowarn "R:UNTESTED" >&2; + echoinfo "E:$test:`date`" >&2; exit 0; } @@ -64,9 +64,9 @@ result=$? if [ $result -eq 0 ]; then : prereqs ok else - echo "I:Prerequisites for $test missing, skipping test." >&2 - [ $result -eq 255 ] && echo "R:SKIPPED" || echo "R:UNTESTED" - echo "E:$test:`date`" >&2 + echowarn "I:Prerequisites for $test missing, skipping test." >&2 + [ $result -eq 255 ] && echowarn "R:SKIPPED" || echowarn "R:UNTESTED" + echoinfo "E:$test:`date`" >&2 exit 0 fi @@ -76,9 +76,9 @@ if then : pkcs11 ok else - echo "I:Need PKCS#11 for $test, skipping test." >&2 - echo "R:PKCS11ONLY" >&2 - echo "E:$test:`date`" >&2 + echowarn "I:Need PKCS#11 for $test, skipping test." >&2 + echowarn "R:PKCS11ONLY" >&2 + echoinfo "E:$test:`date`" >&2 exit 0 fi @@ -89,7 +89,7 @@ then fi # Start name servers running -$PERL start.pl $test || { echo "R:FAIL"; echo "E:$test:`date`"; exit 1; } +$PERL start.pl $test || { echofail "R:FAIL"; echoinfo "E:$test:`date`"; exit 1; } # Run the tests ( cd $test ; $SHELL tests.sh ) @@ -109,11 +109,11 @@ $PERL stop.pl $test status=`expr $status + $?` if [ $status != 0 ]; then - echo "R:FAIL" + echofail "R:FAIL" # Don't clean up - we need the evidence. find . -name core -exec chmod 0644 '{}' \; else - echo "R:PASS" + echopass "R:PASS" if $clean then @@ -130,6 +130,6 @@ else fi fi -echo "E:$test:`date`" +echoinfo "E:$test:`date`" exit $status