#!/bin/bash
#  $HeadURL: http://dione.no-ip.org/svn/ade/tags/1.7.6/lib/tests/bin/ADESTDTEST102_option_version.sh $ $LastChangedRevision: 3171 $
set -e
PROGNAME=`basename $0`
SANDPIT=`pwd`
. $(ade-config ade_include_prefix)/adetestsupport.sh

##############################################################################
#
#  LOAD TEST-SPECIFIC CONFIGURATION FILE
#
##############################################################################

[ "X$ADETEST_MODROOT" != X ] || error "'ADETEST_MODROOT' not defined"
[ -r "$ADETEST_MODROOT/tests/in/$PROGNAME" ] || error "can't read $ADETEST_MODROOT/tests/in/$PROGNAME"
. "$ADETEST_MODROOT/tests/in/$PROGNAME" || error "problem sourcing $ADETEST_MODROOT/tests/in/$PROGNAME"
[ "X$PROGRAMS" != X ] || error "'PROGRAMS' not defined"

##############################################################################
#
#  START OF TESTS
#
##############################################################################

echo "checking exit codes with '-V' ..."
for PROGRAM in $PROGRAMS; do
    debug 4 "running '$PROGRAM -V' and checking return code ..."
    $PROGRAM -V > /dev/null
done

echo "checking exit codes with '--version' ..."
for PROGRAM in $PROGRAMS; do
    debug 4 "running '$PROGRAM --version' and checking return code ..."
    $PROGRAM --version > /dev/null
done

echo "checking reply format with '-V' ..."
for PROGRAM in $PROGRAMS; do
    debug 4 "running '$PROGRAM -V' and checking reply format ..."
    $PROGRAM -V | sed \
	-e "/^$PROGRAM version [^ 	][^ 	]*\$/d" \
	-e "/^$PROGRAM version development\\.revision\\.[0-9][0-9]*\$/d" \
	-e "/^$PROGRAM version development\\.branch\\.[0-9][0-9]*\\.[0-9][0-9]*\$/d"
done

echo "checking reply format with '--version' ..."
for PROGRAM in $PROGRAMS; do
    debug 4 "running '$PROGRAM --version' and checking reply format ..."
    $PROGRAM --version | sed \
	-e "/^$PROGRAM version [^ 	][^ 	]*\$/d" \
	-e "/^$PROGRAM version development\\.revision\\.[0-9][0-9]*\$/d" \
	-e "/^$PROGRAM version development\\.branch\\.[0-9][0-9]*\\.[0-9][0-9]*\$/d"
done
