aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test/prim_file_SUITE.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-02-12 14:30:13 +0100
committerBjörn Gustavsson <[email protected]>2013-02-12 14:30:13 +0100
commitcd08400f92ec7672025bf39a458effcf33a423dc (patch)
treeb874f8c3fe97558d72dcaedc31dd941060ccea75 /lib/kernel/test/prim_file_SUITE.erl
parentbbf692965470a9e993e1afd6f1a9375cbe832fcb (diff)
parent08bc8a328275e751836fab0c562b50cf71000c2b (diff)
downloadotp-cd08400f92ec7672025bf39a458effcf33a423dc.tar.gz
otp-cd08400f92ec7672025bf39a458effcf33a423dc.tar.bz2
otp-cd08400f92ec7672025bf39a458effcf33a423dc.zip
Merge branch 'pan/unicode_filename_warnings'
* pan/unicode_filename_warnings: Add file:list_dir_all/1 and file:read_link_all/1 prim_file: Add list_dir_all() and read_link_all() Teach prim_file:set_cwd() to avoid entering non-translatable directories Make prim_file skip invalid filenames in unicode mode prim_file: Refactor functions that return filenames prim_file: Refactor handling of responses prim_file: Always open non-file ports in binary mode Test that list_dir("non-existing-dir") fails with the correct error
Diffstat (limited to 'lib/kernel/test/prim_file_SUITE.erl')
-rw-r--r--lib/kernel/test/prim_file_SUITE.erl45
1 files changed, 42 insertions, 3 deletions
diff --git a/lib/kernel/test/prim_file_SUITE.erl b/lib/kernel/test/prim_file_SUITE.erl
index 4e93a593b3..4550cb1770 100644
--- a/lib/kernel/test/prim_file_SUITE.erl
+++ b/lib/kernel/test/prim_file_SUITE.erl
@@ -49,7 +49,9 @@
make_link_a/1, make_link_b/1,
read_link_info_for_non_link/1,
symlinks_a/1, symlinks_b/1,
- list_dir_limit/1]).
+ list_dir_limit/1,
+ list_dir_error/1,
+ list_dir/1]).
-export([advise/1]).
-export([large_write/1]).
@@ -81,7 +83,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[read_write_file, {group, dirs}, {group, files},
delete_a, delete_b, rename_a, rename_b, {group, errors},
- {group, compression}, {group, links}, list_dir_limit].
+ {group, compression}, {group, links}, list_dir_limit, list_dir].
groups() ->
[{dirs, [],
@@ -110,7 +112,7 @@ groups() ->
write_compressed, compress_errors]},
{links, [],
[make_link_a, make_link_b, read_link_info_for_non_link,
- symlinks_a, symlinks_b]}].
+ symlinks_a, symlinks_b, list_dir_error]}].
init_per_group(_GroupName, Config) ->
Config.
@@ -2035,6 +2037,8 @@ symlinks(Config, Handle, Suffix) ->
?line #file_info{links=1, type=symlink} = Info2,
?line {ok, Name} =
?PRIM_FILE_call(read_link, Handle, [Alias]),
+ {ok, Name} =
+ ?PRIM_FILE_call(read_link_all, Handle, [Alias]),
ok
end,
@@ -2140,6 +2144,41 @@ list_dir_limit_cleanup(Dir, Handle, N, Cnt) ->
list_dir_limit_cleanup(Dir, Handle, N, Cnt+1).
%%%
+%%% Test list_dir() on a non-existing pathname.
+%%%
+
+list_dir_error(Config) ->
+ Priv = ?config(priv_dir, Config),
+ NonExisting = filename:join(Priv, "non-existing-dir"),
+ {error,enoent} = prim_file:list_dir(NonExisting),
+ ok.
+
+%%%
+%%% Test list_dir() and list_dir_all().
+%%%
+
+list_dir(Config) ->
+ RootDir = ?config(priv_dir, Config),
+ TestDir = filename:join(RootDir, ?MODULE_STRING++"_list_dir"),
+ ?PRIM_FILE:make_dir(TestDir),
+ list_dir_1(TestDir, 42, []).
+
+list_dir_1(TestDir, 0, Sorted) ->
+ [ok = ?PRIM_FILE:delete(filename:join(TestDir, F)) ||
+ F <- Sorted],
+ ok = ?PRIM_FILE:del_dir(TestDir);
+list_dir_1(TestDir, Cnt, Sorted0) ->
+ Base = "file" ++ integer_to_list(Cnt),
+ Name = filename:join(TestDir, Base),
+ ok = ?PRIM_FILE:write_file(Name, Base),
+ Sorted = lists:merge([Base], Sorted0),
+ {ok,DirList0} = ?PRIM_FILE:list_dir(TestDir),
+ {ok,DirList1} = ?PRIM_FILE:list_dir_all(TestDir),
+ Sorted = lists:sort(DirList0),
+ Sorted = lists:sort(DirList1),
+ list_dir_1(TestDir, Cnt-1, Sorted).
+
+%%%
%%% Support for testing large files.
%%%