diff options
author | Anders Svensson <[email protected]> | 2011-10-07 16:26:45 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2011-10-07 17:49:05 +0200 |
commit | ac2810603b7aaad24129fadf887d9e8deff31d2f (patch) | |
tree | 6536cbfa0fc5d89c808cc6ee74f3f155bbc679cf /lib/diameter/test/diameter_util.erl | |
parent | d01551f400e2a7944dcc10319be0c9f248ca3179 (diff) | |
download | otp-ac2810603b7aaad24129fadf887d9e8deff31d2f.tar.gz otp-ac2810603b7aaad24129fadf887d9e8deff31d2f.tar.bz2 otp-ac2810603b7aaad24129fadf887d9e8deff31d2f.zip |
Make testsuites more robust in case of init failure
In particular, move code out of init_per_suite since failure
causes end_per_suite to be skipped. Cleanup is simpler if both
init and cleanup happen as testcases.
Diffstat (limited to 'lib/diameter/test/diameter_util.erl')
-rw-r--r-- | lib/diameter/test/diameter_util.erl | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/diameter/test/diameter_util.erl b/lib/diameter/test/diameter_util.erl index 99f4fa1977..f9942c3408 100644 --- a/lib/diameter/test/diameter_util.erl +++ b/lib/diameter/test/diameter_util.erl @@ -28,7 +28,8 @@ fold/3, foldl/3, scramble/1, - ps/0]). + write_priv/3, + read_priv/2]). -define(L, atom_to_list). @@ -150,11 +151,6 @@ s(Acc, L) -> {H, [T|Rest]} = lists:split(random:uniform(length(L)) - 1, L), s([T|Acc], H ++ Rest). -%% ps/0 - -ps() -> - [{P, process_info(P)} || P <- erlang:processes()]. - %% eval/1 eval({M,[F|A]}) @@ -175,3 +171,18 @@ eval(L) eval(F) when is_function(F,0) -> F(). + +%% write_priv/3 + +write_priv(Config, Name, Term) -> + Dir = proplists:get_value(priv_dir, Config), + Path = filename:join([Dir, Name]), + ok = file:write_file(Path, term_to_binary(Term)). + +%% read_priv/2 + +read_priv(Config, Name) -> + Dir = proplists:get_value(priv_dir, Config), + Path = filename:join([Dir, Name]), + {ok, Bin} = file:read_file(Path), + binary_to_term(Bin). |