function ping_host()
{
if [ -z $1 ]; then
- print_newline
- print_error "No host to ping"
+ set_error "No host to ping"
return $TEST_ERROR
fi
PING_HOST=$1
fi
# XXX: maybe use bash's command type?
which $1 > /dev/null 2>&1
- if [ $? -eq 0 ]; then
- local ret=`which $1`
- if [ -x "$ret" ]; then
- return $TEST_OK
- else
- return $TEST_ERROR
- fi
- else
- return $TEST_ERROR
- fi
+ if [ $? -eq 0 ]; then
+ local ret=`which $1`
+ if [ -x "$ret" ]; then
+ return $TEST_OK
+ else
+ return $TEST_ERROR
+ fi
+ else
+ return $TEST_ERROR
+ fi
# if [ $? -eq 0 ] && [ -x "$ret" ]; then
# return $TEST_OK
do
check_exec $file
if [ $? -gt 0 ]; then
- print_error "file $file not found"
+ update_error "file $file not found"
return $TEST_ERROR
fi
done
function check_socket()
{
if [ $# -lt 2 ]; then
- print_newline
- print_error "No host:port to check"
+ set_error "No host:port to check"
return $TEST_ERROR
fi
- $TEST_SOCKET $1 $2
+ $TEST_SOCKET $1 $2 2> $testerrfile
if [ $? -eq 0 ]; then
return $TEST_OK
else
TEST_ERROR=1
TEST_OK=0
+# test error file
+testerrfile=$$.err
+
function set_test()
{
test_done="${spacefill}${begin_green}done${end_green}"
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}"; }
-function test_end() { syslog "${test_end}"; }
+function test_start() { syslog "${test_start}"; reset_error }
+function test_end() { syslog "${test_end}"; reset_error }
# set output to ASCII (without colors)
function setOutputASCII()
set_test
}
+function reset_error()
+{
+ rm $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}" "$*"
+ printf "${begin_red}Error${end_red}: %s ${lf}" "`cat $testerrfile`"
+ reset_error
}
function print_warning()