From 8bbc48c1aa3abc2a8f52928dfd2f42a6e3dacccd Mon Sep 17 00:00:00 2001 From: dtucker Date: Wed, 20 Apr 2022 13:25:55 +0000 Subject: [PATCH] Use ssh -f and ControlPersist to start up test forwards and ssh -O stop to shut them down intead of sleep loops. This speeds up the test by an order of magnitude. --- regress/usr.bin/ssh/forward-control.sh | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/regress/usr.bin/ssh/forward-control.sh b/regress/usr.bin/ssh/forward-control.sh index 3dcddbc7e8b..24594cc154e 100644 --- a/regress/usr.bin/ssh/forward-control.sh +++ b/regress/usr.bin/ssh/forward-control.sh @@ -1,4 +1,4 @@ -# $OpenBSD: forward-control.sh,v 1.9 2022/04/20 05:24:13 dtucker Exp $ +# $OpenBSD: forward-control.sh,v 1.10 2022/04/20 13:25:55 dtucker Exp $ # Placed in the Public Domain. tid="sshd control of local and remote forwarding" @@ -27,16 +27,14 @@ check_lfwd() { ${SSH} -F $OBJ/ssh_proxy \ -L$LFWD_PORT:127.0.0.1:$PORT \ -o ExitOnForwardFailure=yes \ - -n -N host >/dev/null 2>&1 & - _sshpid=$! - if test $? -ne 0; then - fatal "check_lfwd ssh fail: $_message" - fi + -MS $CTL -o ControlPersist=yes \ + -f host true + ${SSH} -F $OBJ/ssh_proxy -S $CTL -O check host >/dev/null 2>&1 || \ + fatal "check_lfwd ssh fail: $_message" ${SSH} -F $OBJ/ssh_config -p $LFWD_PORT \ -oConnectionAttempts=10 host true >/dev/null 2>&1 _result=$? - kill $_sshpid 2>/dev/null - wait_for_process_to_exit $_sshpid + ${SSH} -F $OBJ/ssh_proxy -S $CTL -O exit host >/dev/null 2>&1 if test "x$_expected" = "xY" -a $_result -ne 0 ; then fail "check_lfwd failed (expecting success): $_message" elif test "x$_expected" = "xN" -a $_result -eq 0 ; then @@ -55,15 +53,15 @@ check_rfwd() { ${SSH} -F $OBJ/ssh_proxy \ -R127.0.0.1:$RFWD_PORT:127.0.0.1:$PORT \ -o ExitOnForwardFailure=yes \ - -n -N host >/dev/null 2>&1 & - _sshpid=$! + -MS $CTL -o ControlPersist=yes \ + -f host true + ${SSH} -F $OBJ/ssh_proxy -S $CTL -O check host >/dev/null 2>&1 _result=$? - if test $_result -eq 0 ; then + if ${SSH} -F $OBJ/ssh_proxy -S $CTL -O check host >/dev/null 2>&1; then ${SSH} -F $OBJ/ssh_config -p $RFWD_PORT \ -oConnectionAttempts=10 host true >/dev/null 2>&1 _result=$? - kill $_sshpid 2>/dev/null - wait_for_process_to_exit $_sshpid + ${SSH} -F $OBJ/ssh_proxy -S $CTL -O exit host >/dev/null 2>&1 fi if test "x$_expected" = "xY" -a $_result -ne 0 ; then fail "check_rfwd failed (expecting success): $_message" -- 2.20.1