aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test/prim_file_SUITE.erl
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2011-05-12 16:32:29 +0200
committerPatrik Nyblom <[email protected]>2011-05-12 16:32:29 +0200
commitaa600acf183923a17b6544c9ffdb8d90bda01810 (patch)
treefbfc8c3fa4a3c2d9a9673eb5a22b73507e772304 /lib/kernel/test/prim_file_SUITE.erl
parenteb26a54528e824f8f08af49d47281201bd8fefe3 (diff)
downloadotp-aa600acf183923a17b6544c9ffdb8d90bda01810.tar.gz
otp-aa600acf183923a17b6544c9ffdb8d90bda01810.tar.bz2
otp-aa600acf183923a17b6544c9ffdb8d90bda01810.zip
Teach (prim_)file_SUITE about directory access on Windows
Diffstat (limited to 'lib/kernel/test/prim_file_SUITE.erl')
-rw-r--r--lib/kernel/test/prim_file_SUITE.erl74
1 files changed, 42 insertions, 32 deletions
diff --git a/lib/kernel/test/prim_file_SUITE.erl b/lib/kernel/test/prim_file_SUITE.erl
index a04ea3cdcd..f83e6b24e6 100644
--- a/lib/kernel/test/prim_file_SUITE.erl
+++ b/lib/kernel/test/prim_file_SUITE.erl
@@ -250,39 +250,49 @@ make_del_dir(Config, Handle, Suffix) ->
?line ok = ?PRIM_FILE_call(del_dir, Handle, [NewDir]),
?line {error, enoent} = ?PRIM_FILE_call(del_dir, Handle, [NewDir]),
- %% Check that we get an error when trying to create...
- %% a deep directory
- ?line NewDir2 = filename:join(RootDir,
- atom_to_list(?MODULE)
- ++"_mk-dir/foo"),
- ?line {error, enoent} = ?PRIM_FILE_call(make_dir, Handle, [NewDir2]),
- %% a nameless directory
- ?line {error, enoent} = ?PRIM_FILE_call(make_dir, Handle, [""]),
- %% a directory with illegal name
- ?line {error, badarg} = ?PRIM_FILE_call(make_dir, Handle, ['mk-dir']),
-
- %% a directory with illegal name, even if it's a (bad) list
- ?line {error, badarg} = ?PRIM_FILE_call(make_dir, Handle, [[1,2,3,{}]]),
-
- %% Maybe this isn't an error, exactly, but worth mentioning anyway:
- %% ok = ?PRIM_FILE:make_dir([$f,$o,$o,0,$b,$a,$r])),
- %% The above line works, and created a directory "./foo"
- %% More elegant would maybe have been to fail, or to really create
- %% a directory, but with a name that incorporates the "bar" part of
- %% the list, so that [$f,$o,$o,0,$f,$o,$o] wouldn't refer to the same
- %% dir. But this would slow it down.
-
- %% Try deleting some bad directories
- %% Deleting the parent directory to the current, sounds dangerous, huh?
- %% Don't worry ;-) the parent directory should never be empty, right?
- case ?PRIM_FILE_call(del_dir, Handle, [".."]) of
- {error, eexist} -> ok;
- {error, einval} -> ok %FreeBSD
+ % Make sure we are not in a directory directly under test_server
+ % as that would result in eacess errors when trying to delere '..',
+ % because there are processes having that directory as current.
+ ?line ok = ?PRIM_FILE_call(make_dir, Handle, [NewDir]),
+ ?line {ok, CurrentDir} = ?PRIM_FILE_call(get_cwd, Handle, []),
+ ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [NewDir]),
+ try
+ %% Check that we get an error when trying to create...
+ %% a deep directory
+ ?line NewDir2 = filename:join(RootDir,
+ atom_to_list(?MODULE)
+ ++"_mk-dir/foo"),
+ ?line {error, enoent} = ?PRIM_FILE_call(make_dir, Handle, [NewDir2]),
+ %% a nameless directory
+ ?line {error, enoent} = ?PRIM_FILE_call(make_dir, Handle, [""]),
+ %% a directory with illegal name
+ ?line {error, badarg} = ?PRIM_FILE_call(make_dir, Handle, ['mk-dir']),
+
+ %% a directory with illegal name, even if it's a (bad) list
+ ?line {error, badarg} = ?PRIM_FILE_call(make_dir, Handle, [[1,2,3,{}]]),
+
+ %% Maybe this isn't an error, exactly, but worth mentioning anyway:
+ %% ok = ?PRIM_FILE:make_dir([$f,$o,$o,0,$b,$a,$r])),
+ %% The above line works, and created a directory "./foo"
+ %% More elegant would maybe have been to fail, or to really create
+ %% a directory, but with a name that incorporates the "bar" part of
+ %% the list, so that [$f,$o,$o,0,$f,$o,$o] wouldn't refer to the same
+ %% dir. But this would slow it down.
+
+ %% Try deleting some bad directories
+ %% Deleting the parent directory to the current, sounds dangerous, huh?
+ %% Don't worry ;-) the parent directory should never be empty, right?
+ ?line case ?PRIM_FILE_call(del_dir, Handle, [".."]) of
+ {error, eexist} -> ok;
+ {error, einval} -> ok %FreeBSD
+ end,
+ ?line {error, enoent} = ?PRIM_FILE_call(del_dir, Handle, [""]),
+ ?line {error, badarg} = ?PRIM_FILE_call(del_dir, Handle, [[3,2,1,{}]]),
+
+ ?line test_server:timetrap_cancel(Dog)
+ after
+ ?line ok = ?PRIM_FILE_call(set_cwd, Handle, [CurrentDir])
end,
- ?line {error, enoent} = ?PRIM_FILE_call(del_dir, Handle, [""]),
- ?line {error, badarg} = ?PRIM_FILE_call(del_dir, Handle, [[3,2,1,{}]]),
-
- ?line test_server:timetrap_cancel(Dog),
ok.
cur_dir_0a(suite) -> [];