Commit 7bf07151 authored by Niels Möller's avatar Niels Möller
Browse files

* src/testsuite/functions.sh (at_exit): Fixed the at_exit

mechanism. The previous code always exited successfully.
(test_result): New variable for keeping the desired exit status.
(test_fail): New function.
(test_success): Likewise.
(compare_output): Likewise.

Rev: src/testsuite/functions.sh:1.5
parent 07bb4d95
......@@ -16,14 +16,27 @@ fi
set -e
PORT=11147
ATEXIT="res=$? ; set +e"
ATEXIT='set +e'
trap 'eval "$ATEXIT ; exit \$res"' 0
# Starting with EXIT_FAILURE and changing it to EXIT_SUCCESS on
# success is right, as long as each test script only performs one
# test. If there are several tests, it would be better to set it to
# EXIT_SUCCESS and change it as soon as one test fails.
test_result=1
test_fail () {
test_result=1
}
test_success () {
test_result=0
}
trap 'eval "$ATEXIT ; exit \$test_result"' 0
at_exit () {
res=$?
ATEXIT="$ATEXIT ; $1"
return $res
}
spawn_lshd () {
......@@ -73,3 +86,13 @@ at_connect () {
mini-inetd -m $2 localhost:$1 -- /bin/sh sh -c "$3" &
at_exit "kill $!"
}
compare_output() {
if cmp test.out1 test.out2; then
echo "$1: Ok, files match."
test_success
else
echo "$1: Error, files are different."
test_fail
fi
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment