aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/filelib_SUITE.erl
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2014-07-01 00:58:26 +0200
committerSiri Hansen <[email protected]>2014-07-09 14:57:11 +0200
commitde2fb97f15ac98aa1d1c5533aacca378334f4778 (patch)
treeda2c0c88479b4bbcdbfe04b1de8632627831bf3e /lib/stdlib/test/filelib_SUITE.erl
parentc9e36ab16034bb7fe71f772df6bba22070976bbf (diff)
downloadotp-de2fb97f15ac98aa1d1c5533aacca378334f4778.tar.gz
otp-de2fb97f15ac98aa1d1c5533aacca378334f4778.tar.bz2
otp-de2fb97f15ac98aa1d1c5533aacca378334f4778.zip
Fix handling of broken symlinks in filelib
This fixes a bug introduced in f11aabdc9fec593c31e6c4f3fa25c1707e9c35df where filelib:eval_read_file_info/2 was made to use file:read_link_info/1 to never follow symlinks. This fixed wildcard/1 but broke every other function using eval_read_file_info/2. Reported-by: Louis-Philippe Gauthier Reported-by: Danil Zagoskin
Diffstat (limited to 'lib/stdlib/test/filelib_SUITE.erl')
-rw-r--r--lib/stdlib/test/filelib_SUITE.erl25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/stdlib/test/filelib_SUITE.erl b/lib/stdlib/test/filelib_SUITE.erl
index 8203a03a7a..f1a072194a 100644
--- a/lib/stdlib/test/filelib_SUITE.erl
+++ b/lib/stdlib/test/filelib_SUITE.erl
@@ -23,7 +23,8 @@
init_per_group/2,end_per_group/2,
init_per_testcase/2,end_per_testcase/2,
wildcard_one/1,wildcard_two/1,wildcard_errors/1,
- fold_files/1,otp_5960/1,ensure_dir_eexist/1,symlinks/1]).
+ fold_files/1,otp_5960/1,ensure_dir_eexist/1,ensure_dir_symlink/1,
+ symlinks/1]).
-import(lists, [foreach/2]).
@@ -43,7 +44,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[wildcard_one, wildcard_two, wildcard_errors,
- fold_files, otp_5960, ensure_dir_eexist, symlinks].
+ fold_files, otp_5960, ensure_dir_eexist, ensure_dir_symlink, symlinks].
groups() ->
[].
@@ -367,6 +368,26 @@ ensure_dir_eexist(Config) when is_list(Config) ->
?line {error, eexist} = filelib:ensure_dir(NeedFileB),
ok.
+ensure_dir_symlink(Config) when is_list(Config) ->
+ PrivDir = ?config(priv_dir, Config),
+ Dir = filename:join(PrivDir, "ensure_dir_symlink"),
+ Name = filename:join(Dir, "same_name_as_file_and_dir"),
+ ok = filelib:ensure_dir(Name),
+ ok = file:write_file(Name, <<"some string\n">>),
+ %% With a symlink to the directory.
+ Symlink = filename:join(PrivDir, "ensure_dir_symlink_link"),
+ case file:make_symlink(Dir, Symlink) of
+ {error,enotsup} ->
+ {skip,"Symlinks not supported on this platform"};
+ {error,eperm} ->
+ {win32,_} = os:type(),
+ {skip,"Windows user not privileged to create symlinks"};
+ ok ->
+ SymlinkedName = filename:join(Symlink, "same_name_as_file_and_dir"),
+ ok = filelib:ensure_dir(SymlinkedName)
+ end.
+
+
symlinks(Config) when is_list(Config) ->
PrivDir = ?config(priv_dir, Config),
Dir = filename:join(PrivDir, ?MODULE_STRING++"_symlinks"),