diff options
author | Lukas Larsson <[email protected]> | 2014-11-26 11:11:01 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2014-11-26 11:11:01 +0100 |
commit | 4192870b70ec65ddb13ae876f32fb211ec8ff29d (patch) | |
tree | 05fe21ca6c6d6d3c83c95a462c46d281fe524656 /lib/kernel/test/file_SUITE.erl | |
parent | 6d6048d997e60fcfa6a0e07d010cbf605738ad40 (diff) | |
parent | 33ef9019afb4cd268d5c9e54e63e428630686d63 (diff) | |
download | otp-4192870b70ec65ddb13ae876f32fb211ec8ff29d.tar.gz otp-4192870b70ec65ddb13ae876f32fb211ec8ff29d.tar.bz2 otp-4192870b70ec65ddb13ae876f32fb211ec8ff29d.zip |
Merge branch 'maint'
* maint:
kernel: Do not check unsync:ed file size
Introduce new option 'raw' in file_info functions
Diffstat (limited to 'lib/kernel/test/file_SUITE.erl')
-rw-r--r-- | lib/kernel/test/file_SUITE.erl | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/lib/kernel/test/file_SUITE.erl b/lib/kernel/test/file_SUITE.erl index f6d6cd94ab..56c35678b6 100644 --- a/lib/kernel/test/file_SUITE.erl +++ b/lib/kernel/test/file_SUITE.erl @@ -1236,9 +1236,10 @@ file_info_basic_file(Config) when is_list(Config) -> %% Test that the file has the expected attributes. %% The times are tricky, so we will save them to a separate test case. - ?line {ok,#file_info{size=Size,type=Type,access=Access, - atime=AccessTime,mtime=ModifyTime}} = - ?FILE_MODULE:read_file_info(Name), + {ok,FileInfo} = ?FILE_MODULE:read_file_info(Name), + {ok,FileInfo} = ?FILE_MODULE:read_file_info(Name, [raw]), + #file_info{size=Size,type=Type,access=Access, + atime=AccessTime,mtime=ModifyTime} = FileInfo, ?line io:format("Access ~p, Modify ~p", [AccessTime, ModifyTime]), ?line Size = 7, ?line Type = regular, @@ -1280,9 +1281,10 @@ file_info_basic_directory(Config) when is_list(Config) -> test_server:timetrap_cancel(Dog). test_directory(Name, ExpectedAccess) -> - ?line {ok,#file_info{size=Size,type=Type,access=Access, - atime=AccessTime,mtime=ModifyTime}} = - ?FILE_MODULE:read_file_info(Name), + {ok,FileInfo} = ?FILE_MODULE:read_file_info(Name), + {ok,FileInfo} = ?FILE_MODULE:read_file_info(Name, [raw]), + #file_info{size=Size,type=Type,access=Access, + atime=AccessTime,mtime=ModifyTime} = FileInfo, ?line io:format("Testing directory ~s", [Name]), ?line io:format("Directory size is ~p", [Size]), ?line io:format("Access ~p", [Access]), @@ -1307,11 +1309,11 @@ file_info_bad(doc) -> []; file_info_bad(Config) when is_list(Config) -> ?line Dog = test_server:timetrap(test_server:seconds(5)), ?line RootDir = filename:join([?config(priv_dir, Config)]), - ?line {error, enoent} = - ?FILE_MODULE:read_file_info( - filename:join(RootDir, - atom_to_list(?MODULE)++ "_nonexistent")), + FileName = filename:join(RootDir, atom_to_list(?MODULE) ++ "_nonexistent"), + {error,enoent} = ?FILE_MODULE:read_file_info(FileName), + {error,enoent} = ?FILE_MODULE:read_file_info(FileName, [raw]), ?line {error, enoent} = ?FILE_MODULE:read_file_info(""), + {error, enoent} = ?FILE_MODULE:read_file_info("", [raw]), ?line [] = flush(), ?line test_server:timetrap_cancel(Dog), ok. @@ -1346,8 +1348,16 @@ file_info_int(Config) -> ?line io:put_chars(Fd1,"foo"), %% check that the file got a modify date max a few seconds away from now - ?line {ok,#file_info{type=regular,atime=AccTime1,mtime=ModTime1}} = - ?FILE_MODULE:read_file_info(Name), + {ok,FileInfo1} = ?FILE_MODULE:read_file_info(Name), + {ok,FileInfo1Raw} = ?FILE_MODULE:read_file_info(Name, [raw]), + + %% We assert that everything but the size is the same, on some OSs the + %% size may not have been flushed to disc and we do not want to do a + %% sync to force it. + FileInfo1Raw = FileInfo1#file_info{ size = FileInfo1Raw#file_info.size }, + + #file_info{type=regular,atime=AccTime1,mtime=ModTime1} = FileInfo1, + ?line Now = erlang:localtime(), %??? ?line io:format("Now ~p",[Now]), ?line io:format("Open file Acc ~p Mod ~p",[AccTime1,ModTime1]), @@ -1363,9 +1373,10 @@ file_info_int(Config) -> %% close the file, and watch the modify date change ?line ok = ?FILE_MODULE:close(Fd1), - ?line {ok,#file_info{size=Size,type=regular,access=Access, - atime=AccTime2,mtime=ModTime2}} = - ?FILE_MODULE:read_file_info(Name), + {ok,FileInfo2} = ?FILE_MODULE:read_file_info(Name), + {ok,FileInfo2} = ?FILE_MODULE:read_file_info(Name, [raw]), + #file_info{size=Size,type=regular,access=Access, + atime=AccTime2,mtime=ModTime2} = FileInfo2, ?line io:format("Closed file Acc ~p Mod ~p",[AccTime2,ModTime2]), ?line true = time_dist(ModTime1,ModTime2) >= 0, @@ -1374,9 +1385,10 @@ file_info_int(Config) -> ?line Access = read_write, %% Do some directory checking - ?line {ok,#file_info{size=DSize,type=directory,access=DAccess, - atime=AccTime3,mtime=ModTime3}} = - ?FILE_MODULE:read_file_info(RootDir), + {ok,FileInfo3} = ?FILE_MODULE:read_file_info(RootDir), + {ok,FileInfo3} = ?FILE_MODULE:read_file_info(RootDir, [raw]), + #file_info{size=DSize,type=directory,access=DAccess, + atime=AccTime3,mtime=ModTime3} = FileInfo3, %% this dir was modified only a few secs ago ?line io:format("Dir Acc ~p; Mod ~p; Now ~p", [AccTime3, ModTime3, Now]), ?line true = abs(time_dist(Now,ModTime3)) < 5, @@ -1449,6 +1461,12 @@ file_write_file_info(Config) when is_list(Config) -> ?line ?FILE_MODULE:write_file_info(Name1, #file_info{mode=8#400}), ?line {error, eacces} = ?FILE_MODULE:write_file(Name1, "hello again"), + %% Same with raw. + ?FILE_MODULE:write_file_info(Name1, #file_info{mode=8#600}, [raw]), + ok = ?FILE_MODULE:write_file(Name1, "hello again"), + ?FILE_MODULE:write_file_info(Name1, #file_info{mode=8#400}, [raw]), + {error,eacces} = ?FILE_MODULE:write_file(Name1, "hello again"), + %% Write the times again. %% Note: Seconds must be even; see note in file_info_times/1. @@ -2650,7 +2668,9 @@ make_link(Config) when is_list(Config) -> %% since they are not used on symbolic links. ?line {ok, Info} = ?FILE_MODULE:read_link_info(Name), + {ok,Info} = ?FILE_MODULE:read_link_info(Name, [raw]), ?line {ok, Info} = ?FILE_MODULE:read_link_info(Alias), + {ok,Info} = ?FILE_MODULE:read_link_info(Alias, [raw]), ?line #file_info{links = 2, type = regular} = Info, ?line {error, eexist} = ?FILE_MODULE:make_link(Name, Alias), @@ -2670,6 +2690,7 @@ read_link_info_for_non_link(Config) when is_list(Config) -> ?line {ok, #file_info{type=directory}} = ?FILE_MODULE:read_link_info("."), + {ok, #file_info{type=directory}} = ?FILE_MODULE:read_link_info(".", [raw]), ?line [] = flush(), ?line test_server:timetrap_cancel(Dog), @@ -2700,11 +2721,15 @@ symlinks(Config) when is_list(Config) -> {skipped, "Windows user not privileged to create symlinks"}; ok -> ?line {ok, Info1} = ?FILE_MODULE:read_file_info(Name), + {ok,Info1} = ?FILE_MODULE:read_file_info(Name, [raw]), ?line {ok, Info1} = ?FILE_MODULE:read_file_info(Alias), + {ok,Info1} = ?FILE_MODULE:read_file_info(Alias, [raw]), ?line {ok, Info1} = ?FILE_MODULE:read_link_info(Name), + {ok,Info1} = ?FILE_MODULE:read_link_info(Name, [raw]), ?line #file_info{links = 1, type = regular} = Info1, ?line {ok, Info2} = ?FILE_MODULE:read_link_info(Alias), + {ok,Info2} = ?FILE_MODULE:read_link_info(Alias, [raw]), ?line #file_info{links=1, type=symlink} = Info2, ?line {ok, Name} = ?FILE_MODULE:read_link(Alias), {ok, Name} = ?FILE_MODULE:read_link_all(Alias), |