aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/test/tftp_SUITE.erl
diff options
context:
space:
mode:
authorMichael Santos <[email protected]>2016-02-12 10:59:36 -0500
committerMichael Santos <[email protected]>2016-02-12 11:09:22 -0500
commitdda67a46e848196fc8603e696a1e2dd55b69e75b (patch)
tree45b151cd5736471e1a96a23f5515e1ab779e6166 /lib/inets/test/tftp_SUITE.erl
parent439292ad4afe73243852fe79d5d467c325f382bf (diff)
downloadotp-dda67a46e848196fc8603e696a1e2dd55b69e75b.tar.gz
otp-dda67a46e848196fc8603e696a1e2dd55b69e75b.tar.bz2
otp-dda67a46e848196fc8603e696a1e2dd55b69e75b.zip
tftp: support transfer of files > 65535 blocks
The block count is an unsigned 2 byte integer. The common behaviour of tftp clients and servers is to overflow the block count and wrap the counter to 0 in order to support files larger than 32M. Modify the tftp implementation to do the same rollover. Interoperability was tested by transferring a 1.4G file using the HPA tftp client.
Diffstat (limited to 'lib/inets/test/tftp_SUITE.erl')
-rw-r--r--lib/inets/test/tftp_SUITE.erl37
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/inets/test/tftp_SUITE.erl b/lib/inets/test/tftp_SUITE.erl
index d29d210d7d..497a50e654 100644
--- a/lib/inets/test/tftp_SUITE.erl
+++ b/lib/inets/test/tftp_SUITE.erl
@@ -76,7 +76,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[simple, extra, reuse_connection, resend_client,
- resend_server].
+ resend_server, large_file].
groups() ->
[].
@@ -902,6 +902,41 @@ reuse_connection(Config) when is_list(Config) ->
ok.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Large file: transfer > 65535 blocks
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+large_file(doc) ->
+ ["Start the daemon and test transfer of files greater than 32M."];
+large_file(suite) ->
+ [];
+large_file(Config) when is_list(Config) ->
+ ?VERIFY(ok, application:start(inets)),
+
+ {Port, DaemonPid} = ?IGNORE(?START_DAEMON(0, [{debug, brief}])),
+
+ %% Read fail
+ RemoteFilename = "tftp_temporary_large_file_remote_test_file.txt",
+ LocalFilename = "tftp_temporary_large_file_local_test_file.txt",
+
+ {ok, FH} = file:open(LocalFilename, [write,exclusive]),
+ {ok, Size} = file:position(FH, {eof, 2*512*65535}),
+ ok = file:truncate(FH),
+ ?IGNORE(file:close(FH)),
+
+ %% Write and read
+ ?VERIFY({ok, Size}, tftp:write_file(RemoteFilename, LocalFilename, [{port, Port}])),
+ ?IGNORE(file:delete(LocalFilename)),
+ ?VERIFY({ok, Size}, tftp:read_file(RemoteFilename, LocalFilename, [{port, Port}])),
+
+ %% Cleanup
+ unlink(DaemonPid),
+ exit(DaemonPid, kill),
+ ?VERIFY(ok, file:delete(LocalFilename)),
+ ?VERIFY(ok, file:delete(RemoteFilename)),
+ ?VERIFY(ok, application:stop(inets)),
+ ok.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Goodies
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%