#!/bin/sh
#!c:/appls/cygwin/bin/sh

#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
# 
# The contents of this file are subject to the Mozilla Public License Version 
# 1.1 (the "License"); you may not use this file except in compliance with 
# the License. You may obtain a copy of the License at 
# http://www.mozilla.org/MPL/
# 
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
# 
# The Original Code is mozilla.org code.
# 
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1996-2003
# the Initial Developer. All Rights Reserved.
# 
# Contributor(s):
#	Mark Smith <MarkCSmithWork@aol.com>
# 
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
# 
# ***** END LICENSE BLOCK ***** 

#UNAME=c:/appls/relbld-tools/gmake3.76.1/uname.exe
UNAME=uname
#
# Perform a sanity check on the LDAP C SDK by executing the command line tools
#
# cd to the directory that contains platform subdirectories before executing
# this script, e.g.,
#    cd /shared-builds/ldapsdk50/20011120D
#    ~/tests/sdk/accept/test-sdk
#

usage()
{
	echo "usage: $0 [-v] [-c] [-s] [-3] [-C] [-b basedn] [-d debuglevel] [-h server] [-p ldap-port] [-P ldaps-port] [-W ssl-keyfile-passwd] [-L extra-lib-path ]" 2>&1
	exit 2
}

# By default, SSL tests are done.  -s turns them off.
TEST_SSL=yes

# component dependencies
NSS_RELEASE=nss/NSS_3_7_7_RTM
NSS_RELEASE_ROOT=/shared-builds
NSPR_RELEASE=nspr20/v4.2.2
NSPR_RELEASE_ROOT=/shared-builds

# hard coded variables
BINDDN="cn=Directory Manager"
BINDPW="secret"
CERTDB=/tmp/certdb
CERTNAME="Kirsten Vaughan's Example ID"
TOOLS_OUTFILE=/dev/null
TOOLS_TMPFILE=/tmp/testsdk-tools-tmp.$$

# defaults
LDAPHOST=ldap.example.com
LDAPPORT=389
LDAPSPORT=636
LDAPBASE="dc=example,dc=com"
KEYPASSWD=
VERBOSE=0
REALLY_VERBOSE=0
LDAPDEBUG=""
STOP_ON_ERRORS=1
COPY_ROOT_CERT_LIB=0
EXTRA_LIB_PATH=""
EXTRA_SSL_ARGS=""

#set - - `getopt vb:d:h:p:P: $*`
#if [ $? != 0 ]; then
#	usage;
#fi
#for i in $*; do
#echo $i
#	case $i in
#		-v)		VERBOSE=1;;
#		-b)		LDAPBASE=$2; shift 2;;
#		-d)		LDAPDEBUG=$2; shift 2;;
#		-h)		LDAPHOST=$2; shift 2;;
#		-p)		LDAPPORT=$2; shift 2;;
#		-P)		LDAPSPORT=$2; shift 2;;
#	esac
#done

while getopts vcCs3b:d:h:L:p:P:W: c; do
	case $c in
		v)	if [ $VERBOSE -eq 1 ]; then
				REALLY_VERBOSE=1;
			else
				VERBOSE=1
			fi
		;;
		c)	STOP_ON_ERRORS=0;;
		C)	COPY_ROOT_CERT_LIB=1;;
		s)	TEST_SSL="no";;
		3)	EXTRA_SSL_ARGS="$EXTRA_SSL_ARGS -3";;
		b)	LDAPBASE=$OPTARG;;
		d)	LDAPDEBUG=$OPTARG;;
		h)	LDAPHOST=$OPTARG;;
		L)	EXTRA_LIB_PATH=$OPTARG;;
		p)	LDAPPORT=$OPTARG;;
		P)	LDAPSPORT=$OPTARG;;
		W)	KEYPASSWD=$OPTARG;;

		\?)	usage;;
	esac
done
shift `expr $OPTIND - 1`

if [ -z "$KEYPASSWD" -a z$TEST_SSL = z"yes" ]; then
	echo "Please provide the keyfile password (-W password)"
	usage;
fi

if [ $# -gt 0 ]; then
	usage;
fi

if [ $REALLY_VERBOSE -ne 0 ]; then
	TOOLS_OUTFILE=/dev/tty
fi

DEV_NULL=/dev/null
BUILD_VARIANTS="DBG.OBJ OPT.OBJ"

ICONV_SRC_CHARSET=ISO8859-1
ICONV_UTF8_CHARSET=UTF-8
OS=`$UNAME`
case $OS in
	SunOS)
		if [ `$UNAME -r` = "5.6" ]; then
			ICONV_SRC_CHARSET=8859-1
		fi
		OS_VARIANTS="SunOS5.6 SunOS5.8 SunOS5.8_64"
		LDAPTOOL_LC_CTYPE=en_US.ISO8859-1
		;;
	HP-UX)
		OS_VARIANTS="HP-UXB.11.00 HP-UXB.11.00_64"
		LDAPTOOL_LC_CTYPE=en_US.iso88591
		ICONV_SRC_CHARSET=iso8859_1
		ICONV_UTF8_CHARSET=utf8
		;;
	AIX)
		OS_VARIANTS="AIX4.3"
		LDAPTOOL_LC_CTYPE=en_US.ISO8859-1
		;;
	Linux)
		OS_VARIANTS="Linux2.2_x86_glibc_PTH Linux2.4_x86_glibc_PTH"
		LDAPTOOL_LC_CTYPE=en_US.ISO8859-1
		ICONV_SRC_CHARSET=ISO-8859-1
		;;
	WINNT)
		OS_VARIANTS="WINNT5.0"
		BUILD_VARIANTS="$BUILD_VARIANTS DBG.OBJD"
		CERTDB=c:/Dev/test/ldapcsdk/client-kvaughan-db-10-2003
		DEV_NULL="nul:"
		;;
	*)
		echo "unknown operating system $OS" 2>&1
		exit 1
esac

# set up locale environment (charset)
if [ $OS != WINNT ]; then
	LC_ALL=$LDAPTOOL_LC_CTYPE; export LC_ALL
	if [ $VERBOSE -ne 0 ]; then
		echo "$0: LC_ALL=$LDAPTOOL_LC_CTYPE"
		locale
	fi
fi

if [ "$OS" = "WINNT" ]; then
	CMD_TO_UTF8=cat
else
	CMD_TO_UTF8="iconv -f $ICONV_SRC_CHARSET -t $ICONV_UTF8_CHARSET"
fi


TEST_SSL_CLIENT_AUTH=yes
TEST_SEARCHES=yes
TEST_MODIFIES=yes
# moddn, etc.
TEST_MODDNNEWSUP=no

if [ ! -z "$LDAPDEBUG" ]; then
	DEBUG_ARG="-d $LDAPDEBUG"
fi

if [ $VERBOSE -ne 0 ]; then
	VERBOSE_ARG="-v"
fi

SEP="++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"


# OS, OBJDIR, NSS_RELEASE, and NSPR_RELEASE must be set
setup_shlib_access()
{
	NSS_LIB_PATH="$NSS_RELEASE_ROOT/$NSS_RELEASE/$OBJDIR/lib"
	NSPR_LIB_PATH="$NSPR_RELEASE_ROOT/$NSPR_RELEASE/$OBJDIR/lib"
	if [ -z "$EXTRA_LIB_PATH" ]; then
		SHARED_LIB_PATH=$NSS_LIB_PATH:$NSPR_LIB_PATH
	else
		SHARED_LIB_PATH=$NSS_LIB_PATH:$NSPR_LIB_PATH:$EXTRA_LIB_PATH
	fi

	case $OS in
		SunOS|IRIX)
			LD_LIBRARY_PATH=$SHARED_LIB_PATH;
			export LD_LIBRARY_PATH;
			ROOT_CERT_SO=libnssckbi.so
			;;
		HP-UX)
			SHLIB_PATH=$SHARED_LIB_PATH;
			export SHLIB_PATH;
			ROOT_CERT_SO=libnssckbi.sl
			;;
		AIX)
			LIBPATH=$SHARED_LIB_PATH;
			export LIBPATH;
			ROOT_CERT_SO=libnssckbi.so
			;;
		Linux)
			LD_LIBRARY_PATH=$SHARED_LIB_PATH;
			export LD_LIBRARY_PATH;
			ROOT_CERT_SO=libnssckbi.so
			;;
		WINNT)
			PATH="`pwd`/$OBJDIR/lib;:$PATH;"
			export PATH;
			ROOT_CERT_SO=nssckbi.dll
			;;
		*)
			echo "setup_shlib_access: unknown operating system $OS" 2>&1
			exit 1
	esac

	if [ z$TEST_SSL = z"yes" ]; then
# Copy root cert shared library to cert DB location
		ROOT_CERT_SO_DST_PATH=$CERTDB/$ROOT_CERT_SO
		if [ "$COPY_ROOT_CERT_LIB" -ne 0 ]; then
			echo setup_shlib_access: cp -p $NSS_LIB_PATH/$ROOT_CERT_SO $ROOT_CERT_SO_DST_PATH
			cp -p $NSS_LIB_PATH/$ROOT_CERT_SO $ROOT_CERT_SO_DST_PATH
		fi
	fi
}


# ROOT_CERT_SO_DST_PATH must be set
cleanup_shlib_access()
{
	if [ "$COPY_ROOT_CERT_LIB" -ne 0 ]; then
		echo cleanup_shlib_access: rm $ROOT_CERT_SO_DST_PATH
		rm $ROOT_CERT_SO_DST_PATH
	fi
}


# OBJDIR and OS must be set
test_one()
{
	TEST_ONE_RC=0

    if [ "$OS" = "WINNT" ]; then
#		echo "cd $OBJDIR/lib"
#		cd $OBJDIR/lib
#		LDAPTOOLSDIR=../tools
		LDAPTOOLSDIR=$OBJDIR/tools
	else
		echo "cd $OBJDIR/tools"
		cd $OBJDIR/tools
		LDAPTOOLSDIR=.
	fi

	if [ z$TEST_SEARCHES = z"yes" ]; then
	# test searches

	echo search1 $SEP
	$LDAPTOOLSDIR/ldapsearch $VERBOSE_ARG $DEBUG_ARG \
		-h $LDAPHOST -p $LDAPPORT \
		-b "$LDAPBASE" 'objectClass=*' > $TOOLS_OUTFILE < $DEV_NULL
	TOOLS_RC=$?
	if [ $TOOLS_RC -ne 0 ]; then
		echo "** FAILURE search1 ($TOOLS_RC)";
		if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
		TEST_ONE_RC=$TOOLS_RC;
	fi

	if [ z$TEST_SSL = z"yes" ]; then
		echo sslsearch1 $SEP
		$LDAPTOOLSDIR/ldapsearch $VERBOSE_ARG $DEBUG_ARG \
			-h $LDAPHOST -p $LDAPSPORT \
			-b "$LDAPBASE" $EXTRA_SSL_ARGS -Z -P $CERTDB \
			'objectClass=*' > $TOOLS_OUTFILE < $DEV_NULL
		TOOLS_RC=$?
		if [ $TOOLS_RC -ne 0 ]; then
			echo "** FAILURE sslsearch1 ($TOOLS_RC)";
			if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
			TEST_ONE_RC=$TOOLS_RC;
		fi

		if [ z$TEST_SSL_CLIENT_AUTH = z"yes" ]; then
			echo sslsearch2-clientauth $SEP
			$LDAPTOOLSDIR/ldapsearch $VERBOSE_ARG $DEBUG_ARG \
				-h $LDAPHOST -p $LDAPSPORT \
				-b "" -s base $EXTRA_SSL_ARGS -Z -P $CERTDB -N "$CERTNAME" \
				-W "$KEYPASSWD" 'objectClass=*' > $TOOLS_OUTFILE < $DEV_NULL
			TOOLS_RC=$?
			if [ $TOOLS_RC -ne 0 ]; then
				echo "** FAILURE sslsearch2 ($TOOLS_RC)";
				if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
				TEST_ONE_RC=$TOOLS_RC;
			fi
		fi
		# end of SSL client auth search tests

	fi
	# end of SSL search tests

fi
# end of search tests

if [ z$TEST_MODIFIES = z"yes" ]; then
	# modify

	echo modify1 $SEP
	$LDAPTOOLSDIR/ldapmodify $VERBOSE_ARG $DEBUG_ARG -a \
		-h $LDAPHOST -p $LDAPPORT \
		-D "$BINDDN" -w "$BINDPW" <<MOD1 > $TOOLS_OUTFILE
dn: cn=Test Entry, $LDAPBASE
cn: Test Entry
sn: Entry
objectClass: person
MOD1
	TOOLS_RC=$?
	if [ $TOOLS_RC -ne 0 ]; then
		echo "** FAILURE modify1 ($TOOLS_RC)";
		if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
		TEST_ONE_RC=$TOOLS_RC;
	fi

	echo modverifysearch1 $SEP
	$LDAPTOOLSDIR/ldapsearch $VERBOSE_ARG $DEBUG_ARG \
		-h $LDAPHOST -p $LDAPPORT \
		-b "$LDAPBASE" 'sn=Entry' > $TOOLS_OUTFILE < $DEV_NULL
	TOOLS_RC=$?
	if [ $TOOLS_RC -ne 0 ]; then
		echo "** FAILURE modverifysearch1 ($TOOLS_RC)";
		if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
		TEST_ONE_RC=$TOOLS_RC;
	fi

	# I18n modify and search
	echo i18nmodify1 $SEP
	LAST_ENTRY_DN_88591="cn= with accent Entry,$LDAPBASE"
	LAST_ENTRY_DN_UTF8="cn=\C3\A1 with accent Entry,$LDAPBASE"

if [ $OS != WINNT ]; then
	$CMD_TO_UTF8 <<I18NMOD1 > $TOOLS_TMPFILE
dn: $LAST_ENTRY_DN_88591
cn:  with accent Entry
sn: A Entry
objectClass: person
I18NMOD1
else
	cat <<I18NMOD1b > $TOOLS_TMPFILE
dn: $LAST_ENTRY_DN_UTF8
sn: A Entry
objectClass: person
I18NMOD1b
fi
	TOOLS_RC=$?
	if [ $TOOLS_RC -ne 0 ]; then
		rm $TOOLS_TMPFILE
		echo "** FAILURE $CMD_TO_UTF8 ($TOOLS_RC)";
		if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
		TEST_ONE_RC=$TOOLS_RC;
	fi

	$LDAPTOOLSDIR/ldapmodify $VERBOSE_ARG $DEBUG_ARG -a \
		-h $LDAPHOST -p $LDAPPORT \
		-D "$BINDDN" -w "$BINDPW" < $TOOLS_TMPFILE > $TOOLS_OUTFILE
	TOOLS_RC=$?
	rm $TOOLS_TMPFILE
	if [ $TOOLS_RC -ne 0 ]; then
		echo "** FAILURE i18nmodify1 ($TOOLS_RC)";
		if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
		TEST_ONE_RC=$TOOLS_RC;
	fi

	echo i18nmodverifysearch1 $SEP
	$LDAPTOOLSDIR/ldapsearch $VERBOSE_ARG $DEBUG_ARG \
		-h $LDAPHOST -p $LDAPPORT -s base \
		-b "$LAST_ENTRY_DN_88591" 'objectClass=*' > $TOOLS_OUTFILE < $DEV_NULL
	TOOLS_RC=$?
	if [ $TOOLS_RC -ne 0 ]; then
		echo "** FAILURE i18nmodverifysearch1 ($TOOLS_RC)";
		if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
		TEST_ONE_RC=$TOOLS_RC;
	fi

	echo i18ndelete1 $SEP
	$LDAPTOOLSDIR/ldapdelete $VERBOSE_ARG $DEBUG_ARG \
		-h $LDAPHOST -p $LDAPPORT \
		-D "$BINDDN" -w "$BINDPW" \
		-i $ICONV_UTF8_CHARSET "$LAST_ENTRY_DN_UTF8" > $TOOLS_OUTFILE
	TOOLS_RC=$?
	if [ $TOOLS_RC -ne 0 ]; then
		echo "** FAILURE i18ndelete1 ($TOOLS_RC)";
		if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
		TEST_ONE_RC=$TOOLS_RC;
	fi

	# modrdn
	echo modrdn1 $SEP
	$LDAPTOOLSDIR/ldapmodify $VERBOSE_ARG $DEBUG_ARG \
		-h $LDAPHOST -p $LDAPPORT \
		-D "$BINDDN" -w "$BINDPW" <<MOD2 > $TOOLS_OUTFILE
dn: cn=Test Entry, $LDAPBASE
changetype: modrdn
newrdn: cn=Testy Entry
deleteoldrdn: 0
MOD2
	TOOLS_RC=$?
	if [ $TOOLS_RC -ne 0 ]; then
		echo "** FAILURE modrdn1 ($TOOLS_RC)";
		if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
			TEST_ONE_RC=$TOOLS_RC;
	fi

	LAST_ENTRY_DN="cn=Testy Entry, $LDAPBASE"

	echo modverifysearch2 $SEP
	$LDAPTOOLSDIR/ldapsearch $VERBOSE_ARG $DEBUG_ARG \
		-h $LDAPHOST -p $LDAPPORT \
		-b "$LDAPBASE" 'sn=Entry' > $TOOLS_OUTFILE < $DEV_NULL
	TOOLS_RC=$?
	if [ $TOOLS_RC -ne 0 ]; then
		echo "** FAILURE modverifysearch2 ($TOOLS_RC)";
		if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
		TEST_ONE_RC=$TOOLS_RC;
	fi

	if [ z$TEST_MODDNNEWSUP = z"yes" ]; then
		# moddn with new superior
		echo moddn1 $SEP
		$LDAPTOOLSDIR/ldapmodify -V 3 $VERBOSE_ARG $DEBUG_ARG \
			-h $LDAPHOST -p $LDAPPORT \
			-D "$BINDDN" -w "$BINDPW" <<MOD3 > $TOOLS_OUTFILE
dn: cn=Test Entry, $LDAPBASE
changetype: moddn
newrdn: cn=Testier Entry
deleteoldrdn: 0
newparent: ou=People, $LDAPBASE
MOD3
		TOOLS_RC=$?
		if [ $TOOLS_RC -ne 0 ]; then
			echo "** FAILURE moddn1 ($TOOLS_RC)";
			if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
			TEST_ONE_RC=$TOOLS_RC;
		fi

		LAST_ENTRY_DN="cn=Testier Entry, ou=People, $LDAPBASE"

		echo modverifysearch3 $SEP
		$LDAPTOOLSDIR/ldapsearch $VERBOSE_ARG $DEBUG_ARG \
			-h $LDAPHOST -p $LDAPPORT \
			-b "$LDAPBASE" 'sn=Entry' > $TOOLS_OUTFILE < $DEV_NULL
		TOOLS_RC=$?
		if [ $TOOLS_RC -ne 0 ]; then
			echo "** FAILURE modverifysearch3 ($TOOLS_RC)";
			if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
			TEST_ONE_RC=$TOOLS_RC;
		fi

	# end of moddn with new superior tests
	fi

	if [ z$TEST_SSL = z"yes" ]; then
		echo delete1 $SEP
		$LDAPTOOLSDIR/ldapdelete $VERBOSE_ARG $DEBUG_ARG \
			-h $LDAPHOST -p $LDAPSPORT \
			-D "$BINDDN" -w "$BINDPW" $EXTRA_SSL_ARGS -Z -P $CERTDB \
			 "$LAST_ENTRY_DN" > $TOOLS_OUTFILE
			TOOLS_RC=$?
			if [ $TOOLS_RC -ne 0 ]; then
				echo "** FAILURE ssldelete1 ($TOOLS_RC)";
				if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
				TEST_ONE_RC=$TOOLS_RC;
			fi

	else
		echo delete 1 $SEP
		$LDAPTOOLSDIR/ldapdelete $VERBOSE_ARG $DEBUG_ARG \
			-h $LDAPHOST -p $LDAPPORT \
			-D "$BINDDN" -w "$BINDPW" \
			"$LAST_ENTRY_DN" > $TOOLS_OUTFILE
		TOOLS_RC=$?
		if [ $TOOLS_RC -ne 0 ]; then
			echo "** FAILURE delete1 ($TOOLS_RC)";
			if [ $STOP_ON_ERRORS -ne 0 ]; then return $TOOLS_RC; fi
			TEST_ONE_RC=$TOOLS_RC;
		fi
	fi
	# end of SSL or non-SSL delete test

fi
# end of modify tests

return $TEST_ONE_RC;
}

echo $0 started
echo server:	$LDAPHOST:$LDAPPORT
echo ssl:		$TEST_SSL		"(port $LDAPSPORT)"
echo clientath:	$TEST_SSL_CLIENT_AUTH
echo moddn:		$TEST_MODDNNEWSUP
echo search:	$TEST_SEARCHES
echo modify:	$TEST_MODIFIES
echo nss:		$NSS_RELEASE
echo nspr:		$NSPR_RELEASE

RC=0
TESTED_STR=""
TESTED_COUNT=0
TESTED_FAIL_COUNT=0
TESTED_SKIP_COUNT=0
HOMEBASE_DIR=`pwd`;
for os in $OS_VARIANTS; do
	for build in $BUILD_VARIANTS; do
		OBJDIR="${os}_${build}"
		echo ""
		if [ ! -d "$OBJDIR" ]; then
			echo "Skipping $OBJDIR (no such directory)..."
			TESTED_SKIP_COUNT=`expr $TESTED_SKIP_COUNT + 1`;
			continue;
		fi
		echo Testing $OBJDIR...
		setup_shlib_access;
		test_one;
		ONE_RC=$?
		cleanup_shlib_access;
		TESTED_COUNT=`expr $TESTED_COUNT + 1`;
		TESTED_STR="$TESTED_STR $OBJDIR";
		if [ $ONE_RC -ne 0 ]; then
			echo "** FAILURE $OBJDIR";
			TESTED_FAIL_COUNT=`expr $TESTED_FAIL_COUNT + 1`;
			if [ $STOP_ON_ERRORS -ne 0 ]; then
				exit $ONE_RC;
			else
				RC=$ONE_RC;
			fi
		fi
		cd $HOMEBASE_DIR
	done
done

echo ""
if [ "$TESTED_SKIP_COUNT" -gt 0 ]; then
	SKIP_STR=" (skipped $TESTED_SKIP_COUNT tests)";
else
	SKIP_STR="";
fi
if [ -z "$TESTED_STR" ]; then
	echo "No tests executed$SKIP_STR."
	RC=2;
else
	echo "Tested $TESTED_STR."
	if [ "$ONE_RC" -eq 0 ]; then
		echo "All $TESTED_COUNT tests completed OK$SKIP_STR."
	else
		echo "$TESTED_FAIL_COUNT tests of $TESTED_COUNT failed $SKIP_STR."
	fi
fi

echo $0 done.
exit $RC
