@@ -112,12 +112,29 @@ fail() {
112112 exit 1
113113}
114114
115+ # Set WOLFSSH_TEST_REQUIRE_OPENSSH=1 where every part must run, as in CI;
116+ # each skip below is then a failure.
117+ require_openssh=${WOLFSSH_TEST_REQUIRE_OPENSSH:- 0}
118+
115119skip () {
120+ if [ " $require_openssh " = " 1" ]; then
121+ fail " $1 ; WOLFSSH_TEST_REQUIRE_OPENSSH=1 does not allow skipping"
122+ fi
116123 printf ' %s, skipping\n' " $1 "
117124 rm -rf -- " $work_dir "
118125 exit 77
119126}
120127
128+ # Skip the part named by $2, keeping the parts that already passed.
129+ skip_rest () {
130+ if [ " $require_openssh " = " 1" ]; then
131+ fail " $1 ; WOLFSSH_TEST_REQUIRE_OPENSSH=1 does not allow skipping $2 "
132+ fi
133+ echo " $1 , skipping $2 "
134+ do_cleanup
135+ exit 0
136+ }
137+
121138command -v ssh > /dev/null 2>&1 || skip " no ssh in the path"
122139
123140ssh_version=` ssh -V 2>&1 `
@@ -279,19 +296,13 @@ if [ -z "$sshd_bin" ]; then
279296fi
280297
281298if [ -z " $sshd_bin " ] || [ ! -x " $sshd_bin " ]; then
282- echo " no sshd on this machine, skipping the wolfSSH client half"
283- do_cleanup
284- exit 0
299+ skip_rest " no sshd on this machine" " the wolfSSH client half"
285300fi
286301if ! command -v ssh-keygen > /dev/null 2>&1 ; then
287- echo " no ssh-keygen, skipping the wolfSSH client half"
288- do_cleanup
289- exit 0
302+ skip_rest " no ssh-keygen" " the wolfSSH client half"
290303fi
291304if [ ! -x ./examples/client/client ]; then
292- echo " the example client wasn't built, skipping the wolfSSH client half"
293- do_cleanup
294- exit 0
305+ skip_rest " the example client wasn't built" " the wolfSSH client half"
295306fi
296307
297308echo " Test the wolfSSH client against OpenSSH's sshd"
@@ -358,10 +369,8 @@ while [ "$counter" -lt 5 ]; do
358369done
359370
360371if [ " $sshd_port " -eq 0 ]; then
361- echo " sshd wouldn't start here, skipping the wolfSSH client half"
362372 [ -s " $sshd_log " ] && tail -n 5 " $sshd_log "
363- do_cleanup
364- exit 0
373+ skip_rest " sshd wouldn't start here" " the wolfSSH client half"
365374fi
366375
367376# The version gate above covered the client. This sshd was found on its own
@@ -372,10 +381,9 @@ sshd_version=`sed -n 's/.*sshd version \(OpenSSH_[^,]*\).*/\1/p' \
372381 " $sshd_log " | head -n 1`
373382has_strict_kex " $sshd_version "
374383if [ $? -ne 0 ]; then
375- echo " $sshd_bin is ${sshd_version:- an unreadable version} , no strict KEX,"
376- echo " skipping the wolfSSH client half"
377- do_cleanup
378- exit 0
384+ skip_rest \
385+ " $sshd_bin is ${sshd_version:- an unreadable version} , no strict KEX" \
386+ " the wolfSSH client half"
379387fi
380388
381389# sshd authenticates the user running this test, with one of the canned
@@ -455,15 +463,11 @@ echo "the wolfSSH client negotiated strict KEX with sshd"
455463
456464# Part 3 needs the client's agent support and OpenSSH's agent tools.
457465if ! ./examples/client/client ' -?' 2>&1 | grep -q ' SSH-AGENT' ; then
458- echo " the example client has no agent support, skipping the agent half"
459- do_cleanup
460- exit 0
466+ skip_rest " the example client has no agent support" " the agent half"
461467fi
462468if ! command -v ssh-agent > /dev/null 2>&1 ||
463469 ! command -v ssh-add > /dev/null 2>&1 ; then
464- echo " no ssh-agent or ssh-add, skipping the agent half"
465- do_cleanup
466- exit 0
470+ skip_rest " no ssh-agent or ssh-add" " the agent half"
467471fi
468472
469473# The RSA signature algorithms this client was built with; -E lists them
@@ -475,9 +479,7 @@ for alg in rsa-sha2-256 rsa-sha2-512; do
475479 fi
476480done
477481if [ -z " $agent_rsa_algs " ]; then
478- echo " the client has no rsa-sha2 algorithms, skipping the agent half"
479- do_cleanup
480- exit 0
482+ skip_rest " the client has no rsa-sha2 algorithms" " the agent half"
481483fi
482484
483485echo " Test the wolfSSH client signing through ssh-agent for sshd"
0 commit comments