From f9de643f167cfa274862d323694c1bf5b57d3be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Wed, 19 Jul 2017 13:48:04 +0200 Subject: [PATCH] Try to fix tests for older openssl --- src/fast_tls.erl | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/fast_tls.erl b/src/fast_tls.erl index f1d8cfe..802acfd 100644 --- a/src/fast_tls.erl +++ b/src/fast_tls.erl @@ -439,29 +439,29 @@ load_nif_test() -> transmission_test() -> {LPid, Port} = setup_listener([]), SPid = setup_sender(Port, []), - LPid ! {stop, self()}, - receive - {received, Msg} -> - ?assertEqual(Msg, <<"abcdefghi">>) - end, SPid ! {stop, self()}, receive {result, Res} -> ?assertEqual(ok, Res) + end, + LPid ! {stop, self()}, + receive + {received, Msg} -> + ?assertEqual(Msg, <<"abcdefghi">>) end. not_compatible_protocol_options_test() -> - {LPid, Port} = setup_listener([{protocol_options, <<"no_sslv2|no_sslv3|no_tlsv1|no_tlsv1_1">>}]), - SPid = setup_sender(Port, [{protocol_options, <<"no_sslv2|no_sslv3|no_tlsv1_1|no_tlsv1_2">>}]), + {LPid, Port} = setup_listener([{protocol_options, <<"no_sslv2|no_sslv3|no_tlsv1_1|no_tlsv1_2">>}]), + SPid = setup_sender(Port, [{protocol_options, <<"no_sslv2|no_sslv3|no_tlsv1|no_tlsv1_2">>}]), + SPid ! {stop, self()}, + receive + {result, Res} -> + ?assertMatch({badmatch, {error, _}}, Res) + end, LPid ! {stop, self()}, receive {received, Msg} -> ?assertEqual(Msg, <<>>) - end, - SPid ! {stop, self()}, - receive - {result, Res} -> - ?assertEqual({badmatch, {error, enotconn}}, Res) end. setup_listener(Opts) -> @@ -479,7 +479,12 @@ setup_listener(Opts) -> listener_loop(TLSSock, Msg) -> case recv(TLSSock, 1, 1000) of {error, timeout} -> - listener_loop(TLSSock, Msg); + receive + {stop, Pid} -> + Pid ! {received, Msg} + after 0 -> + listener_loop(TLSSock, Msg) + end; {error, _} -> receive {stop, Pid} ->