diff options
author | Hans Nilsson <[email protected]> | 2016-10-31 11:37:10 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2016-10-31 11:37:10 +0100 |
commit | 59ecab4221fd2b8938c2a3a65f82159626d6a273 (patch) | |
tree | 84b944d044492224b33a9c7b4967f3e9f6d48f8d /lib/ssh/test/ssh_test_lib.erl | |
parent | 1d6d13cc0ab1178d1603af90660963160817a03d (diff) | |
download | otp-59ecab4221fd2b8938c2a3a65f82159626d6a273.tar.gz otp-59ecab4221fd2b8938c2a3a65f82159626d6a273.tar.bz2 otp-59ecab4221fd2b8938c2a3a65f82159626d6a273.zip |
ssh: make test more precise in ssh_to_openssh_SUITE
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. + |