--- /dev/null
+#!/bin/bash
+#
+# Copyright (c) Members of the EGEE Collaboration. 2004-2010.
+# See http://www.eu-egee.org/partners for details on the copyright holders.
+#
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# show help and usage
+progname=`basename $0`
+showHelp()
+{
+cat << EndHelpHeader
+This script is intended for running a fully automated deployment and functionality test of MyProxy configurations and proxy renewal
+
+Prerequisities:
+New empty machine, certificates
+
+Tests called:
+ Deployment
+ The full PX Functional Test Suite
+
+EndHelpHeader
+
+ echo "Usage: $progname [OPTIONS] hostname"
+ echo "Options:"
+ echo " -h | --help Show this help message."
+}
+
+STARTTIME=`date +%s`
+
+# read common definitions and functions
+for COMMON in px-common.sh test-common.sh px-common-testbeds.sh
+do
+ if [ ! -r ${COMMON} ]; then
+ printf "Downloading common definitions '${COMMON}'"
+ wget -O ${COMMON} http://jra1mw.cvs.cern.ch/cgi-bin/jra1mw.cgi/org.glite.testsuites.ctb/PX/tests/$COMMON?view=co > /dev/null
+ if [ ! -r ${COMMON} ]; then
+ exit 2
+ else
+ test_done
+ fi
+ fi
+done
+source px-common.sh
+source px-common-testbeds.sh
+#also read L&B common definitions for common functions.
+if [ ! -r lb-common-testbeds.sh ]; then
+ printf "Downloading common definitions 'lb-common-testbeds.sh'"
+ wget -O lb-common-testbeds.sh http://jra1mw.cvs.cern.ch/cgi-bin/jra1mw.cgi/org.glite.testsuites.ctb/LB/tests/lb-common-testbeds.sh?view=co > /dev/null
+ if [ ! -r lb-common-testbeds.sh ]; then
+ exit 2
+ else
+ test_done
+ fi
+fi
+source lb-common-testbeds.sh
+
+
+printf "Getting the 'install' script... "
+#XXX Provisional. The test won't be generated here in the future. Just downloaded or otherwise obtained
+SCENARIO="Clean installation"
+cat << EndInstallScript > PXinstall.sh
+rpm -Uvhi http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
+yum install -y yum-priorities yum-protectbase
+rpm -i http://emisoft.web.cern.ch/emisoft/dist/EMI/1/sl5/x86_64/base/emi-release-1.0.0-1.sl5.noarch.rpm
+
+#cd /etc/yum.repos.d
+#wget http://etics-repository.cern.ch/repository/pm/registered/repomd/id/f850dc7c-4774-4b6f-98cf-5bb7eb205d18/sl5_x86_64_gcc412EPEL/etics-registered-build-by-id-protect.repo
+#echo priority=45 >> etics-registered-build-by-id-protect.repo
+
+yum install -y emi-px glite-px-proxyrenewal
+
+cd ~/
+mkdir -m 700 yaim
+cd yaim
+
+cat << EOF > site-info.def
+SITE_NAME=krakonosovo
+PX_HOST=\`hostname -f\`
+GRID_AUTHORIZED_RETRIEVERS="\*"
+GRID_AUTHORIZED_RENEWERS="\`openssl x509 -in /etc/grid-security/hostcert.pem -noout -subject |sed -e 's/subject= //'\`"
+EOF
+
+sed -i 's/155/255/g' /opt/glite/yaim/examples/edgusers.conf
+sed -i 's/156/256/g' /opt/glite/yaim/examples/edgusers.conf
+
+/opt/glite/yaim/bin/yaim -c -s ./site-info.def -n glite-PX
+
+mkdir ~glite/.certs
+cp /etc/grid-security/host* ~glite/.certs/
+chown -R glite ~glite/.certs/
+
+export GLITE_USER=glite
+export GLITE_HOST_KEY=/home/glite/.certs/hostkey.pem
+export GLITE_HOST_CERT=/home/glite/.certs/hostcert.pem
+
+/etc/init.d/glite-proxy-renewald start
+EndInstallScript
+test_done
+
+
+printf "Generating the 'arrange' script... "
+gen_arrange_script_px `hostname -f` 0
+test_done
+
+
+printf "Installing... "
+sh PXinstall.sh > Install_log.txt 2> Install_err.log
+test_done
+
+printf "Running tests... "
+sh arrange_px_test_root.sh none glite 80 '-x' > test_log.txt 2> test_err.log
+test_done
+
+ENDTIME=`date +%s`
+
+#Generating report section
+gen_deployment_header $ENDTIME $STARTTIME "$SCENARIO" > report.twiki
+
+cat PXinstall.sh >> report.twiki
+printf "</verbatim>
+
+---++++ Full Output of the Installation
+
+<verbatim>\n" >> report.twiki
+cat Install_log.txt >> report.twiki
+
+printf "</verbatim>
+
+---+++ Tests
+
+| !TestPlan | https://twiki.cern.ch/twiki/bin/view/EGEE/GridSiteTestPlan |
+| Tests | http://jra1mw.cvs.cern.ch/cgi-bin/jra1mw.cgi/org.glite.testsuites.ctb/gridsite/tests/ |
+
+<verbatim>\n" >> report.twiki
+cat test_log.txt >> report.twiki
+
+
--- /dev/null
+#!/bin/bash
+#
+# Copyright (c) Members of the EGEE Collaboration. 2004-2010.
+# See http://www.eu-egee.org/partners for details on the copyright holders.
+#
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+function gen_arrange_script_px()
+{
+remotehost=$1
+COPYPROXY=$2
+
+cat << EndArrangeScript > arrange_px_test_root.sh
+CERTFILE=\$1
+GLITE_USER=\$2
+PXTSTCOLS=\$3
+OUTPUT_OPT=\$4
+
+echo "Certificate file: \$CERTFILE "
+echo "gLite user: \$GLITE_USER "
+echo "Terminal width: \$PXTSTCOLS "
+echo "Output format: \$OUTPUT_OPT "
+
+export PXTSTCOLS
+
+yum install -q -y globus-proxy-utils
+yum install -q -y voms-clients
+yum install -q -y curl
+yum install -q -y wget
+yum install -q -y sudo
+
+cd /tmp
+
+CVSPATH=\`which cvs\`
+
+if [ "\$CVSPATH" = "" ]; then
+ printf "CVS binary not present"
+ egrep -i "Debian|Ubuntu" /etc/issue
+
+ if [ \$? = 0 ]; then
+ apt-get install --yes cvs
+ else
+ yum install -y cvs
+ fi
+
+fi
+
+glite_id=\`id -u \$GLITE_USER\`
+
+echo \$GLITE_USER user ID is \$glite_id
+
+if [ $COPYPROXY -eq 1 ]; then
+ mv \$CERTFILE x509up_u\$glite_id
+ chown \$GLITE_USER:\$GLITE_USER x509up_u\${glite_id}
+else
+ rm -rf /tmp/test-certs/grid-security
+ cvs -d :pserver:anonymous@glite.cvs.cern.ch:/cvs/jra1mw co org.glite.testsuites.ctb/LB > /dev/null 2>/dev/null
+ FAKE_CAS=\`./org.glite.testsuites.ctb/LB/tests/lb-generate-fake-proxy.sh | grep -E "^X509_CERT_DIR" | sed 's/X509_CERT_DIR=//'\`
+ if [ "\$FAKE_CAS" == "" ]; then
+ echo "Failed generating proxy" >&2
+ exit 2
+ else
+ cp -rv \$FAKE_CAS/* /etc/grid-security/certificates/
+ fi
+fi
+
+echo cd > arrange_px_test_user.sh
+echo export PXTSTCOLS=\$PXTSTCOLS >> arrange_px_test_user.sh
+echo 'export GLITE_MYSQL_ROOT_PASSWORD="[Edited]"' >> arrange_px_test_user.sh
+echo mkdir PX_testing >> arrange_px_test_user.sh
+echo cd PX_testing >> arrange_px_test_user.sh
+echo cvs -d :pserver:anonymous@glite.cvs.cern.ch:/cvs/jra1mw co org.glite.testsuites.ctb/PX >> arrange_px_test_user.sh
+echo ls >> arrange_px_test_user.sh
+echo cd org.glite.testsuites.ctb/PX/tests >> arrange_px_test_user.sh
+echo ulimit -c unlimited >> arrange_px_test_user.sh
+echo 'export HNAME=\`hostname -f\`' >> arrange_px_test_user.sh
+echo 'env | egrep "GLITE|\$HNAME|PATH"' >> arrange_px_test_user.sh
+echo pwd >> arrange_px_test_user.sh
+echo id >> arrange_px_test_user.sh
+if [ "\$OUTPUT_OPT" == "-i" ]; then
+echo echo ======================== >> arrange_px_test_user.sh
+echo echo " THE CONSOLE IS YOURS" >> arrange_px_test_user.sh
+echo echo ======================== >> arrange_px_test_user.sh
+echo '/bin/bash -i' >> arrange_px_test_user.sh
+else
+echo echo ======================== >> arrange_px_test_user.sh
+echo echo " REAL TESTS START HERE" >> arrange_px_test_user.sh
+echo echo ======================== >> arrange_px_test_user.sh
+echo 'echo "</verbatim>"' >> arrange_px_test_user.sh
+echo 'echo "<literal>"' >> arrange_px_test_user.sh
+echo sh ./px-test-all.sh \$OUTPUT_OPT >> arrange_px_test_user.sh
+echo 'echo "</literal>"' >> arrange_px_test_user.sh
+echo 'echo "<verbatim>"' >> arrange_px_test_user.sh
+echo echo ================== >> arrange_px_test_user.sh
+echo echo " TESTS END HERE" >> arrange_px_test_user.sh
+echo echo ================== >> arrange_px_test_user.sh
+fi
+#echo "" >> arrange_px_test_user.sh
+
+chown \$GLITE_USER:\$GLITE_USER arrange_px_test_user.sh
+chmod +x arrange_px_test_user.sh
+
+#su -l \$GLITE_USER
+su -l \$GLITE_USER --command=/tmp/arrange_px_test_user.sh
+echo "</verbatim>"
+
+EndArrangeScript
+}
+
--- /dev/null
+# $Header$
+#
+# Copyright (c) Members of the EGEE Collaboration. 2004-2010.
+# See http://www.eu-egee.org/partners for details on the copyright holders.
+#
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ------------------------------------------------------------------------------
+# Definitions of functions and variables common to LB test scripts
+#
+# ping_host() - basic network ping
+# check_binaries() - check for binary executables, calls check_exec()
+# check_socket() - TCPecho to host:port
+#
+# ------------------------------------------------------------------------------
+
+# read common definitions and functions
+TEST_COMMON=test-common.sh
+if [ ! -r ${TEST_COMMON} ]; then
+ printf "Common definitions '${TEST_COMMON}' not found!\n"
+ exit 2
+fi
+source ${TEST_COMMON}
+
+
+# define variables
+GLITE_LOCATION=${GLITE_LOCATION:-/opt/glite}
+SAME_SENSOR_HOME=${SAME_SENSOR_HOME:-.}
+PATH=$GLITE_LOCATION/bin:$GLITE_LOCATION/examples:$PATH
+export PATH
+
+GRIDPROXYINFO=grid-proxy-info
+
+# binaries
+SYS_LSOF=lsof
+SYS_GREP=grep
+SYS_SED=sed
+SYS_PS=ps
+SYS_PIDOF=pidof
+if test -f /usr/sbin/apache2; then
+ SYS_APACHE=apache2
+else
+ SYS_APACHE=httpd
+fi
+if test -f /usr/sbin/apache2ctl; then
+ SYS_APACHECTL=apache2ctl
+else
+ SYS_APACHECTL=apachectl
+fi
+SYS_PING=ping
+SYS_AWK=awk
+SYS_ECHO=echo
+SYS_DOMAINNAME=domainname
+SYS_CURL=curl
+SYS_RM="rm -f"
+SYS_CHMOD=chmod
+SYS_CAT=cat
+SYS_NL=nl
+SYS_TAIL=tail
+SYS_DATE=date
+SYS_EXPR=expr
+SYS_BC=bc
+SYS_SCP=scp
+SYS_NC=nc
+SYS_CURL=curl
+VOMSPROXYINFO=voms-proxy-info
+
+# not used at the moment
+DEBUG=2
+
+# ping host
+function ping_host()
+{
+ if [ -z $1 ]; then
+ set_error "No host to ping"
+ return $TEST_ERROR
+ fi
+ PING_HOST=$1
+ # XXX: there might be a better way to test the network reachability
+ result=`${SYS_PING} -c 3 $PING_HOST 2>/dev/null | ${SYS_GREP} " 0% packet loss"| wc -l`
+ if [ $result -gt 0 ]; then
+ return $TEST_OK
+ else
+ return $TEST_ERROR
+ fi
+}
+
+
+# check the binaries
+function check_exec()
+{
+ if [ -z $1 ]; then
+ set_error "No binary to check"
+ return $TEST_ERROR
+ fi
+ # XXX: maybe use bash's command type?
+ local ret=`which $1 2> /dev/null`
+ if [ -n "$ret" -a -x "$ret" ]; then
+ return $TEST_OK
+ else
+ return $TEST_ERROR
+ fi
+}
+
+function check_binaries()
+{
+# TODO: test only the binaries that are needed - it can differ in each test
+ local ret=$TEST_OK
+ for file in $@
+ do
+ check_exec $file
+ if [ $? -gt 0 ]; then
+ update_error "file $file not found"
+ ret=$TEST_ERROR
+ fi
+ done
+ return $ret
+}
+
+# check socket
+function check_socket()
+{
+ if [ $# -lt 2 ]; then
+ set_error "No host:port to check"
+ return $TEST_ERROR
+ fi
+ $SYS_NC -z $1 $2 > $testerrfile
+ if [ $? -eq 0 ]; then
+ return $TEST_OK
+ else
+ return $TEST_ERROR
+ fi
+}
+
+# Check listener
+# Arguments:
+# $1: program expected to listen on the given port
+# $2: TCP port to check
+function check_listener()
+{
+ req_program=$1
+ req_port=$2
+ if [ -z $1 ]; then
+ set_error "No program name entered"
+ return $TEST_ERROR
+ fi
+
+ pid=`lsof -F p -i TCP:$req_port | sed "s/^p//" | head -n 1`
+ if [ -z "$pid" ]; then
+ return $TEST_ERROR
+ fi
+ program=`ps -p ${pid} -o args= | grep -E "[\/]*$req_program[ \t]*"`
+ if [ -z "$program" ]; then
+ return $TEST_ERROR
+ else
+ return $TEST_OK
+ fi
+}
+
+# make HTTP request using curl
+# Arguments: Options to be passed to curl, at least the URL
+# return http_code containing resulting code
+
+function call_curl()
+{
+ http_code=`curl --cert ${X509_USER_PROXY} --key ${X509_USER_PROXY} \
+ --capath ${X509_CERT_DIR} \
+ --output /dev/null --silent --write-out '%{http_code}\n' \
+ "$@"`
+}
--- /dev/null
+#!/bin/bash
+#
+# Copyright (c) Members of the EGEE Collaboration. 2004-2010.
+# See http://www.eu-egee.org/partners for details on the copyright holders.
+#
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# show help and usage
+progname=`basename $0`
+showHelp()
+{
+cat << EndHelpHeader
+Script for testing PX and proxyrenewal functions
+
+Prerequisities:
+ - PX configured, proxy-renewal installed
+
+Returned values:
+ Exit TEST_OK: Test Passed
+ Exit TEST_ERROR: Test Failed
+ Exit 2: Wrong Input
+
+EndHelpHeader
+
+ echo "Usage: $progname [OPTIONS]"
+ echo "Options:"
+ echo " -h | --help Show this help message."
+ echo " -o | --output 'file' Redirect all output to the 'file' (stdout by default)."
+ echo " -t | --text Format output as plain ASCII text."
+ echo " -c | --color Format output as text with ANSI colours (autodetected by default)."
+ echo " -x | --html Format output as html."
+}
+
+# read common definitions and functions
+COMMON=px-common.sh
+if [ ! -r ${COMMON} ]; then
+ printf "Common definitions '${COMMON}' missing!"
+ exit 2
+fi
+source ${COMMON}
+
+logfile=$$.tmp
+flag=0
+while test -n "$1"
+do
+ case "$1" in
+ "-h" | "--help") showHelp && exit 2 ;;
+ "-o" | "--output") shift ; logfile=$1 flag=1 ;;
+ "-t" | "--text") setOutputASCII ;;
+ "-c" | "--color") setOutputColor ;;
+ "-x" | "--html") setOutputHTML ;;
+ esac
+ shift
+done
+
+# redirecting all output to $logfile
+#touch $logfile
+#if [ ! -w $logfile ]; then
+# echo "Cannot write to output file $logfile"
+# exit $TEST_ERROR
+#fi
+
+DEBUG=2
+
+##
+# Starting the test
+#####################
+
+{
+test_start
+
+
+# check_binaries
+printf "Testing if all binaries are available"
+check_binaries curl rm chown openssl htcp htls htmv htcp htrm htls htls htproxydestroy
+if [ $? -gt 0 ]; then
+ test_failed
+ exit 2
+else
+ test_done
+fi
+
+JOBID=https://fake.job.id/xxx
+
+ORIG_PROXY=`voms-proxy-info | grep -E "^path" | sed 's/^path\s*:\s*//'`
+REGISTERED_PROXY=`glite-proxy-renew -s localhost -f $ORIG_PROXY -j $JOBID start`
+printf "\tProxy:\t$ORIG_PROXY\n\tRenew:\t$REGISTERED_PROXY\n";
+printf "Registered proxy -- ";
+voms-proxy-info -file $REGISTERED_PROXY | grep timeleft;
+printf "sleeping...";
+sleep 600;
+printf "\nRegistered proxy -- ";
+voms-proxy-info -file $REGISTERED_PROXY | grep timeleft;
+printf "Original proxy -- ";
+voms-proxy-info -file $ORIG_PROXY | grep timeleft;
+printf "\nRegistered proxy -- ";
+voms-proxy-info -file $REGISTERED_PROXY -fqan -actimeleft;
+printf "Original proxy -- ";
+voms-proxy-info -file $ORIG_PROXY -fqan -actimeleft;
+printf "\nRegistered proxy -- ";
+voms-proxy-info -file $REGISTERED_PROXY -identity;
+printf "Original proxy -- ";
+voms-proxy-info -file $ORIG_PROXY -identity;
+glite-proxy-renew -j $JOBID stop;
+ls $REGISTERED_PROXY 2>&1 | grep 'No such file or directory' > /dev/null && echo OK
+
+
+test_end
+}
+#} &> $logfile
+
+#if [ $flag -ne 1 ]; then
+# cat $logfile
+# $SYS_RM $logfile
+#fi
+exit $TEST_OK
+
--- /dev/null
+# $Header$
+#
+# Copyright (c) Members of the EGEE Collaboration. 2004-2010.
+# See http://www.eu-egee.org/partners for details on the copyright holders.
+#
+# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ------------------------------------------------------------------------------
+# Definition of test script return messages
+#
+# The test scripts should use the variables test_done and test_failed to
+# report whether they failed or succeeded.
+#
+# The variable test_reset is used to turn off all attributes and switch
+# to the standard character set.
+#
+# \033 ascii ESCape
+# \033[<NUM>G move to column <NUM> (linux console, xterm, not vt100)
+# \033[<NUM>C move <NUM> columns forward but only upto last column
+# \033[<NUM>D move <NUM> columns backward but only upto first column
+# \033[<NUM>A move <NUM> rows up
+# \033[<NUM>B move <NUM> rows down
+# \033[1m switch on bold
+# \033[31m switch on red
+# \033[32m switch on green
+# \033[33m switch on yellow
+# \033[m switch off color/bold
+# \017 exit alternate mode (xterm, vt100, linux console)
+# \033[10m exit alternate mode (linux console)
+# \015 carriage return (without newline)
+#
+# See also United Linux or OpenSUSE /etc/rc.status script
+#
+# ------------------------------------------------------------------------------
+
+# Do _not_ be fooled by non POSIX locale
+LC_ALL=POSIX
+export LC_ALL
+
+# Seek for terminal size and, if needed, set default size
+if [ -z "${LINES}" -o -z "${COLUMNS}" ]; then
+ stty_size=`stty size 2> /dev/null`
+ if [ $? = 0 ]; then
+ LINES=`echo ${stty_size} | awk '{print $1}'`
+ COLUMNS=`echo ${stty_size} | awk '{print $2}'`
+ else
+ LINES=24
+ if [ $LBTSTCOLS -gt 0 ]; then
+ COLUMNS=$LBTSTCOLS
+ else
+ COLUMNS=80
+ fi
+ fi
+fi
+if [ ! $LINES -ge 0 ]; then LINES=24; fi
+if [ ! $COLUMNS -ge 0 ]; then COLUMNS=80; fi
+export LINES COLUMNS
+
+# default return values
+TEST_ERROR=1
+TEST_OK=0
+
+# test error file
+testerrfile=$$.err
+
+function set_test()
+{
+test_done="${spacefill}${begin_green}done${end_green}"
+test_running="${spacefill}${begin_green}running${end_green}"
+test_failed="${spacefill}${begin_red}-TEST FAILED-${end_red}"
+test_missed="${spacefill}${begin_red}missing${end_red}"
+test_skipped="${spacefill}${begin_yellow}skipped${end_yellow}"
+test_dead="${spacefill}${begin_red}dead${end_red}"
+test_unused="${spacefill}${begin_bold}unused${end_bold}"
+test_unknown="${spacefill}${begin_yellow}unknown${end_yellow}"
+
+test_start="${spacefill}${begin_green}start${end_green}"
+test_end="${spacefill}${begin_green}end${end_green}"
+}
+
+function test_done() { printf "${test_done}${lf}"; }
+function test_running() { printf "${test_running}${lf}"; }
+function test_failed() { printf "${test_failed}${lf}"; }
+function test_missed() { printf "${test_missed}${lf}"; }
+function test_skipped() { printf "${test_skipped}${lf}"; }
+function test_dead() { printf "${test_dead}${lf}"; }
+function test_unused() { printf "${test_unused}${lf}"; }
+function test_unknown { printf "${test_unknown}${lf}"; }
+function test_start() {
+ syslog "${test_start}";
+ reset_error
+}
+function test_end() {
+ syslog "${test_end}";
+ reset_error
+}
+
+# set output to ASCII (without colors)
+function setOutputASCII()
+{
+lf="\n"
+spacefill="..."
+
+begin_bold=""
+begin_black=""
+begin_red=""
+begin_green=""
+begin_yellow=""
+begin_blue=""
+begin_magenta=""
+begin_cyan=""
+begin_white=""
+
+end_bold=""
+end_black=""
+end_red=""
+end_green=""
+end_yellow=""
+end_blue=""
+end_magenta=""
+end_cyan=""
+end_white=""
+
+set_test
+}
+
+# set output to ASCII with ANSI colors
+function setOutputColor()
+{
+local esc=`echo -en "\033"`
+local normal="${esc}[0m" # unsets color to term's fg color
+lf="\n"
+spacefill=`echo -en "\015${esc}[${COLUMNS}C${esc}[15D"`
+
+begin_bold="${esc}[0;1m"
+begin_black="${esc}[0;30m"
+begin_red="${esc}[0;31m"
+begin_green="${esc}[0;32m"
+begin_yellow="${esc}[0;33m"
+begin_blue="${esc}[0;34m"
+begin_magenta="${esc}[0;35m"
+begin_cyan="${esc}[0;36m"
+begin_white="${esc}[0;37m"
+
+end_bold="$normal"
+end_black="$normal"
+end_red="$normal"
+end_green="$normal"
+end_yellow="$normal"
+end_blue="$normal"
+end_magenta="$normal"
+end_cyan="$normal"
+end_white="$normal"
+
+set_test
+}
+
+# set output to HTML
+function setOutputHTML()
+{
+local ENDFONT="</font>"
+lf="<br />\n"
+spacefill=" "
+is_html=1
+
+begin_bold="<b>"
+begin_black="<font color=\"black\">"
+begin_red="<font color=\"red\">"
+begin_green="<font color=\"green\">"
+begin_yellow="<font color=\"yellow\">"
+begin_blue="<font color=\"blue\">"
+begin_magenta="<font color=\"magenta\">"
+begin_cyan="<font color=\"cyan\">"
+begin_white="<font color=\"white\">"
+
+end_bold="</b>"
+end_black="$ENDFONT"
+end_red="$ENDFONT"
+end_green="$ENDFONT"
+end_yellow="$ENDFONT"
+end_blue="$ENDFONT"
+end_magenta="$ENDFONT"
+end_cyan="$ENDFONT"
+end_white="$ENDFONT"
+
+set_test
+}
+
+function reset_error()
+{
+ rm -f $testerrfile
+}
+
+function set_error()
+{
+ printf "%s ${lf}" "$*" > $testerrfile
+}
+
+function update_error()
+{
+ printf "%s; " "$*" >> $testerrfile
+}
+
+function print_error()
+{
+ printf "${begin_red}Error${end_red}: %s ${lf}" "$*"
+
+ if [ -f $testerrfile ]; then
+ printf "${begin_red}Error${end_red}: %s ${lf}" "`cat $testerrfile`"
+ fi
+ reset_error
+}
+
+function print_warning()
+{
+ printf "${begin_magenta}Warning${end_magenta}: %s ${lf}" "$*"
+}
+
+function print_info()
+{
+ printf "${begin_blue}Info${end_blue}: %s ${lf}" "$*"
+}
+
+function print_newline()
+{
+ printf "${lf}"
+}
+
+function syslog()
+{
+ local tmp="`date +'%b %d %H:%M:%S'` `hostname` $progname"
+ printf "${begin_bold}${tmp}${end_bold}: %s ${lf}" "$*"
+}
+
+function dprintf()
+{
+ if [ $DEBUG -gt 0 ]; then
+ printf "%s${lf}" "$*"
+ fi
+}
+
+# by default set output to color if possible
+if test -t 1 -a "$TERM" != "raw" -a "$TERM" != "dumb" && stty size <&1 > /dev/null 2>&1 ; then
+ setOutputColor
+else
+ setOutputASCII
+fi
+