From cabe113ee5e4a137e16ad2cf6c6a0bbb8889fdb6 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 25 May 2016 14:49:59 +0200 Subject: Retry ct_telnet:get_data if no data is received after short wait ct_telnet_own_server_SUITE:large_string tests that the client can receive a chopped up string. To make sure the right thing is tested, a SHORT timer is used before calling ct_telnet:get_data, but on some slow machines the the timer is too short to allow data to be received. To overcome this, the test now re-tries ct_telnet:get_data a few times before giving up. --- .../ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl index 9dc9095f47..985fa40ad2 100644 --- a/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl +++ b/lib/common_test/test/ct_telnet_SUITE_data/ct_telnet_own_server_SUITE.erl @@ -308,8 +308,19 @@ large_string(_) -> VerifyStr = [C || C <- lists:flatten(Data1), C/=$ , C/=$\r, C/=$\n, C/=$>], ok = ct_telnet:send(Handle, "echo_sep "++BigString), - ct:sleep(50), - {ok,Data2} = ct_telnet:get_data(Handle), + %% On some slow machines, 50 ms might not be enough to get the + %% first packet of data. We will therefore keep trying for a + %% second before we give up this... + F = fun RepeatUntilData(N) -> + ct:sleep(50), + case ct_telnet:get_data(Handle) of + {ok,[]} when N>1 -> + RepeatUntilData(N-1); + Other -> + Other + end + end, + {ok,Data2} = F(20), ct:log("[GET DATA #2] Received ~w chars: ~s", [length(lists:flatten(Data2)),Data2]), VerifyStr = [C || C <- lists:flatten(Data2), C/=$ , C/=$\r, C/=$\n, C/=$>], -- cgit v1.2.3