corrected several tests

This commit is contained in:
Gerhard Rieger 2008-01-28 22:57:36 +01:00
parent bb4d740d15
commit 6b16968f07
2 changed files with 34 additions and 19 deletions

View file

@ -7,6 +7,8 @@ new features:
corrections: corrections:
make uninstall did not uninstall procan make uninstall did not uninstall procan
fixed lots of weaknesses in test.sh
####################### V 1.6.0.0: ####################### V 1.6.0.0:
new features: new features:

51
test.sh
View file

@ -1434,15 +1434,13 @@ testecho () {
#$ECHO "testing $title (test $num)... \c" #$ECHO "testing $title (test $num)... \c"
$PRINTF "test $F_n %s... " $num "$title" $PRINTF "test $F_n %s... " $num "$title"
#echo "$da" |$cmd >"$tf" 2>"$te" #echo "$da" |$cmd >"$tf" 2>"$te"
#set -vx (echo "$da"; sleep $T) |($SOCAT $opts "$arg1" "$arg2" >"$tf" 2>"$te"; echo $? >"$td/test$N.rc") &
(echo "$da"; sleep $T) |$SOCAT $opts "$arg1" "$arg2" >"$tf" 2>"$te" &
export rc1=$! export rc1=$!
#sleep 5 && kill $rc1 2>/dev/null & #sleep 5 && kill $rc1 2>/dev/null &
# rc2=$! # rc2=$!
wait $rc1 wait $rc1
# kill $rc2 2>/dev/null # kill $rc2 2>/dev/null
#set +vx if [ "$(cat "$td/test$N.rc")" != 0 ]; then
if [ "$?" != 0 ]; then
$PRINTF "$FAILED: $SOCAT:\n" $PRINTF "$FAILED: $SOCAT:\n"
echo "$SOCAT $opts $arg1 $arg2" echo "$SOCAT $opts $arg1 $arg2"
cat "$te" cat "$te"
@ -1474,7 +1472,7 @@ testod () {
local te="$td/test$N.stderr" local te="$td/test$N.stderr"
local tdiff="$td/test$N.diff" local tdiff="$td/test$N.diff"
local dain="$(date)" local dain="$(date)"
local daout="$(echo "$dain" |od -c)" local daout="$(echo "$dain" |$OD_C)"
$PRINTF "test $F_n %s... " $num "$title" $PRINTF "test $F_n %s... " $num "$title"
(echo "$dain"; sleep $T) |$SOCAT $opts "$arg1" "$arg2" >"$tf" 2>"$te" (echo "$dain"; sleep $T) |$SOCAT $opts "$arg1" "$arg2" >"$tf" 2>"$te"
if [ "$?" != 0 ]; then if [ "$?" != 0 ]; then
@ -1816,7 +1814,7 @@ gentestcert () {
local name="$1" local name="$1"
if [ -f $name.key -a -f $name.crt -a -f $name.pem ]; then return; fi if [ -f $name.key -a -f $name.crt -a -f $name.pem ]; then return; fi
openssl genrsa $OPENSSL_RAND -out $name.key 768 >/dev/null 2>&1 openssl genrsa $OPENSSL_RAND -out $name.key 768 >/dev/null 2>&1
openssl req -new -config testcert.conf -key $name.key -x509 -out $name.crt >/dev/null 2>&1 openssl req -new -config testcert.conf -key $name.key -x509 -out $name.crt -days 3653 >/dev/null 2>&1
cat $name.key $name.crt >$name.pem cat $name.key $name.crt >$name.pem
} }
@ -1826,7 +1824,7 @@ gentestdsacert () {
if [ -f $name.key -a -f $name.crt -a -f $name.pem ]; then return; fi if [ -f $name.key -a -f $name.crt -a -f $name.pem ]; then return; fi
openssl dsaparam -out $name-dsa.pem 512 >/dev/null 2>&1 openssl dsaparam -out $name-dsa.pem 512 >/dev/null 2>&1
openssl dhparam -dsaparam -out $name-dh.pem 512 >/dev/null 2>&1 openssl dhparam -dsaparam -out $name-dh.pem 512 >/dev/null 2>&1
openssl req -newkey dsa:$name-dsa.pem -keyout $name.key -nodes -x509 -config testcert.conf -out $name.crt >/dev/null 2>&1 openssl req -newkey dsa:$name-dsa.pem -keyout $name.key -nodes -x509 -config testcert.conf -out $name.crt -days 3653 >/dev/null 2>&1
cat $name-dsa.pem $name-dh.pem $name.key $name.crt >$name.pem cat $name-dsa.pem $name-dh.pem $name.key $name.crt >$name.pem
} }
@ -1999,7 +1997,11 @@ esac
N=$((N+1)) N=$((N+1))
# test: send EOF to exec'ed sub process, let it finished its operation, and
# check if the sub process returns its data before terminating.
NAME=EXECSOCKETFLUSH NAME=EXECSOCKETFLUSH
# idea: have socat exec'ing od; send data and EOF, and check if the od'ed data
# arrives.
case "$TESTS" in case "$TESTS" in
*%functions%*|*%exec%*|*%$NAME%*) *%functions%*|*%exec%*|*%$NAME%*)
TEST="$NAME: call to od via exec with socketpair" TEST="$NAME: call to od via exec with socketpair"
@ -2288,13 +2290,15 @@ CMD1="$SOCAT $opts TCP4-LISTEN:$tsl,reuseaddr PIPE"
CMD2="$SOCAT $opts stdin!!stdout TCP4:$ts" CMD2="$SOCAT $opts stdin!!stdout TCP4:$ts"
printf "test $F_n $TEST... " $N printf "test $F_n $TEST... " $N
$CMD1 >"$tf" 2>"${te}1" & $CMD1 >"$tf" 2>"${te}1" &
pid1=$!
waittcp4port $tsl 1 waittcp4port $tsl 1
echo "$da" |$CMD2 >>"$tf" 2>>"${te}2" echo "$da" |$CMD2 >>"$tf" 2>>"${te}2"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
$PRINTF "$FAILED: $SOCAT:\n" $PRINTF "$FAILED: $SOCAT:\n"
echo "$CMD1 &" echo "$CMD1 &"
cat "${te}1"
echo "$CMD2" echo "$CMD2"
cat "$te" cat "${te}2"
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
elif ! echo "$da" |diff - "$tf" >"$tdiff"; then elif ! echo "$da" |diff - "$tf" >"$tdiff"; then
$PRINTF "$FAILED\n" $PRINTF "$FAILED\n"
@ -2304,7 +2308,9 @@ else
$PRINTF "$OK\n" $PRINTF "$OK\n"
if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi
numOK=$((numOK+1)) numOK=$((numOK+1))
fi ;; fi
kill $pid1 2>/dev/null
wait ;;
esac esac
PORT=$((PORT+1)) PORT=$((PORT+1))
N=$((N+1)) N=$((N+1))
@ -5115,7 +5121,7 @@ NAME=UNIEXECEOF
case "$TESTS" in case "$TESTS" in
*%functions%*|*%$NAME%*) *%functions%*|*%$NAME%*)
TEST="$NAME: give exec'd write-only process a chance to flush (-u)" TEST="$NAME: give exec'd write-only process a chance to flush (-u)"
testod "$N" "$TEST" "" exec:'od -c' "$opts -u" testod "$N" "$TEST" "" exec:"$OD_C" "$opts -u"
esac esac
N=$((N+1)) N=$((N+1))
@ -5124,7 +5130,7 @@ NAME=REVEXECEOF
case "$TESTS" in case "$TESTS" in
*%functions%*|*%$NAME%*) *%functions%*|*%$NAME%*)
TEST="$NAME: give exec'd write-only process a chance to flush (-U)" TEST="$NAME: give exec'd write-only process a chance to flush (-U)"
testod "$N" "$TEST" exec:'od -c' "-" "$opts -U" testod "$N" "$TEST" exec:"$OD_C" "-" "$opts -U"
esac esac
N=$((N+1)) N=$((N+1))
@ -5864,7 +5870,10 @@ NAME=RAWIP6RECVFROM
case "$TESTS" in case "$TESTS" in
*%functions%*|*%ip%*|*%ip6%*|*%rawip%*|*%rawip6%*|*%dgram%*|*%root%*|*%$NAME%*) *%functions%*|*%ip%*|*%ip6%*|*%rawip%*|*%rawip6%*|*%dgram%*|*%root%*|*%$NAME%*)
TEST="$NAME: raw IPv6 datagram by self addressing" TEST="$NAME: raw IPv6 datagram by self addressing"
if [ $(id -u) -ne 0 -a "$withroot" -eq 0 ]; then if ! feat=$(testaddrs ip6 rawip) || ! runsip6 >/dev/null; then
$PRINTF "test $F_n $TEST... ${YELLOW}$feat not available${NORMAL}\n" $N
numCANT=$((numCANT+1))
elif [ $(id -u) -ne 0 -a "$withroot" -eq 0 ]; then
$PRINTF "test $F_n $TEST... ${YELLOW}must be root${NORMAL}\n" $N $PRINTF "test $F_n $TEST... ${YELLOW}must be root${NORMAL}\n" $N
numCANT=$((numCANT+1)) numCANT=$((numCANT+1))
else else
@ -6092,7 +6101,7 @@ NAME=RAWIP6RECV
case "$TESTS" in case "$TESTS" in
*%functions%*|*%ip6%*|*%dgram%*|*%rawip%*|*%rawip6%*|*%recv%*|*%root%*|*%$NAME%*) *%functions%*|*%ip6%*|*%dgram%*|*%rawip%*|*%rawip6%*|*%recv%*|*%root%*|*%$NAME%*)
TEST="$NAME: raw IPv6 receive" TEST="$NAME: raw IPv6 receive"
if ! feat=$(testaddrs ip6 rawip) || ! runsip4 >/dev/null; then if ! feat=$(testaddrs ip6 rawip) || ! runsip6 >/dev/null; then
$PRINTF "test $F_n $TEST... ${YELLOW}$feat not available${NORMAL}\n" $N $PRINTF "test $F_n $TEST... ${YELLOW}$feat not available${NORMAL}\n" $N
numCANT=$((numCANT+1)) numCANT=$((numCANT+1))
elif [ $(id -u) -ne 0 -a "$withroot" -eq 0 ]; then elif [ $(id -u) -ne 0 -a "$withroot" -eq 0 ]; then
@ -6806,7 +6815,7 @@ if ! testoptions cool-write >/dev/null; then
numCANT=$((numCANT+1)) numCANT=$((numCANT+1))
else else
#set -vx #set -vx
ti="$td/test$N.file" ti="$td/test$N.pipe"
tf="$td/test$N.stdout" tf="$td/test$N.stdout"
te="$td/test$N.stderr" te="$td/test$N.stderr"
tdiff="$td/test$N.diff" tdiff="$td/test$N.diff"
@ -6910,12 +6919,12 @@ if [ $? -ne 0 ]; then
echo "$CMD1 &" echo "$CMD1 &"
echo "$CMD2" echo "$CMD2"
cat "${te}1a" "${te}1b" "${te}2" cat "${te}1a" "${te}1b" "${te}2"
$PRINTF "$FAILED: $SOCAT:\n" numFAIL=$((numFAIL+1))
elif ! echo -e "$da1a\n$da1b" |diff - "$tf" >"$tdiff"; then elif ! echo -e "$da1a\n$da1b" |diff - "$tf" >"$tdiff"; then
$PRINTF "$FAILED\n" $PRINTF "$FAILED\n"
cat "$tdiff" cat "$tdiff"
cat "${te}1a" "${te}1b" "${te}2" cat "${te}1a" "${te}1b" "${te}2"
$PRINTF "$FAILED: $SOCAT:\n" numFAIL=$((numFAIL+1))
else else
$PRINTF "$OK\n" $PRINTF "$OK\n"
if [ -n "$debug" ]; then cat "${te}1a" "${te}1b" "${te}2"; fi if [ -n "$debug" ]; then cat "${te}1a" "${te}1b" "${te}2"; fi
@ -7525,6 +7534,7 @@ touch "$ts" # make a file with same name, so non-abstract fails
eval "$SRV 2>${te}s &" eval "$SRV 2>${te}s &"
pids=$! pids=$!
#waitfile "$ts" #waitfile "$ts"
sleep 1
echo "$da1" |eval "$CMD" >"${tf}1" 2>"${te}1" echo "$da1" |eval "$CMD" >"${tf}1" 2>"${te}1"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
kill "$pids" 2>/dev/null kill "$pids" 2>/dev/null
@ -7575,6 +7585,7 @@ printf "test $F_n $TEST... " $N
touch "$ts1" # make a file with same name, so non-abstract fails touch "$ts1" # make a file with same name, so non-abstract fails
$CMD1 2>"${te}1" & $CMD1 2>"${te}1" &
pid1="$!" pid1="$!"
sleep 1
echo "$da" |$CMD2 >>"$tf" 2>>"${te}2" echo "$da" |$CMD2 >>"$tf" 2>>"${te}2"
rc2=$? rc2=$?
kill "$pid1" 2>/dev/null; wait kill "$pid1" 2>/dev/null; wait
@ -7621,6 +7632,7 @@ touch "$ts1" # make a file with same name, so non-abstract fails
$CMD1 >"$tf" 2>"${te}1" & $CMD1 >"$tf" 2>"${te}1" &
pid1="$!" pid1="$!"
#waitfile $ts1 1 #waitfile $ts1 1
sleep 1
echo "$da" |$CMD2 2>>"${te}2" echo "$da" |$CMD2 2>>"${te}2"
rc2="$?" rc2="$?"
i=0; while [ ! -s "$tf" -a "$i" -lt 10 ]; do usleep 100000; i=$((i+1)); done i=0; while [ ! -s "$tf" -a "$i" -lt 10 ]; do usleep 100000; i=$((i+1)); done
@ -7650,7 +7662,7 @@ N=$((N+1))
NAME=OPENSSLREAD NAME=OPENSSLREAD
# socat determined availability of data using select(). With openssl, the # socat determined availability of data using select(). With openssl, the
# following situation might occur: # following situation might occur:
# a SSL data block with more than 8192 bytes (socat defaults blocksize) # a SSL data block with more than 8192 bytes (socats default blocksize)
# arrives; socat calls SSL_read, and the SSL routine reads the complete block. # arrives; socat calls SSL_read, and the SSL routine reads the complete block.
# socat then reads 8192 bytes from the SSL layer, the rest remains buffered. # socat then reads 8192 bytes from the SSL layer, the rest remains buffered.
# If the TCP connection stays idle for some time, the data in the SSL layer # If the TCP connection stays idle for some time, the data in the SSL layer
@ -7679,6 +7691,7 @@ printf "test $F_n $TEST... " $N
# #
$CMD1 2>"${te}1" >"$tf" & $CMD1 2>"${te}1" >"$tf" &
pid=$! # background process id pid=$! # background process id
waittcp4port $PORT
(echo "$da"; sleep 2) |$CMD2 2>"${te}2" (echo "$da"; sleep 2) |$CMD2 2>"${te}2"
if ! echo "$da" |diff - "$tf" >"$tdiff"; then if ! echo "$da" |diff - "$tf" >"$tdiff"; then
$PRINTF "$FAILED: $SOCAT:\n" $PRINTF "$FAILED: $SOCAT:\n"
@ -7694,6 +7707,7 @@ else
numOK=$((numOK+1)) numOK=$((numOK+1))
fi fi
fi fi
wait ;;
esac esac
N=$((N+1)) N=$((N+1))
@ -7711,8 +7725,7 @@ TEST="$NAME: trigger EOF after that many bytes, even when socket idle"
# we try to transfer data in the other direction then; if transfer succeeds, # we try to transfer data in the other direction then; if transfer succeeds,
# the process did not terminate and the bug is still there. # the process did not terminate and the bug is still there.
if false; then if false; then
$PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not avail $PRINTF "test $F_n $TEST... ${YELLOW}$(echo $feat| tr 'a-z' 'A-Z') not available${NORMAL}\n" $N
able${NORMAL}\n" $N
numCANT=$((numCANT+1)) numCANT=$((numCANT+1))
else else
tr="$td/test$N.ref" tr="$td/test$N.ref"