From 085d179fd8c192d42415e5df73bc3eb8a6d912d2 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Wed, 14 Dec 2011 12:30:15 +0100 Subject: Increase timetrap in compiler suite Compilation is slow on Solaris for one. --- lib/diameter/test/diameter_compiler_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl') diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl index 66d788f6ec..be2a43bc54 100644 --- a/lib/diameter/test/diameter_compiler_SUITE.erl +++ b/lib/diameter/test/diameter_compiler_SUITE.erl @@ -398,7 +398,7 @@ re({RE, Repl}, Bin) -> %% 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), -- cgit v1.2.3 From 25232edb6e11334e8be767e8fa67cf690cc3e205 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Thu, 15 Dec 2011 12:56:43 +0100 Subject: Add standards testcase to compiler suite To test compilation of example dictionaries from various standards. --- lib/diameter/test/diameter_compiler_SUITE.erl | 37 ++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl') 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. @@ -421,6 +426,26 @@ generate(Mods, Bin, N, Mode) -> Mode == erl 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) -> -- cgit v1.2.3 From 03ac66e8e98707d3e198717681d8a3ad9a44835a Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Fri, 2 Dec 2011 10:00:35 +0100 Subject: Add RFC 4005 (NAS) dictionary --- lib/diameter/test/diameter_compiler_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl') diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl index ad536d3df5..45971646a7 100644 --- a/lib/diameter/test/diameter_compiler_SUITE.erl +++ b/lib/diameter/test/diameter_compiler_SUITE.erl @@ -329,7 +329,7 @@ "Origin-Host Origin-Realm\n&"}]}]). %% Standard dictionaries. --define(STANDARDS, []). +-define(STANDARDS, [rfc4005_nas]). %% =========================================================================== -- cgit v1.2.3 From 83c4ee94fe92524e7e548d8d4ee03ce8f75837a1 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Fri, 16 Dec 2011 12:23:18 +0100 Subject: Add RFC 4006 (CC) dictionary --- lib/diameter/test/diameter_compiler_SUITE.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl') diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl index 45971646a7..48dccf3e23 100644 --- a/lib/diameter/test/diameter_compiler_SUITE.erl +++ b/lib/diameter/test/diameter_compiler_SUITE.erl @@ -329,7 +329,8 @@ "Origin-Host Origin-Realm\n&"}]}]). %% Standard dictionaries. --define(STANDARDS, [rfc4005_nas]). +-define(STANDARDS, [rfc4005_nas, + rfc4006_cc]). %% =========================================================================== @@ -443,6 +444,8 @@ standards(Dict, Dir) -> [{name, Dict} | opts(Dict)]), {ok, _, _} = compile:file(Dict ++ ".erl", [return]). +opts("rfc4006_cc") -> + [{inherits, "diameter_gen_nas_rfc4005/rfc4005_nas"}]; opts(_) -> []. -- cgit v1.2.3 From 093f10348fe133018645efb4dad65258021d51aa Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Fri, 16 Dec 2011 12:23:57 +0100 Subject: Add RFC 4072 (EAP) dictionary --- lib/diameter/test/diameter_compiler_SUITE.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl') diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl index 48dccf3e23..9a338fd133 100644 --- a/lib/diameter/test/diameter_compiler_SUITE.erl +++ b/lib/diameter/test/diameter_compiler_SUITE.erl @@ -330,7 +330,8 @@ %% Standard dictionaries. -define(STANDARDS, [rfc4005_nas, - rfc4006_cc]). + rfc4006_cc, + rfc4072_eap]). %% =========================================================================== @@ -444,7 +445,9 @@ standards(Dict, Dir) -> [{name, Dict} | opts(Dict)]), {ok, _, _} = compile:file(Dict ++ ".erl", [return]). -opts("rfc4006_cc") -> +opts(M) + when M == "rfc4006_cc"; + M == "rfc4072_eap" -> [{inherits, "diameter_gen_nas_rfc4005/rfc4005_nas"}]; opts(_) -> []. -- cgit v1.2.3 From 69cc61f28ec91389a8fe4d67efb247563cbef4bf Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Fri, 16 Dec 2011 12:24:21 +0100 Subject: Add RFC 4740 (SIP) dictionary --- lib/diameter/test/diameter_compiler_SUITE.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl') diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl index 9a338fd133..9c14a58c28 100644 --- a/lib/diameter/test/diameter_compiler_SUITE.erl +++ b/lib/diameter/test/diameter_compiler_SUITE.erl @@ -331,7 +331,9 @@ %% Standard dictionaries. -define(STANDARDS, [rfc4005_nas, rfc4006_cc, - rfc4072_eap]). + rfc4072_eap, + rfc4590_digest, + rfc4740_sip]). %% =========================================================================== @@ -449,6 +451,8 @@ opts(M) when M == "rfc4006_cc"; M == "rfc4072_eap" -> [{inherits, "diameter_gen_nas_rfc4005/rfc4005_nas"}]; +opts("rfc4740_sip") -> + [{inherits, "diameter_gen_digest_rfc4590/rfc4590_digest"}]; opts(_) -> []. -- cgit v1.2.3 From a1fe4bfad84938828f9a092a29387e7ec3f1ab80 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Fri, 16 Dec 2011 12:16:48 +0100 Subject: Add RFC 4004 (MIP) dictionary --- lib/diameter/test/diameter_compiler_SUITE.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl') diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl index 9c14a58c28..9271cd2ec3 100644 --- a/lib/diameter/test/diameter_compiler_SUITE.erl +++ b/lib/diameter/test/diameter_compiler_SUITE.erl @@ -329,7 +329,8 @@ "Origin-Host Origin-Realm\n&"}]}]). %% Standard dictionaries. --define(STANDARDS, [rfc4005_nas, +-define(STANDARDS, [rfc4004_mip, + rfc4005_nas, rfc4006_cc, rfc4072_eap, rfc4590_digest, -- cgit v1.2.3 From d486873f661e8e22b355c9f12edb726a6832d84d Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Fri, 16 Dec 2011 16:05:43 +0100 Subject: Set name/prefix at compilation, not in dictionaries To avoid inappropriate defaults if the dictionaries are reused. --- lib/diameter/test/diameter_compiler_SUITE.erl | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl') diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl index 9271cd2ec3..f12fba3654 100644 --- a/lib/diameter/test/diameter_compiler_SUITE.erl +++ b/lib/diameter/test/diameter_compiler_SUITE.erl @@ -444,19 +444,31 @@ standards(Config) -> [D || D <- ?STANDARDS, _ <- [standards(?S(D), Data)]]. standards(Dict, Dir) -> + {Name, Pre} = make_name(Dict), ok = diameter_make:codec(filename:join([Dir, Dict ++ ".dia"]), - [{name, Dict} | opts(Dict)]), - {ok, _, _} = compile:file(Dict ++ ".erl", [return]). + [{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, "diameter_gen_nas_rfc4005/rfc4005_nas"}]; + [inherits("rfc4005_nas")]; opts("rfc4740_sip") -> - [{inherits, "diameter_gen_digest_rfc4590/rfc4590_digest"}]; + [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) -> -- cgit v1.2.3 From fba96f493b940f032bc238492a9375ad6397dbe4 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Fri, 16 Dec 2011 16:19:06 +0100 Subject: Move example dictionaries to examples/dict --- lib/diameter/test/diameter_compiler_SUITE.erl | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'lib/diameter/test/diameter_compiler_SUITE.erl') diff --git a/lib/diameter/test/diameter_compiler_SUITE.erl b/lib/diameter/test/diameter_compiler_SUITE.erl index f12fba3654..3b4c9706e0 100644 --- a/lib/diameter/test/diameter_compiler_SUITE.erl +++ b/lib/diameter/test/diameter_compiler_SUITE.erl @@ -32,7 +32,7 @@ -export([format/1, format/2, replace/1, replace/2, generate/1, generate/4, generate/0, - standards/1, standards/0]). + examples/1, examples/0]). -export([dict/0]). %% fake dictionary module @@ -328,13 +328,13 @@ "@codecs mymod " "Origin-Host Origin-Realm\n&"}]}]). -%% Standard dictionaries. --define(STANDARDS, [rfc4004_mip, - rfc4005_nas, - rfc4006_cc, - rfc4072_eap, - rfc4590_digest, - rfc4740_sip]). +%% Standard dictionaries in examples/dict. +-define(EXAMPLES, [rfc4004_mip, + rfc4005_nas, + rfc4006_cc, + rfc4072_eap, + rfc4590_digest, + rfc4740_sip]). %% =========================================================================== @@ -345,7 +345,7 @@ all() -> [format, replace, generate, - standards]. + examples]. %% Error handling testcases will make an erroneous dictionary out of %% the base dictionary and check that the expected error results. @@ -432,18 +432,18 @@ generate(Mods, Bin, N, Mode) -> andalso ({ok, _} = compile:file(File ++ ".erl", [return_errors])). %% =========================================================================== -%% standards/1 +%% examples/1 %% %% Compile dictionaries extracted from various standards. -standards() -> - [{timetrap, {seconds, 3*length(?STANDARDS)}}]. +examples() -> + [{timetrap, {seconds, 3*length(?EXAMPLES)}}]. -standards(Config) -> - Data = proplists:get_value(data_dir, Config), - [D || D <- ?STANDARDS, _ <- [standards(?S(D), Data)]]. +examples(_Config) -> + Dir = filename:join([code:lib_dir(diameter, examples), "dict"]), + [D || D <- ?EXAMPLES, _ <- [examples(?S(D), Dir)]]. -standards(Dict, Dir) -> +examples(Dict, Dir) -> {Name, Pre} = make_name(Dict), ok = diameter_make:codec(filename:join([Dir, Dict ++ ".dia"]), [{name, Name}, -- cgit v1.2.3