diff options
author | Hans Nilsson <[email protected]> | 2016-11-01 11:54:24 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2016-11-01 11:54:24 +0100 |
commit | 6ecfa5c23518335ed8c129d57666f1265b1b7d20 (patch) | |
tree | e8aa8630060f92e73b970027f72b5720d7234379 /lib/ssh/test/ssh_test_lib.erl | |
parent | 18dad110a0e9220cf1a18ff1cd78d66d6ce203b5 (diff) | |
parent | a5d638e4aa772f44f8ca071e1f7cf625ccc34c01 (diff) | |
download | otp-6ecfa5c23518335ed8c129d57666f1265b1b7d20.tar.gz otp-6ecfa5c23518335ed8c129d57666f1265b1b7d20.tar.bz2 otp-6ecfa5c23518335ed8c129d57666f1265b1b7d20.zip |
Merge branch 'hans/ssh/cuddle_tests_maint' into maint
Diffstat (limited to 'lib/ssh/test/ssh_test_lib.erl')
-rw-r--r-- | lib/ssh/test/ssh_test_lib.erl | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl index 7cd364a6dc..f93237f3e7 100644 --- a/lib/ssh/test/ssh_test_lib.erl +++ b/lib/ssh/test/ssh_test_lib.erl @@ -800,17 +800,37 @@ busy_wait(Nus, T0) -> %% get_kex_init - helper function to get key_exchange_init_msg get_kex_init(Conn) -> + Ref = make_ref(), + {ok,TRef} = timer:send_after(15000, {reneg_timeout,Ref}), + get_kex_init(Conn, Ref, TRef). + +get_kex_init(Conn, Ref, TRef) -> %% First, validate the key exchange is complete (StateName == connected) - {{connected,_},S} = sys:get_state(Conn), - %% Next, walk through the elements of the #state record looking - %% for the #ssh_msg_kexinit record. This method is robust against - %% changes to either record. The KEXINIT message contains a cookie - %% unique to each invocation of the key exchange procedure (RFC4253) - SL = tuple_to_list(S), - case lists:keyfind(ssh_msg_kexinit, 1, SL) of - false -> - throw(not_found); - KexInit -> - KexInit - end. + case sys:get_state(Conn) of + {{connected,_}, S} -> + timer:cancel(TRef), + %% Next, walk through the elements of the #state record looking + %% for the #ssh_msg_kexinit record. This method is robust against + %% changes to either record. The KEXINIT message contains a cookie + %% unique to each invocation of the key exchange procedure (RFC4253) + SL = tuple_to_list(S), + case lists:keyfind(ssh_msg_kexinit, 1, SL) of + false -> + throw(not_found); + KexInit -> + KexInit + end; + {OtherState, S} -> + ct:log("Not in 'connected' state: ~p",[OtherState]), + receive + {reneg_timeout,Ref} -> + ct:log("S = ~p", [S]), + ct:fail(reneg_timeout) + after 0 -> + timer:sleep(100), % If renegotiation is complete we do not + % want to exit on the reneg_timeout + get_kex_init(Conn, Ref, TRef) + end + end. + |