aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test/testMegaco.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1/test/testMegaco.erl')
-rw-r--r--lib/asn1/test/testMegaco.erl51
1 files changed, 11 insertions, 40 deletions
diff --git a/lib/asn1/test/testMegaco.erl b/lib/asn1/test/testMegaco.erl
index f954f506b6..644042b484 100644
--- a/lib/asn1/test/testMegaco.erl
+++ b/lib/asn1/test/testMegaco.erl
@@ -24,53 +24,24 @@
-include_lib("test_server/include/test_server.hrl").
-compile(_Config,ber,[optimize]) ->
- {ok,no_module,no_module};
-compile(_Config,per,[optimize]) ->
- {ok,no_module,no_module};
-compile(Config,Erule,Options) ->
+compile(Config, Erule, Options) ->
asn1_test_lib:compile("MEDIA-GATEWAY-CONTROL.asn", Config, [Erule|Options]),
asn1_test_lib:compile("OLD-MEDIA-GATEWAY-CONTROL.asn", Config, [Erule|Options]),
{ok,'OLD-MEDIA-GATEWAY-CONTROL','MEDIA-GATEWAY-CONTROL'}.
-
main(no_module,_) -> ok;
main('OLD-MEDIA-GATEWAY-CONTROL',Config) ->
CaseDir = ?config(case_dir, Config),
{ok,Msg} = asn1ct:value('OLD-MEDIA-GATEWAY-CONTROL','MegacoMessage',
[{i, CaseDir}]),
- ?line {ok,Bytes} = asn1_wrapper:encode('OLD-MEDIA-GATEWAY-CONTROL',
- 'MegacoMessage',Msg),
- ?line {ok,Msg} = asn1_wrapper:decode('OLD-MEDIA-GATEWAY-CONTROL',
- 'MegacoMessage',
- Bytes),
+ asn1_test_lib:roundtrip('OLD-MEDIA-GATEWAY-CONTROL', 'MegacoMessage', Msg),
ok;
-main(Mod='MEDIA-GATEWAY-CONTROL',Config) ->
- ?line DataDir = ?config(data_dir,Config),
- io:format("DataDir:~p~n",[DataDir]),
- ?line {ok,FilenameList} = file:list_dir(filename:join([DataDir,
- megacomessages])),
- %% remove any junk files that may be in the megacomessage directory
- Pred = fun(X) ->
- case lists:reverse(X) of
- [$l,$a,$v,$.|_R] ->true;
- _ -> false
- end
- end,
- MegacoMsgFilenameList = lists:filter(Pred,FilenameList),
-
- Fun = fun(F) ->
- M = read_msg(filename:join([DataDir,megacomessages,F])),
- {ok,B} = asn1_wrapper:encode(Mod,element(1,M),M),
- {ok,M} = asn1_wrapper:decode(Mod,element(1,M),B)
- end,
- ?line lists:foreach(Fun,MegacoMsgFilenameList),
- ok.
-
-read_msg(File) ->
- case file:read_file(File) of
- {ok,Bin} ->
- binary_to_term(Bin);
- _ ->
- io:format("couldn't read file ~p~n",[File])
- end.
+main('MEDIA-GATEWAY-CONTROL'=Mod, Config) ->
+ DataDir = ?config(data_dir, Config),
+ Files = filelib:wildcard(filename:join([DataDir,megacomessages,"*.val"])),
+ lists:foreach(fun(File) ->
+ {ok,Bin} = file:read_file(File),
+ V = binary_to_term(Bin),
+ T = element(1, V),
+ asn1_test_lib:roundtrip(Mod, T, V)
+ end, Files).