From a9a2931258f9ce4938aae3f71ec0fa2694d66a48 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Fri, 24 Mar 2023 19:44:00 +0100 Subject: [PATCH] test.sh: Some timing adaptations --- CHANGES | 3 +++ test.sh | 39 ++++++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index 090ae47..4b394b3 100644 --- a/CHANGES +++ b/CHANGES @@ -84,6 +84,9 @@ Testing: test.sh: Added help text + Speeded up wait loops; more addresses in upper case; more tests with + command printing ($VERBOSE) + ####################### V 1.7.4.4: Corrections: diff --git a/test.sh b/test.sh index bcb7aec..7bb27ae 100755 --- a/test.sh +++ b/test.sh @@ -2171,7 +2171,7 @@ waitip4proto () { esac [ \( \( $logic -ne 0 \) -a -n "$l" \) -o \ \( \( $logic -eq 0 \) -a -z "$l" \) ] && return 0 - sleep 1 + psleep $val_t timeout=$((timeout-1)) done @@ -2217,7 +2217,7 @@ waitip6proto () { esac [ \( \( $logic -ne 0 \) -a -n "$l" \) -o \ \( \( $logic -eq 0 \) -a -z "$l" \) ] && return 0 - sleep 1 + psleep $val_t timeout=$((timeout-1)) done @@ -2294,7 +2294,7 @@ waittcp4port () { set ${vx}vx return 0 fi - sleep 1 + psleep $val_t timeout=$((timeout-1)) done @@ -2338,7 +2338,7 @@ waitudp4port () { set ${vx}vx return 0 fi - sleep 1 + psleep $val_t timeout=$((timeout-1)) done @@ -2381,7 +2381,7 @@ waitsctp4port () { set ${vx}vx return 0 fi - sleep 1 + psleep $val_t timeout=$((timeout-1)) done @@ -2421,7 +2421,7 @@ waittcp6port () { set ${vx}vx return 0 fi - sleep 1 + psleep $val_t timeout=$((timeout-1)) done @@ -2465,7 +2465,7 @@ waitudp6port () { set ${vx}vx return 0 fi - sleep 1 + psleep $val_t timeout=$((timeout-1)) done @@ -2504,7 +2504,7 @@ waitsctp6port () { set ${vx}vx return 0 fi - sleep 1 + psleep $val_t timeout=$((timeout-1)) done @@ -2536,7 +2536,7 @@ waitfile () { set ${vx}vx return 0 fi - sleep 1 + psleep $val_t timeout=$((timeout-1)) done @@ -4564,7 +4564,11 @@ if ! echo "$da" |$OD_C |diff - "$tf" >"$tdiff"; then numFAIL=$((numFAIL+1)) listFAIL="$listFAIL $N" else - $PRINTF "$OK\n" + $PRINTF "$OK\n" + if [ "$VERBOSE" ]; then + echo " $CMD2 &" + echo " $CMD" + fi if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi numOK=$((numOK+1)) fi @@ -6622,23 +6626,28 @@ testptywaitslave () { local da="test$N $(date) $RANDOM" printf "test $F_n $TEST... " $N # first generate a pty, then a socket -($TRACE $SOCAT $opts -lpsocat1 pty,$PTYTYPE,pty-wait-slave,link="$tp" unix-listen:"$ts" 2>"$te1"; rm -f "$tp") 2>/dev/null & +($TRACE $SOCAT $opts -lpsocat1 PTY,$PTYTYPE,pty-wait-slave,link="$tp" UNIX-LISTEN:"$ts" 2>"$te1"; rm -f "$tp") 2>/dev/null & pid=$! waitfile "$tp" # if pty was non-blocking, the socket is active, and socat1 will term -$TRACE $SOCAT $opts -T 10 -lpsocat2 file:/dev/null unix-connect:"$ts" 2>"$te2" +$TRACE $SOCAT $opts -T 10 -lpsocat2 FILE:/dev/null UNIX-CONNECT:"$ts" 2>"$te2" # if pty is blocking, first socat is still active and we get a connection now #((echo "$da"; sleep 2) |$TRACE $SOCAT -lpsocat3 $opts - file:"$tp",$PTYOPTS2 >"$tf" 2>"$te3") & -( (waitfile "$ts"; echo "$da"; sleep 1) |$TRACE $SOCAT -lpsocat3 $opts - file:"$tp",$PTYOPTS2 >"$tf" 2>"$te3") & -waitfile "$ts" +( (waitfile "$ts" 1 20; echo "$da"; sleep 1) |$TRACE $SOCAT -lpsocat3 $opts - FILE:"$tp",$PTYOPTS2 >"$tf" 2>"$te3") & +waitfile "$ts" 1 20 # but we need an echoer on the socket -$TRACE $SOCAT $opts -lpsocat4 unix:"$ts" echo 2>"$te4" +$TRACE $SOCAT $opts -lpsocat4 UNIX:"$ts" ECHO 2>"$te4" # now $tf file should contain $da #kill $pid 2>/dev/null wait # if echo "$da" |diff - "$tf"> "$tdiff"; then $PRINTF "$OK\n" + if [ "$VERBOSE" ]; then + echo " $TRACE $SOCAT $opts -T 10 -lpsocat2 FILE:/dev/null UNIX-CONNECT:\"$ts\"" 2>"$te2" + echo " $TRACE $SOCAT $opts -lpsocat1 PTY,$PTYTYPE,pty-wait-slave,link=\"$tp\" UNIX-LISTEN:\"$ts\"" >&2 + echo " $TRACE $SOCAT -lpsocat3 $opts - file:\"$tp\",$PTYOPTS2" >&2 + fi numOK=$((numOK+1)) else $PRINTF "${YELLOW}FAILED${NORMAL}\n"