mirror of
https://repo.or.cz/socat.git
synced 2025-07-09 05:46:32 +00:00
Corrected regression of ignoreeof
This commit is contained in:
parent
9968ca4c5b
commit
fa67d7d380
3 changed files with 71 additions and 23 deletions
88
test.sh
88
test.sh
|
@ -3521,67 +3521,110 @@ esac
|
|||
N=$((N+1))
|
||||
|
||||
|
||||
# Test the ignoreeof option in forward (left to right) direction
|
||||
NAME=IGNOREEOF
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%engine%*|*%ignoreeof%*|*%$NAME%*)
|
||||
TEST="$NAME: ignoreeof on file"
|
||||
if ! eval $NUMCOND; then :; else
|
||||
# Let Socat read from an empty file, this would terminate immediately due to
|
||||
# EOF. Wait for more than one second, then append data to the file; when Socat
|
||||
# transfers this data the test succeeded.
|
||||
if ! eval $NUMCOND; then :;
|
||||
elif ! cond=$(checkconds \
|
||||
"" \
|
||||
"" \
|
||||
"" \
|
||||
"STDIO FILE" \
|
||||
"STDOUT FILE" \
|
||||
"ignoreeof" \
|
||||
"" ); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
|
||||
numCANT=$((numCANT+1))
|
||||
listCANT="$listCANT $N"
|
||||
else
|
||||
ti="$td/test$N.file"
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
tdiff="$td/test$N.diff"
|
||||
da="test$N $(date) $RANDOM"
|
||||
CMD="$TRACE $SOCAT $opts -u file:\"$ti\",ignoreeof -"
|
||||
# Note: the bug in 1.8.0.0 and 1.8.0.1 let Socat terminate in unidirectional
|
||||
# mode after 1s, in bidirectional mode with traffic in reverse direction
|
||||
# (var wasaction) immediately
|
||||
CMD="$TRACE $SOCAT $opts -u FILE:\"$ti\",ignoreeof -"
|
||||
printf "test $F_n $TEST... " $N
|
||||
touch "$ti"
|
||||
$CMD >"$tf" 2>"$te" &
|
||||
bg=$!
|
||||
sleep 0.1
|
||||
# Up to 1.8.0.1 this sleep was 0.1 and thus the test said OK despite the bug
|
||||
sleep 1.1
|
||||
echo "$da" >>"$ti"
|
||||
sleep 1
|
||||
kill $bg 2>/dev/null; wait
|
||||
if ! echo "$da" |diff - "$tf" >"$tdiff"; then
|
||||
$PRINTF "$FAILED: diff:\n"
|
||||
cat "$tdiff"
|
||||
$PRINTF "$FAILED (diff)\n"
|
||||
echo "$CMD"
|
||||
cat "$te" >&2
|
||||
echo "// diff:" >&2
|
||||
cat "$tdiff" >&2
|
||||
failed
|
||||
else
|
||||
$PRINTF "$OK\n"
|
||||
if [ -n "$debug" ]; then cat $te; fi
|
||||
ok
|
||||
$PRINTF "$OK\n"
|
||||
if [ -n "$VERBOSE" ]; then echo "$CMD"; fi
|
||||
if [ -n "$DEBUG" ]; then cat "$te" >&2; fi
|
||||
ok
|
||||
fi
|
||||
fi ;; # NUMCOND
|
||||
esac
|
||||
N=$((N+1))
|
||||
|
||||
# Test the ignoreeof option in reverse (right to left) direction
|
||||
NAME=IGNOREEOF_REV
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%engine%*|*%ignoreeof%*|*%$NAME%*)
|
||||
TEST="$NAME: ignoreeof on file right-to-left"
|
||||
if ! eval $NUMCOND; then :; else
|
||||
if ! eval $NUMCOND; then :;
|
||||
elif ! cond=$(checkconds \
|
||||
"" \
|
||||
"" \
|
||||
"" \
|
||||
"STDIO FILE" \
|
||||
"STDOUT FILE" \
|
||||
"ignoreeof" \
|
||||
"" ); then
|
||||
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
|
||||
numCANT=$((numCANT+1))
|
||||
listCANT="$listCANT $N"
|
||||
else
|
||||
# Let Socat read from an empty file, this would terminate immediately due to
|
||||
# EOF. Wait for more than one second, then append data to the file; when Socat
|
||||
# transfers this data the test succeeded.
|
||||
ti="$td/test$N.file"
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
tdiff="$td/test$N.diff"
|
||||
da="test$N $(date) $RANDOM"
|
||||
CMD="$SOCAT $opts -U - file:\"$ti\",ignoreeof"
|
||||
CMD="$SOCAT $opts -U - FILE:\"$ti\",ignoreeof"
|
||||
printf "test $F_n $TEST... " $N
|
||||
touch "$ti"
|
||||
$CMD >"$tf" 2>"$te" &
|
||||
bg=$!
|
||||
relsleep 1
|
||||
sleep 1.1
|
||||
echo "$da" >>"$ti"
|
||||
sleep 1
|
||||
kill $bg 2>/dev/null
|
||||
kill $bg 2>/dev/null; wait
|
||||
if ! echo "$da" |diff - "$tf" >"$tdiff"; then
|
||||
$PRINTF "$FAILED: diff:\n"
|
||||
cat "$tdiff"
|
||||
$PRINTF "$FAILED (diff)\n"
|
||||
echo "$CMD"
|
||||
cat "$te" >&2
|
||||
echo "// diff:" >&2
|
||||
cat "$tdiff" >&2
|
||||
failed
|
||||
else
|
||||
$PRINTF "$OK\n"
|
||||
if [ -n "$debug" ]; then cat $te; fi
|
||||
ok
|
||||
$PRINTF "$OK\n"
|
||||
if [ -n "$VERBOSE" ]; then echo "$CMD"; fi
|
||||
if [ -n "$DEBUG" ]; then cat "$te" >&2; fi
|
||||
ok
|
||||
fi
|
||||
wait
|
||||
fi ;; # NUMCOND
|
||||
esac
|
||||
N=$((N+1))
|
||||
|
@ -3601,12 +3644,13 @@ $CMD >"$tf" 2>"$te"
|
|||
if [ -s "$te" ]; then
|
||||
$PRINTF "$FAILED: $TRACE $SOCAT:\n"
|
||||
echo "$CMD"
|
||||
cat "$te"
|
||||
cat "$te" >&2
|
||||
failed
|
||||
else
|
||||
$PRINTF "$OK\n"
|
||||
if [ -n "$debug" ]; then cat $te; fi
|
||||
ok
|
||||
$PRINTF "$OK\n"
|
||||
if [ -n "$VERBOSE" ]; then echo "$CMD"; fi
|
||||
if [ -n "$DEBUG" ]; then cat "$te" >&2; fi
|
||||
ok
|
||||
fi
|
||||
fi ;; # NUMCOND
|
||||
esac
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue