diff options
author | Björn Gustavsson <[email protected]> | 2015-08-18 13:48:27 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-09-07 10:35:31 +0200 |
commit | 3923364687edcc8704f921a425910be856a0c879 (patch) | |
tree | 8f71231752a9780a18998d56e4448f5b27d310f2 /lib/sasl | |
parent | 1afcce230bc62c04bc6ff7b105bf33be770fea29 (diff) | |
download | otp-3923364687edcc8704f921a425910be856a0c879.tar.gz otp-3923364687edcc8704f921a425910be856a0c879.tar.bz2 otp-3923364687edcc8704f921a425910be856a0c879.zip |
sasl_SUITE: Correct the log_file/1 test case
The test case did not test the log files were created. And they
were not created, because filelib:ensure_dir/1 was used
incorrectly.
Diffstat (limited to 'lib/sasl')
-rw-r--r-- | lib/sasl/test/sasl_SUITE.erl | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/lib/sasl/test/sasl_SUITE.erl b/lib/sasl/test/sasl_SUITE.erl index 1d76cdee6e..d73cce3c44 100644 --- a/lib/sasl/test/sasl_SUITE.erl +++ b/lib/sasl/test/sasl_SUITE.erl @@ -182,20 +182,40 @@ log_mf_h_env(Config) -> log_file(Config) -> PrivDir = ?config(priv_dir,Config), LogDir = filename:join(PrivDir,sasl_SUITE_log_dir), - ok = filelib:ensure_dir(LogDir), File = filename:join(LogDir, "file.log"), + ok = filelib:ensure_dir(File), application:stop(sasl), clear_env(sasl), - ok = application:set_env(sasl,sasl_error_logger,{file, File}, [{persistent, true}]), - ok = application:start(sasl), - application:stop(sasl), - ok = application:set_env(sasl,sasl_error_logger,{file, File, [append]}, [{persistent, true}]), - ok = application:start(sasl), - application:stop(sasl), - ok = application:set_env(sasl,sasl_error_logger, tty, [{persistent, false}]), + _ = test_log_file(File, {file,File}), + _ = test_log_file(File, {file,File,[write]}), + + ok = file:write_file(File, <<"=PROGRESS preserve me\n">>), + <<"=PROGRESS preserve me\n",_/binary>> = + test_log_file(File, {file,File,[append]}), + + ok = application:set_env(sasl,sasl_error_logger, tty, + [{persistent, false}]), ok = application:start(sasl). +test_log_file(File, Arg) -> + ok = application:set_env(sasl, sasl_error_logger, Arg, + [{persistent, true}]), + ok = application:start(sasl), + application:stop(sasl), + {ok,Bin} = file:read_file(File), + ok = file:delete(File), + Lines0 = binary:split(Bin, <<"\n">>, [trim_all,global]), + Lines = [L || L <- Lines0, + binary:match(L, <<"=PROGRESS">>) =:= {0,9}], + io:format("~p:\n~p\n", [Arg,Lines]), + + %% There must be at least four PROGRESS lines. + if + length(Lines) >= 4 -> ok; + true -> ?t:fail() + end, + Bin. %%----------------------------------------------------------------- %% Internal |