diff options
author | Ingela Anderton Andin <[email protected]> | 2010-04-09 10:07:27 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-04-09 10:07:27 +0000 |
commit | 1e27864b145d6411fcb0c7c4c41c18acc289174b (patch) | |
tree | d28db82b674ee16047e0b517e2718df48f1a41a3 /lib/ssl/test/ssl_test_lib.erl | |
parent | d26d7db828416ffc4c9cc02b8c756e53aa144d3a (diff) | |
download | otp-1e27864b145d6411fcb0c7c4c41c18acc289174b.tar.gz otp-1e27864b145d6411fcb0c7c4c41c18acc289174b.tar.bz2 otp-1e27864b145d6411fcb0c7c4c41c18acc289174b.zip |
Removed need of sleep better to synchronize if possible.
Diffstat (limited to 'lib/ssl/test/ssl_test_lib.erl')
-rw-r--r-- | lib/ssl/test/ssl_test_lib.erl | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/ssl/test/ssl_test_lib.erl b/lib/ssl/test/ssl_test_lib.erl index 51a8e1a95c..466e987e3e 100644 --- a/lib/ssl/test/ssl_test_lib.erl +++ b/lib/ssl/test/ssl_test_lib.erl @@ -52,7 +52,11 @@ node_to_hostip(Node) -> Address. start_server(Args) -> - spawn_link(?MODULE, run_server, [Args]). + Result = spawn_link(?MODULE, run_server, [Args]), + receive + {listen, up} -> + Result + end. run_server(Opts) -> Node = proplists:get_value(node, Opts), @@ -61,6 +65,7 @@ run_server(Opts) -> Pid = proplists:get_value(from, Opts), test_server:format("ssl:listen(~p, ~p)~n", [Port, Options]), {ok, ListenSocket} = rpc:call(Node, ssl, listen, [Port, Options]), + Pid ! {listen, up}, case Port of 0 -> {ok, {_, NewPort}} = ssl:sockname(ListenSocket), @@ -298,7 +303,11 @@ cert_options(Config) -> start_upgrade_server(Args) -> - spawn_link(?MODULE, run_upgrade_server, [Args]). + Result = spawn_link(?MODULE, run_upgrade_server, [Args]), + receive + {listen, up} -> + Result + end. run_upgrade_server(Opts) -> Node = proplists:get_value(node, Opts), @@ -310,6 +319,7 @@ run_upgrade_server(Opts) -> test_server:format("gen_tcp:listen(~p, ~p)~n", [Port, TcpOptions]), {ok, ListenSocket} = rpc:call(Node, gen_tcp, listen, [Port, TcpOptions]), + Pid ! {listen, up}, case Port of 0 -> @@ -383,7 +393,11 @@ run_upgrade_client(Opts) -> end. start_server_error(Args) -> - spawn_link(?MODULE, run_server_error, [Args]). + Result = spawn_link(?MODULE, run_server_error, [Args]), + receive + {listen, up} -> + Result + end. run_server_error(Opts) -> Node = proplists:get_value(node, Opts), @@ -393,8 +407,9 @@ run_server_error(Opts) -> test_server:format("ssl:listen(~p, ~p)~n", [Port, Options]), case rpc:call(Node, ssl, listen, [Port, Options]) of {ok, ListenSocket} -> - test_server:sleep(2000), %% To make sure error_client will + %% To make sure error_client will %% get {error, closed} and not {error, connection_refused} + Pid ! {listen, up}, test_server:format("ssl:transport_accept(~p)~n", [ListenSocket]), case rpc:call(Node, ssl, transport_accept, [ListenSocket]) of {error, _} = Error -> @@ -405,6 +420,9 @@ run_server_error(Opts) -> Pid ! {self(), Error} end; Error -> + %% Not really true but as this is an error test + %% this is what we want. + Pid ! {listen, up}, Pid ! {self(), Error} end. |