diff options
author | Erlang/OTP <[email protected]> | 2017-05-11 17:41:19 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2017-05-11 17:41:19 +0200 |
commit | a644cd89c84dc93eb3a1840c32ab2b1d0dd5f768 (patch) | |
tree | 229d0fc8e6be787e97e5de6f9010108b1f11e69b /lib/inets/test/ftp_SUITE.erl | |
parent | 3c667750d16cd25f4b47fa230475050cb345fd8a (diff) | |
parent | 98a9c17063097865d7bf2f69e19f1ab85d1cc180 (diff) | |
download | otp-a644cd89c84dc93eb3a1840c32ab2b1d0dd5f768.tar.gz otp-a644cd89c84dc93eb3a1840c32ab2b1d0dd5f768.tar.bz2 otp-a644cd89c84dc93eb3a1840c32ab2b1d0dd5f768.zip |
Merge branch 'hans/inets/ftp_recv_chunk_close/OTP-14391' into maint-19
* hans/inets/ftp_recv_chunk_close/OTP-14391:
inets: add testcase to ftp_SUITE Try doing three consecutive chunked receive with some changed timing in the ending sequence
inets: Try fix ftp recv_chunk timing issue
Diffstat (limited to 'lib/inets/test/ftp_SUITE.erl')
-rw-r--r-- | lib/inets/test/ftp_SUITE.erl | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/lib/inets/test/ftp_SUITE.erl b/lib/inets/test/ftp_SUITE.erl index d37f2feb7e..1a79cb58ed 100644 --- a/lib/inets/test/ftp_SUITE.erl +++ b/lib/inets/test/ftp_SUITE.erl @@ -97,6 +97,7 @@ ftp_tests()-> recv_bin_twice, recv_chunk, recv_chunk_twice, + recv_chunk_three_times, type, quote, error_elogin, @@ -626,13 +627,57 @@ recv_chunk_twice(Config0) -> find_diff(ReceivedContents1, Contents1), find_diff(ReceivedContents2, Contents2). +recv_chunk_three_times() -> + [{doc, "Receive two files using chunk-wise."}, + {timetrap,{seconds,120}}]. +recv_chunk_three_times(Config0) -> + File1 = "big_file1.txt", + File2 = "big_file2.txt", + File3 = "big_file3.txt", + Contents1 = list_to_binary( lists:duplicate(1000, lists:seq(0,255)) ), + Contents2 = crypto:strong_rand_bytes(1200), + Contents3 = list_to_binary( lists:duplicate(1000, lists:seq(255,0,-1)) ), + + Config = set_state([reset, {mkfile,File1,Contents1}, {mkfile,File2,Contents2}, {mkfile,File3,Contents3}], Config0), + Pid = proplists:get_value(ftp, Config), + {{error, "ftp:recv_chunk_start/2 not called"},_} = recv_chunk(Pid, <<>>), + + ok = ftp:recv_chunk_start(Pid, id2ftp(File1,Config)), + {ok, ReceivedContents1, Nchunks1} = recv_chunk(Pid, <<>>), + + ok = ftp:recv_chunk_start(Pid, id2ftp(File2,Config)), + {ok, ReceivedContents2, _Nchunks2} = recv_chunk(Pid, <<>>), + + ok = ftp:recv_chunk_start(Pid, id2ftp(File3,Config)), + {ok, ReceivedContents3, _Nchunks3} = recv_chunk(Pid, <<>>, 10000, 0, Nchunks1), + + find_diff(ReceivedContents1, Contents1), + find_diff(ReceivedContents2, Contents2), + find_diff(ReceivedContents3, Contents3). + + + recv_chunk(Pid, Acc) -> - recv_chunk(Pid, Acc, 0). + recv_chunk(Pid, Acc, 0, 0, undefined). + + + +%% ExpectNchunks :: integer() | undefined +recv_chunk(Pid, Acc, DelayMilliSec, N, ExpectNchunks) when N+1 < ExpectNchunks -> + %% for all I in integer(), I < undefined + recv_chunk1(Pid, Acc, DelayMilliSec, N, ExpectNchunks); + +recv_chunk(Pid, Acc, DelayMilliSec, N, ExpectNchunks) -> + %% N >= ExpectNchunks-1 + timer:sleep(DelayMilliSec), + recv_chunk1(Pid, Acc, DelayMilliSec, N, ExpectNchunks). + -recv_chunk(Pid, Acc, N) -> +recv_chunk1(Pid, Acc, DelayMilliSec, N, ExpectNchunks) -> + ct:log("Call ftp:recv_chunk",[]), case ftp:recv_chunk(Pid) of ok -> {ok, Acc, N}; - {ok, Bin} -> recv_chunk(Pid, <<Acc/binary, Bin/binary>>, N+1); + {ok, Bin} -> recv_chunk(Pid, <<Acc/binary, Bin/binary>>, DelayMilliSec, N+1, ExpectNchunks); Error -> {Error, N} end. |