diff options
author | Anders Svensson <[email protected]> | 2013-03-23 19:16:19 +0100 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2013-03-24 15:53:03 +0100 |
commit | dbdab43a5b4eab278538b9c82c17fccac7f778a3 (patch) | |
tree | 65d4bdca049f9c85e37101720df0eab0b0603a59 /lib/diameter/test/diameter_examples_SUITE.erl | |
parent | 849d61f719120fddac1e0797cd282e4f0ec7e335 (diff) | |
download | otp-dbdab43a5b4eab278538b9c82c17fccac7f778a3.tar.gz otp-dbdab43a5b4eab278538b9c82c17fccac7f778a3.tar.bz2 otp-dbdab43a5b4eab278538b9c82c17fccac7f778a3.zip |
Move example dict compilation to examples suite
From compiler suite.
Diffstat (limited to 'lib/diameter/test/diameter_examples_SUITE.erl')
-rw-r--r-- | lib/diameter/test/diameter_examples_SUITE.erl | 81 |
1 files changed, 77 insertions, 4 deletions
diff --git a/lib/diameter/test/diameter_examples_SUITE.erl b/lib/diameter/test/diameter_examples_SUITE.erl index f857f893e2..16b858041a 100644 --- a/lib/diameter/test/diameter_examples_SUITE.erl +++ b/lib/diameter/test/diameter_examples_SUITE.erl @@ -27,7 +27,8 @@ all/0]). %% testcases --export([compile/1, +-export([dict/1, dict/0, + code/1, enslave/1, start/1, traffic/1, @@ -57,17 +58,87 @@ suite() -> [{timetrap, {seconds, 45}}]. all() -> - [compile, + [dict, + code, enslave, start, traffic, stop]. %% =========================================================================== +%% dict/1 +%% +%% Compile example dictionaries in examples/dict. + +-define(EXAMPLES, [rfc4004_mip, + rfc4005_nas, + rfc4006_cc, + rfc4072_eap, + rfc4590_digest, + rfc4740_sip]). + +dict() -> + [{timetrap, {minutes, length(?EXAMPLES)}}]. + +dict(_Config) -> + Dir = filename:join([code:lib_dir(diameter, examples), "dict"]), + [] = [RC || D <- ?EXAMPLES, + RC <- [dict(atom_to_list(D), Dir)], + RC /= ok]. + +dict(Dict, Dir) -> + {Name, Pre} = make_name(Dict), + try + ok = make(filename:join([Dir, Dict ++ ".dia"]), + [{name, Name}, + {prefix, Pre}, + inherits("rfc3588_base") + | opts(Dict)]), + ok = compile(Name) + catch + throw: {_,_} = E -> + E + end. + +make(File, Opts) -> + case diameter_make:codec(File, Opts) of + ok -> + ok; + No -> + throw({make, No}) + end. + +compile(Name) -> + case compile:file(Name ++ ".erl", [return]) of + {ok, _, _} -> + ok; + No -> + throw({compile, No}) + end. -%% compile/1 +opts(M) + when M == "rfc4006_cc"; + M == "rfc4072_eap" -> + [inherits("rfc4005_nas")]; +opts("rfc4740_sip") -> + [inherits("rfc4590_digest")]; +opts(_) -> + []. -compile(Config) -> +inherits(File) -> + {Name, _} = make_name(File), + {inherits, File ++ "/" ++ Name}. + +make_name(File) -> + {R, [$_|N]} = lists:splitwith(fun(C) -> C /= $_ end, File), + {string:join(["diameter_gen", N, R], "_"), "diameter_" ++ N}. + +%% =========================================================================== +%% code/1 +%% +%% Compile example code under examples/code. + +code(Config) -> Node = slave(hd(?NODES), here()), [] = rpc:call(Node, ?MODULE, @@ -129,6 +200,8 @@ find_files(Dir, RE) -> cons(H,T) -> [H|T]. +%% =========================================================================== + %% enslave/1 %% %% Start two nodes: one for the server, one for the client. |