#!/bin/bash # $HeadURL$ $LastChangedRevision$ PROGNAME=${0##*/} SANDPIT=$(pwd) . $(ade-config ade_share_prefix)/include/adetestsupport.sh ############################################################################## # # LOAD TEST-SPECIFIC CONFIGURATION FILE # ############################################################################## [ "X$ADETEST_MODROOT" != X ] || adetestsupport_error "'ADETEST_MODROOT' not defined" [ -r "$ADETEST_MODROOT/tests/in/$PROGNAME" ] || adetestsupport_error "can't read $ADETEST_MODROOT/tests/in/$PROGNAME" . "$ADETEST_MODROOT/tests/in/$PROGNAME" || adetestsupport_error "problem sourcing $ADETEST_MODROOT/tests/in/$PROGNAME" [ "X$PROGRAMS" != X ] || adetestsupport_error "'PROGRAMS' not defined" ############################################################################## # # START OF TESTS # ############################################################################## echo "checking -h and --help return text that looks like usage message ..." for PROGRAM in $PROGRAMS; do for OPTION in -h --help; do adetestsupport_debug 4 "running '$PROGRAM $OPTION' and checking it looks like a usage message ..." if { ! [[ $($PROGRAM $OPTION < /dev/null 2>&1) =~ ^Usage:[\ \ ]+[a-z][-a-z0-9]*\ .*$ ]]; }; then echo "'$PROGRAM $OPTION' failed; its ouput was [$PROGRAM_OPTION_OUTPUT]" fi done done echo "checking -h and --help exit codes and output stream with ..." for PROGRAM in $PROGRAMS; do for OPTION in -h --help; do adetestsupport_debug 4 "running '$PROGRAM $OPTION' and checking return code ..." $PROGRAM $OPTION > /dev/null < /dev/null done done echo "checking -h and --help reply format ..." for PROGRAM in $PROGRAMS; do adetestsupport_debug 4 "checking $PROGRAM ..." for OPTION in -h --help; do adetestsupport_debug 4 "running '$PROGRAM $OPTION' and checking reply format ..." OUTPUT="$($PROGRAM $OPTION < /dev/null 2>&1)" || true # rpm used to have help string exactly 80 chars long, so "sed -rn 's/.{80,80}//p'" # succeeded but stripped all but the newline, so a blank line was produced, making # it slightly difficult to track which line in the usage message was at fault. Now # we look for lines that are 80 long, but output the last character. echo "$OUTPUT" | sed -rn 's/.{79,79}(.)/\1/p' done done # leave this in to facilitate easier detection of silent non-non-zero # exits from above loop. echo "end of tests"