aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2017-10-13 11:47:41 +0200
committerJohn Högberg <[email protected]>2017-11-30 15:44:36 +0100
commit072a991bc2eafb283cd25eaad1f4fd2f70c0f8b9 (patch)
tree74a1490284c08fd9c215b71c2162f4e9302a6a94
parent925b2a298875aef850cd4d78861aca82cf521d04 (diff)
downloadotp-072a991bc2eafb283cd25eaad1f4fd2f70c0f8b9.tar.gz
otp-072a991bc2eafb283cd25eaad1f4fd2f70c0f8b9.tar.bz2
otp-072a991bc2eafb283cd25eaad1f4fd2f70c0f8b9.zip
Reads that draw from both buffer and file must work
-rw-r--r--lib/kernel/test/file_SUITE.erl10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/kernel/test/file_SUITE.erl b/lib/kernel/test/file_SUITE.erl
index 6139d2161e..3cb249c565 100644
--- a/lib/kernel/test/file_SUITE.erl
+++ b/lib/kernel/test/file_SUITE.erl
@@ -3161,6 +3161,16 @@ read_ahead(Config) when is_list(Config) ->
Data1Data2Data3 = Data1++Data2++Data3,
{ok, Data1Data2Data3} = ?FILE_MODULE:read(Fd5, 3*Size+1),
ok = ?FILE_MODULE:close(Fd5),
+
+ %% Ensure that a read that draws from both the buffer and the file won't
+ %% return anything wonky.
+ SplitData = << <<(I rem 256)>> || I <- lists:seq(1, 1024) >>,
+ file:write_file(File, SplitData),
+ {ok, Fd6} = ?FILE_MODULE:open(File, [raw, read, binary, {read_ahead, 256}]),
+ {ok, <<1>>} = file:read(Fd6, 1),
+ <<1, Shifted:512/binary, _Rest/binary>> = SplitData,
+ {ok, Shifted} = file:read(Fd6, 512),
+
%%
[] = flush(),
ok.