diff options
author | Björn Gustavsson <[email protected]> | 2015-05-29 10:52:15 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-05-29 10:52:15 +0200 |
commit | 3f652961917964b1f47a0ac62609860691bd9099 (patch) | |
tree | 69849088246ab0d044ade9104f7bbf4c75d4bd9d /lib/sasl/test/sasl_SUITE.erl | |
parent | 6635bfa7c480d33d43874f4b37b7c461ba04db23 (diff) | |
parent | 885ad5783c33d7f6115c5ad55c401102f10039d6 (diff) | |
download | otp-3f652961917964b1f47a0ac62609860691bd9099.tar.gz otp-3f652961917964b1f47a0ac62609860691bd9099.tar.bz2 otp-3f652961917964b1f47a0ac62609860691bd9099.zip |
Merge branch 'saleyn/sasl/opening-modes/OTP-12778'
* saleyn/sasl/opening-modes/OTP-12778:
Customize SASL error_logger file opening modes
Diffstat (limited to 'lib/sasl/test/sasl_SUITE.erl')
-rw-r--r-- | lib/sasl/test/sasl_SUITE.erl | 31 |
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. |