Commits

Anonymous committed 5fe0516 Merge

Merged from main branch

Comments (0)

Files changed (2)

test/lhttpc_manager_tests.erl

     ok = application:stop(crypto).
 
 manager_test_() ->
-    {setup, fun start_app/0, fun stop_app/1, [
-            ?_test(empty_manager()),
-            ?_test(one_socket()),
-            ?_test(many_sockets()),
-            ?_test(closed_race_cond())
-        ]}.
+    {inorder,
+        {setup, fun start_app/0, fun stop_app/1, [
+                ?_test(empty_manager()),
+                ?_test(one_socket()),
+                ?_test(many_sockets()),
+                ?_test(closed_race_cond())
+            ]}
+    }.
 
 %%% Tests
 
 empty_manager() ->
-    ?assertEqual(no_socket,  gen_server:call(lhttpc_manager,
+    ?assertEqual(no_socket, gen_server:call(lhttpc_manager,
             {socket, self(), ?HOST, ?PORT, ?SSL})).
 
 one_socket() ->

test/socket_server.erl

 -module(socket_server).
 
 -export([open/0, connect/1, listen/0, accept/1]).
--export([do_accept/1]).
+-export([do_accept/2]).
 
 open() ->
     {LS, Port} = listen(),
     {LS, Port}.
 
 accept(LS) ->
-    spawn_link(?MODULE, do_accept, [LS]).
+    Pid = spawn_link(?MODULE, do_accept, [LS, self()]),
+    receive in_accept -> ok end,
+    Pid.
 
-do_accept(LS) ->
+do_accept(LS, Parent) ->
+    erlang:send_after(50, Parent, in_accept),
     {ok, S} = gen_tcp:accept(LS),
     {error, closed} = gen_tcp:recv(S, 0).