aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorZandra Hird <[email protected]>2015-03-17 12:44:31 +0100
committerZandra Hird <[email protected]>2015-03-17 12:44:50 +0100
commit94c86eb6325248e76156ba6d31882576b93d242f (patch)
tree40cb066e07e3baf3d2b1358bfd775c1a279ce9f5 /lib/stdlib/test
parentf991b0bb0ce200967f73b4d6505956a56e358b21 (diff)
parent3ec48aa1782af3b4d84d9bad8129127c2b9f4b9d (diff)
downloadotp-94c86eb6325248e76156ba6d31882576b93d242f.tar.gz
otp-94c86eb6325248e76156ba6d31882576b93d242f.tar.bz2
otp-94c86eb6325248e76156ba6d31882576b93d242f.zip
Merge branch 'danielwhite/zip-port-leak-fix'
OTP-12566 * danielwhite/zip-port-leak-fix: Describe zip handles an opaque type Document the termination semantics of a zip handle Prevent zip:zip_open/1,2 from leaking ports
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/zip_SUITE.erl42
1 files changed, 40 insertions, 2 deletions
diff --git a/lib/stdlib/test/zip_SUITE.erl b/lib/stdlib/test/zip_SUITE.erl
index a57641ef62..d168a9d9bc 100644
--- a/lib/stdlib/test/zip_SUITE.erl
+++ b/lib/stdlib/test/zip_SUITE.erl
@@ -23,7 +23,7 @@
bad_zip/1, unzip_from_binary/1, unzip_to_binary/1,
zip_to_binary/1,
unzip_options/1, zip_options/1, list_dir_options/1, aliases/1,
- openzip_api/1, zip_api/1, unzip_jar/1,
+ openzip_api/1, zip_api/1, open_leak/1, unzip_jar/1,
compress_control/1,
foldl/1]).
@@ -38,7 +38,7 @@ all() ->
[borderline, atomic, bad_zip, unzip_from_binary,
unzip_to_binary, zip_to_binary, unzip_options,
zip_options, list_dir_options, aliases, openzip_api,
- zip_api, unzip_jar, compress_control, foldl].
+ zip_api, open_leak, unzip_jar, compress_control, foldl].
groups() ->
[].
@@ -318,8 +318,46 @@ zip_api(Config) when is_list(Config) ->
%% Clean up.
delete_files([Names]),
+ ok.
+
+open_leak(doc) ->
+ ["Test that zip doesn't leak processes and ports where the "
+ "controlling process dies without closing an zip opened with "
+ "zip:zip_open/1."];
+open_leak(suite) -> [];
+open_leak(Config) when is_list(Config) ->
+ %% Create a zip archive
+ Zip = "zip.zip",
+ {ok, Zip} = zip:zip(Zip, [], []),
+
+ %% Open archive in a another process that dies immediately.
+ ZipSrv = spawn_zip(Zip, [memory]),
+
+ %% Expect the ZipSrv process to die soon after.
+ true = spawned_zip_dead(ZipSrv),
+
+ %% Clean up.
+ delete_files([Zip]),
+
ok.
+spawn_zip(Zip, Options) ->
+ Self = self(),
+ spawn(fun() -> Self ! zip:zip_open(Zip, Options) end),
+ receive
+ {ok, ZipSrv} ->
+ ZipSrv
+ end.
+
+spawned_zip_dead(ZipSrv) ->
+ Ref = monitor(process, ZipSrv),
+ receive
+ {'DOWN', Ref, _, ZipSrv, _} ->
+ true
+ after 1000 ->
+ false
+ end.
+
unzip_options(doc) ->
["Test options for unzip, only cwd and file_list currently"];
unzip_options(suite) ->