aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sasl/test/sasl_SUITE.erl
diff options
context:
space:
mode:
authorSerge Aleynikov <[email protected]>2014-04-20 12:37:57 -0400
committerBjörn Gustavsson <[email protected]>2015-05-28 13:34:45 +0200
commit885ad5783c33d7f6115c5ad55c401102f10039d6 (patch)
treeb74e9cbc55f22cb5f797ff37be50c964ca354a41 /lib/sasl/test/sasl_SUITE.erl
parentce96ab6d64768cd6536011ccdecc08191c238220 (diff)
downloadotp-885ad5783c33d7f6115c5ad55c401102f10039d6.tar.gz
otp-885ad5783c33d7f6115c5ad55c401102f10039d6.tar.bz2
otp-885ad5783c33d7f6115c5ad55c401102f10039d6.zip
Customize SASL error_logger file opening modes
Include the ability to open a SASL error log file in append mode at startup vs currently implemented "rewrite-always" mode.
Diffstat (limited to 'lib/sasl/test/sasl_SUITE.erl')
-rw-r--r--lib/sasl/test/sasl_SUITE.erl31
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/sasl/test/sasl_SUITE.erl b/lib/sasl/test/sasl_SUITE.erl
index d7b99d506e..d9ab9e551c 100644
--- a/lib/sasl/test/sasl_SUITE.erl
+++ b/lib/sasl/test/sasl_SUITE.erl
@@ -26,10 +26,11 @@
%% Test cases must be exported.
-export([app_test/1,
appup_test/1,
- log_mf_h_env/1]).
+ log_mf_h_env/1,
+ log_file/1]).
all() ->
- [log_mf_h_env, app_test, appup_test].
+ [log_mf_h_env, log_file, app_test, appup_test].
groups() ->
[].
@@ -151,10 +152,9 @@ check_appup([],_,_) ->
log_mf_h_env(Config) ->
PrivDir = ?config(priv_dir,Config),
LogDir = filename:join(PrivDir,sasl_SUITE_log_dir),
- ok = file:make_dir(LogDir),
+ ok = filelib:ensure_dir(LogDir),
application:stop(sasl),
- SaslEnv = application:get_all_env(sasl),
- lists:foreach(fun({E,_V}) -> application:unset_env(sasl,E) end, SaslEnv),
+ clear_env(sasl),
ok = application:set_env(sasl,error_logger_mf_dir,LogDir),
match_error(missing_config,application:start(sasl)),
@@ -178,6 +178,23 @@ log_mf_h_env(Config) ->
ok = application:set_env(sasl,error_logger_mf_dir,LogDir),
ok = application:start(sasl).
+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"),
+ 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}]),
+ ok = application:start(sasl).
+
%%-----------------------------------------------------------------
%% Internal
@@ -185,3 +202,7 @@ match_error(Expected,{error,{bad_return,{_,{'EXIT',{Expected,{sasl,_}}}}}}) ->
ok;
match_error(Expected,Actual) ->
?t:fail({unexpected_return,Expected,Actual}).
+
+clear_env(App) ->
+ [application:unset_env(App,Opt) || {Opt,_} <- application:get_all_env(App)],
+ ok.