aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/test/diameter_compiler_SUITE.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2011-12-20 14:51:56 +0100
committerAnders Svensson <[email protected]>2011-12-20 14:51:56 +0100
commit58336ee5c613de56f6d69562cd59b651eef734f0 (patch)
tree5a593244269992c86b9157229a2cb6d0242bbb79 /lib/diameter/test/diameter_compiler_SUITE.erl
parente986108d71a71d835c241d22cdb08f97584958c5 (diff)
parent84873533d8caf176a710135d15e3578168350eab (diff)
downloadotp-58336ee5c613de56f6d69562cd59b651eef734f0.tar.gz
otp-58336ee5c613de56f6d69562cd59b651eef734f0.tar.bz2
otp-58336ee5c613de56f6d69562cd59b651eef734f0.zip
Merge branch 'anders/diameter/testsuites/OTP-9829' into maint
* anders/diameter/testsuites/OTP-9829: (21 commits) Install example dictionaries Move example code to examples/code Move example dictionaries to examples/dict Set name/prefix at compilation, not in dictionaries Add RFC 4004 (MIP) dictionary Add RFC 4740 (SIP) dictionary Add RFC 4072 (EAP) dictionary Add RFC 4006 (CC) dictionary Add RFC 4005 (NAS) dictionary Add standards testcase to compiler suite Remove {init,end}_per_group workaround Use new syntax for specifying ct group properties Increase timetrap in compiler suite Minor capx suite tweaks Minor makefile tweak Remove trailing whitespace Update skip condition in gen_sctp suite Reintroduce gen_sctp suite Remove delay from connect in transport suite Add codec testcase for decode of unknown AVPs ...
Diffstat (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl')
-rw-r--r--lib/diameter/test/diameter_compiler_SUITE.erl62
1 files changed, 55 insertions, 7 deletions
diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl
index 66d788f6ec..3b4c9706e0 100644
--- a/lib/diameter/test/diameter_compiler_SUITE.erl
+++ b/lib/diameter/test/diameter_compiler_SUITE.erl
@@ -29,9 +29,10 @@
end_per_suite/1]).
%% testcases
--export([format/1, format/2,
- replace/1, replace/2,
- generate/1, generate/4, generate/0]).
+-export([format/1, format/2,
+ replace/1, replace/2,
+ generate/1, generate/4, generate/0,
+ examples/1, examples/0]).
-export([dict/0]). %% fake dictionary module
@@ -327,6 +328,14 @@
"@codecs mymod "
"Origin-Host Origin-Realm\n&"}]}]).
+%% Standard dictionaries in examples/dict.
+-define(EXAMPLES, [rfc4004_mip,
+ rfc4005_nas,
+ rfc4006_cc,
+ rfc4072_eap,
+ rfc4590_digest,
+ rfc4740_sip]).
+
%% ===========================================================================
suite() ->
@@ -335,7 +344,8 @@ suite() ->
all() ->
[format,
replace,
- generate].
+ generate,
+ examples].
%% Error handling testcases will make an erroneous dictionary out of
%% the base dictionary and check that the expected error results.
@@ -349,8 +359,6 @@ end_per_suite(_Config) ->
ok.
%% ===========================================================================
-%% testcases
-
%% format/1
%%
%% Ensure that parse o format is the identity map.
@@ -367,6 +375,7 @@ format(Mods, Bin) ->
{ok, D} = diameter_dict_util:parse(diameter_dict_util:format(Dict), []),
{Dict, Dict} = {Dict, D}.
+%% ===========================================================================
%% replace/1
%%
%% Ensure the expected success/error when parsing a morphed common
@@ -393,12 +402,13 @@ replace({E, Mods}, Bin) ->
re({RE, Repl}, Bin) ->
re:replace(Bin, RE, Repl, [multiline]).
+%% ===========================================================================
%% generate/1
%%
%% Ensure success when generating code and compiling.
generate() ->
- [{timetrap, {seconds, length(?REPLACE)}}].
+ [{timetrap, {seconds, 2*length(?REPLACE)}}].
generate(Config) ->
Bin = proplists:get_value(base, Config),
@@ -422,6 +432,44 @@ generate(Mods, Bin, N, Mode) ->
andalso ({ok, _} = compile:file(File ++ ".erl", [return_errors])).
%% ===========================================================================
+%% examples/1
+%%
+%% Compile dictionaries extracted from various standards.
+
+examples() ->
+ [{timetrap, {seconds, 3*length(?EXAMPLES)}}].
+
+examples(_Config) ->
+ Dir = filename:join([code:lib_dir(diameter, examples), "dict"]),
+ [D || D <- ?EXAMPLES, _ <- [examples(?S(D), Dir)]].
+
+examples(Dict, Dir) ->
+ {Name, Pre} = make_name(Dict),
+ ok = diameter_make:codec(filename:join([Dir, Dict ++ ".dia"]),
+ [{name, Name},
+ {prefix, Pre},
+ inherits("rfc3588_base")
+ | opts(Dict)]),
+ {ok, _, _} = compile:file(Name ++ ".erl", [return]).
+
+opts(M)
+ when M == "rfc4006_cc";
+ M == "rfc4072_eap" ->
+ [inherits("rfc4005_nas")];
+opts("rfc4740_sip") ->
+ [inherits("rfc4590_digest")];
+opts(_) ->
+ [].
+
+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}.
+
+%% ===========================================================================
modify(Bin, Mods) ->
lists:foldl(fun re/2, Bin, Mods).