From 24da8cbfa0f9ecffcf3785d321d203ff6707fd7e Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Sat, 30 Aug 2014 11:25:33 -0400 Subject: [PATCH] stream test: use receive Use a receive with timeout rather than polling the mailbox. --- test/alcove_tests.erl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/alcove_tests.erl b/test/alcove_tests.erl index 15fe121..8fe590d 100644 --- a/test/alcove_tests.erl +++ b/test/alcove_tests.erl @@ -604,8 +604,6 @@ stream(#state{pid = Drv}) -> Count = 1 * 1024 * 1024, ok = alcove:execvp(Drv, Chain, "/bin/sh", ["/bin/sh", "-c", "yes | head -" ++ integer_to_list(Count)]), - % XXX magic timeout: give OS time to exec shell command - timer:sleep(100), % <<"y\n">> Reply = stream_count(Drv, Chain, Count*2), ?_assertEqual(ok, Reply). @@ -660,9 +658,10 @@ chain(Drv, Fork, N) -> stream_count(_Drv, _Chain, 0) -> ok; stream_count(Drv, Chain, N) -> - case alcove:stdout(Drv, Chain) of - false -> - {error, N}; - Bin -> + receive + {alcove_stdout, Drv, Chain, Bin} -> stream_count(Drv, Chain, N - byte_size(Bin)) + after + 1000 -> + {error, N} end.