aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2011-12-15 12:56:43 +0100
committerAnders Svensson <[email protected]>2011-12-16 18:27:19 +0100
commit25232edb6e11334e8be767e8fa67cf690cc3e205 (patch)
tree416686a9656b24a95a6542058079762357670b27 /lib/diameter
parent93e15894d807e9d6c0c94febfda6f5897dddfe02 (diff)
downloadotp-25232edb6e11334e8be767e8fa67cf690cc3e205.tar.gz
otp-25232edb6e11334e8be767e8fa67cf690cc3e205.tar.bz2
otp-25232edb6e11334e8be767e8fa67cf690cc3e205.zip
Add standards testcase to compiler suite
To test compilation of example dictionaries from various standards.
Diffstat (limited to 'lib/diameter')
-rw-r--r--lib/diameter/test/diameter_compiler_SUITE.erl37
1 files changed, 31 insertions, 6 deletions
diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl
index be2a43bc54..ad536d3df5 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,
+ standards/1, standards/0]).
-export([dict/0]). %% fake dictionary module
@@ -327,6 +328,9 @@
"@codecs mymod "
"Origin-Host Origin-Realm\n&"}]}]).
+%% Standard dictionaries.
+-define(STANDARDS, []).
+
%% ===========================================================================
suite() ->
@@ -335,7 +339,8 @@ suite() ->
all() ->
[format,
replace,
- generate].
+ generate,
+ standards].
%% Error handling testcases will make an erroneous dictionary out of
%% the base dictionary and check that the expected error results.
@@ -349,8 +354,6 @@ end_per_suite(_Config) ->
ok.
%% ===========================================================================
-%% testcases
-
%% format/1
%%
%% Ensure that parse o format is the identity map.
@@ -367,6 +370,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,6 +397,7 @@ replace({E, Mods}, Bin) ->
re({RE, Repl}, Bin) ->
re:replace(Bin, RE, Repl, [multiline]).
+%% ===========================================================================
%% generate/1
%%
%% Ensure success when generating code and compiling.
@@ -422,6 +427,26 @@ generate(Mods, Bin, N, Mode) ->
andalso ({ok, _} = compile:file(File ++ ".erl", [return_errors])).
%% ===========================================================================
+%% standards/1
+%%
+%% Compile dictionaries extracted from various standards.
+
+standards() ->
+ [{timetrap, {seconds, 3*length(?STANDARDS)}}].
+
+standards(Config) ->
+ Data = proplists:get_value(data_dir, Config),
+ [D || D <- ?STANDARDS, _ <- [standards(?S(D), Data)]].
+
+standards(Dict, Dir) ->
+ ok = diameter_make:codec(filename:join([Dir, Dict ++ ".dia"]),
+ [{name, Dict} | opts(Dict)]),
+ {ok, _, _} = compile:file(Dict ++ ".erl", [return]).
+
+opts(_) ->
+ [].
+
+%% ===========================================================================
modify(Bin, Mods) ->
lists:foldl(fun re/2, Bin, Mods).