aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sasl/test/rh_test_lib.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-06-05 14:58:58 +0200
committerSiri Hansen <[email protected]>2013-06-05 14:58:58 +0200
commit3a40a631313ea3a5b05de121ebd6a559d8543329 (patch)
tree846a70b93f4870e5dcaeae7026b67f4afe5f3db1 /lib/sasl/test/rh_test_lib.erl
parent00e93e8948c84bc5150e3c8dbea0820e60491461 (diff)
parentb81d9bf18cd99b60f4bd964f190f63673e0a9b6b (diff)
downloadotp-3a40a631313ea3a5b05de121ebd6a559d8543329.tar.gz
otp-3a40a631313ea3a5b05de121ebd6a559d8543329.tar.bz2
otp-3a40a631313ea3a5b05de121ebd6a559d8543329.zip
Merge branch 'siri/install-otp-in-unicode-path'
* siri/install-otp-in-unicode-path: [sasl] Remove priv dir after release_handler_SUITE Update preloaded init.beam Allow unicode characters for boot and config in init:make_permanent [sasl] Clean priv_dir after systools_SUITE [reltool] Use unicode characters in work dir for unicode test [sasl] Use unicode characters in priv dir name also on windows [reltool] Write erl.ini as UTF-8 [sasl] Update tests to run under unicode path [sasl] Rewrite release_handler_SUITE:clean_priv_dir to work on unicode paths [sasl] Update example/target_system.erl to handle unicode [sasl] Write erl.ini as utf8, allowing unicode path for root dir and bin dir
Diffstat (limited to 'lib/sasl/test/rh_test_lib.erl')
-rw-r--r--lib/sasl/test/rh_test_lib.erl61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/sasl/test/rh_test_lib.erl b/lib/sasl/test/rh_test_lib.erl
index c9a425c729..11935496d8 100644
--- a/lib/sasl/test/rh_test_lib.erl
+++ b/lib/sasl/test/rh_test_lib.erl
@@ -1,5 +1,6 @@
-module(rh_test_lib).
+-export([cmd/3]).
-export([erlsrv/3,
erlsrv/4]).
-export([get_service_args/3,
@@ -8,7 +9,20 @@
get_start_erl_args/3,
get_client_args/3,
get_client_args/4]).
+-export([clean_dir/1,
+ clean_dir/2]).
+-include_lib("kernel/include/file.hrl").
+
+cmd(Cmd,Args,Env) ->
+ case open_port({spawn_executable, Cmd}, [{args,Args},{env,Env}]) of
+ Port when is_port(Port) ->
+ unlink(Port),
+ erlang:port_close(Port),
+ ok;
+ Error ->
+ Error
+ end.
erlsrv(Erlsrv,Action,Name) ->
erlsrv(Erlsrv,Action,Name,"").
@@ -99,3 +113,50 @@ single_quote() ->
_ ->
"\\'"
end.
+
+clean_dir(Dir) ->
+ clean_dir(Dir,false).
+clean_dir(Dir,Save) ->
+ test_server:format("======== current dir ~tp~n",[Dir]),
+ Dirs = filelib:wildcard(filename:join(Dir,"*")),
+ test_server:format("======== deleting ~tp~n",[Dirs]),
+
+ ok = rm_rf(Dirs,Save),
+ Remaining = filelib:wildcard(filename:join(Dir,"*")),
+ test_server:format("======== remaining ~tp~n",[Remaining]),
+
+ case Remaining of
+ [] ->
+ ok;
+ _ ->
+ rm_rf(Remaining,Save),
+ Remaining2 = filelib:wildcard(filename:join(Dir,"*")),
+ test_server:format("======== remaining after second try ~tp~n",
+ [Remaining2])
+ end,
+
+ ok.
+
+
+rm_rf([File|Files],Save) ->
+ case Save andalso filename:basename(File)=="save" of
+ true ->
+ rm_rf(Files,Save);
+ false ->
+ case file:read_link_info(File) of
+ {ok,#file_info{type=directory}} ->
+ MoreFiles = filelib:wildcard(filename:join(File,"*")),
+ rm_rf(MoreFiles,Save),
+ file:del_dir(File),
+ rm_rf(Files,Save);
+ {ok,#file_info{}} ->
+ file:delete(File),
+ rm_rf(Files,Save);
+ Other ->
+ test_server:format("======== could not delete file ~p~n"
+ "read_link_info -> ~p~n",[File,Other]),
+ rm_rf(Files,Save)
+ end
+ end;
+rm_rf([],_) ->
+ ok.