~statik/ubuntu/maverick/erlang/erlang-merge-testing

« back to all changes in this revision

Viewing changes to lib/megaco/test/megaco_codec_v3_test.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-01 10:14:38 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090501101438-6qlr6rsdxgyzrg2z
Tags: 1:13.b-dfsg-2
* Cleaned up patches: removed unneeded patch which helped to support
  different SCTP library versions, made sure that changes for m68k
  architecture applied only when building on this architecture.
* Removed duplicated information from binary packages descriptions.
* Don't require libsctp-dev build-dependency on solaris-i386 architecture
  which allows to build Erlang on Nexenta (thanks to Tim Spriggs for
  the suggestion).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%%<copyright>
2
 
%% <year>2006-2008</year>
3
 
%% <holder>Ericsson AB, All Rights Reserved</holder>
4
 
%%</copyright>
5
 
%%<legalnotice>
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%% 
 
4
%% Copyright Ericsson AB 2006-2009. All Rights Reserved.
 
5
%% 
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
11
 
%%
 
11
%% 
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
 
16
%% 
 
17
%% %CopyrightEnd%
16
18
%%
17
 
%% The Initial Developer of the Original Code is Ericsson AB.
18
 
%%</legalnotice>
 
19
 
19
20
%%
20
21
%%----------------------------------------------------------------------
21
22
%% Purpose: Test encoding/decoding (codec) module of Megaco/H.248
185
186
         pretty_otp6490_msg04/1, 
186
187
         pretty_otp6490_msg05/1, 
187
188
         pretty_otp6490_msg06/1, 
 
189
         pretty_otp7671_msg01/1,
 
190
         pretty_otp7671_msg02/1,
 
191
         pretty_otp7671_msg03/1,
 
192
         pretty_otp7671_msg04/1,
 
193
         pretty_otp7671_msg05/1,
188
194
 
189
195
         flex_pretty_tickets/1, 
190
196
         flex_pretty_otp5042_msg1/1, 
552
558
     pretty_otp6490_msg03,
553
559
     pretty_otp6490_msg04,
554
560
     pretty_otp6490_msg05,
555
 
     pretty_otp6490_msg06
 
561
     pretty_otp6490_msg06,
 
562
     pretty_otp7671_msg01,
 
563
     pretty_otp7671_msg02,
 
564
     pretty_otp7671_msg03,
 
565
     pretty_otp7671_msg04,
 
566
     pretty_otp7671_msg05
556
567
    ].
557
568
 
558
569
 
3815
3826
    pretty_otp6490_msg(EBD).
3816
3827
 
3817
3828
 
 
3829
%% --------------------------------------------------------------
 
3830
%%
 
3831
 
 
3832
pretty_otp7671_msg01(suite) ->
 
3833
    [];
 
3834
pretty_otp7671_msg01(Config) when is_list(Config) ->
 
3835
%%     put(severity, trc),
 
3836
%%     put(dbg,      true),
 
3837
    d("pretty_otp7671_msg01 -> entry", []),
 
3838
    %% ?ACQUIRE_NODES(1, Config),
 
3839
    ok = pretty_otp7671( pretty_otp7671_msg01(), [] ),
 
3840
%%     erase(dbg),
 
3841
%%     erase(severity),
 
3842
    ok.
 
3843
 
 
3844
pretty_otp7671_msg02(suite) ->
 
3845
    [];
 
3846
pretty_otp7671_msg02(Config) when is_list(Config) ->
 
3847
%%     put(severity, trc),
 
3848
%%     put(dbg,      true),
 
3849
    d("pretty_otp7671_msg02 -> entry", []),
 
3850
    %% ?ACQUIRE_NODES(1, Config),
 
3851
    ok = pretty_otp7671( pretty_otp7671_msg02(), [] ),
 
3852
%%     erase(dbg),
 
3853
%%     erase(severity),
 
3854
   ok.
 
3855
 
 
3856
pretty_otp7671_msg03(suite) ->
 
3857
    [];
 
3858
pretty_otp7671_msg03(Config) when is_list(Config) ->
 
3859
%%     put(severity, trc),
 
3860
%%     put(dbg,      true),
 
3861
    d("pretty_otp7671_msg03 -> entry", []),
 
3862
    %% ?ACQUIRE_NODES(1, Config),
 
3863
    ok = pretty_otp7671( pretty_otp7671_msg03(), [] ),
 
3864
%%     erase(dbg),
 
3865
%%     erase(severity),
 
3866
    ok.
 
3867
 
 
3868
pretty_otp7671_msg04(suite) ->
 
3869
    [];
 
3870
pretty_otp7671_msg04(Config) when is_list(Config) ->
 
3871
%%     put(severity, trc),
 
3872
%%     put(dbg,      true),
 
3873
    d("pretty_otp7671_msg04 -> entry", []),
 
3874
    %% ?ACQUIRE_NODES(1, Config),
 
3875
    ok = pretty_otp7671( pretty_otp7671_msg04(), [] , error, ignore),
 
3876
%%     erase(dbg),
 
3877
%%     erase(severity),
 
3878
    ok.
 
3879
 
 
3880
pretty_otp7671_msg05(suite) ->
 
3881
    [];
 
3882
pretty_otp7671_msg05(Config) when is_list(Config) ->
 
3883
%%     put(severity, trc),
 
3884
%%     put(dbg,      true),
 
3885
    d("pretty_otp7671_msg05 -> entry", []),
 
3886
    Check = fun(M1, M2) -> cmp_otp7671_msg05(M1, M2) end,
 
3887
    ok = pretty_otp7671( pretty_otp7671_msg05(), [] , ok, ok, Check),
 
3888
%%     erase(dbg),
 
3889
%%     erase(severity),
 
3890
    ok.
 
3891
 
 
3892
pretty_otp7671(Msg, Conf) ->
 
3893
    pretty_otp7671(Msg, Conf, ok).
 
3894
 
 
3895
pretty_otp7671(Msg, Conf, ExpectedEncode) ->
 
3896
    pretty_otp7671(Msg, Conf, ExpectedEncode, ok).
 
3897
 
 
3898
pretty_otp7671(Msg, Conf, ExpectedEncode, ExpectedDecode) ->
 
3899
    otp7671(Msg, megaco_pretty_text_encoder, Conf,
 
3900
            ExpectedEncode, ExpectedDecode).
 
3901
 
 
3902
pretty_otp7671(Msg, Conf, ExpectedEncode, ExpectedDecode, Check) ->
 
3903
    otp7671(Msg, megaco_pretty_text_encoder, Conf,
 
3904
            ExpectedEncode, ExpectedDecode, Check).
 
3905
 
 
3906
otp7671(Msg, Codec, Conf, ExpectedEncode, ExpectedDecode) ->
 
3907
    Check = fun(M1, M2) -> 
 
3908
                    exit({unexpected_decode_result, M1, M2})
 
3909
            end,
 
3910
    otp7671(Msg, Codec, Conf, ExpectedEncode, ExpectedDecode, Check).
 
3911
 
 
3912
otp7671(Msg, Codec, Conf, ExpectedEncode, ExpectedDecode, Check) ->
 
3913
    case (catch encode_message(Codec, Conf, Msg)) of
 
3914
        {error, _Reason} when ExpectedEncode =:= error ->
 
3915
            ok;
 
3916
        {error, Reason} when ExpectedEncode =:= ok ->
 
3917
            exit({unexpected_encode_failure, Reason});
 
3918
        {ok, Bin} when ExpectedEncode =:= error ->
 
3919
            exit({unexpected_encode_success, Msg, binary_to_list(Bin)});
 
3920
        {ok, Bin} when ExpectedEncode =:= ok ->
 
3921
            case decode_message(Codec, false, Conf, Bin) of
 
3922
                {ok, Msg} when ExpectedDecode =:= ok ->
 
3923
                    ok;
 
3924
                {ok, Msg2} when ExpectedDecode =:= ok ->
 
3925
                    Check(Msg, Msg2);
 
3926
                {ok, Msg} when ExpectedDecode =:= error ->
 
3927
                    exit({unexpected_decode_success, Msg});
 
3928
                {ok, Msg2} when ExpectedDecode =:= error ->
 
3929
                    exit({unexpected_decode_success, Msg, Msg2});
 
3930
                {error, _Reason} when ExpectedDecode =:= error ->
 
3931
                    ok;
 
3932
                {error, Reason} when ExpectedDecode == ok ->
 
3933
                    exit({unexpected_decode_failure, Msg, Reason})
 
3934
            end
 
3935
    end.
 
3936
 
 
3937
 
 
3938
pretty_otp7671_msg(DigitMapDesc) ->
 
3939
    AmmReq = cre_AmmReq([#megaco_term_id{id = ?A4444}],
 
3940
                        [{digitMapDescriptor, DigitMapDesc}]),
 
3941
    CmdReq = cre_CmdReq({modReq, AmmReq}),
 
3942
    msg_request(?MGC_MID, 10001, ?megaco_null_context_id, [CmdReq]).
 
3943
 
 
3944
pretty_otp7671_msg01() ->
 
3945
    Name         = "dialplan01",
 
3946
    DigitMapDesc = cre_DigitMapDesc(Name),
 
3947
    pretty_otp7671_msg(DigitMapDesc).
 
3948
 
 
3949
pretty_otp7671_msg02() ->
 
3950
    Name         = "dialplan02",
 
3951
    Body         = "(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)",
 
3952
    Value        = cre_DigitMapValue(Body),
 
3953
    DigitMapDesc = cre_DigitMapDesc(Name, Value),
 
3954
    pretty_otp7671_msg(DigitMapDesc).
 
3955
 
 
3956
pretty_otp7671_msg03() ->
 
3957
    Body         = "(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)",
 
3958
    Value        = cre_DigitMapValue(Body),
 
3959
    DigitMapDesc = cre_DigitMapDesc(Value),
 
3960
    pretty_otp7671_msg(DigitMapDesc).
 
3961
 
 
3962
pretty_otp7671_msg04() ->
 
3963
    DigitMapDesc = cre_DigitMapDesc(),
 
3964
    pretty_otp7671_msg(DigitMapDesc).
 
3965
 
 
3966
pretty_otp7671_msg05() ->
 
3967
    {'MegacoMessage',asn1_NOVALUE,
 
3968
     {'Message',?VERSION,
 
3969
      {domainName,{'DomainName',"tgc",asn1_NOVALUE}},
 
3970
      {transactions,
 
3971
       [{transactionRequest,
 
3972
         {'TransactionRequest',12582952,
 
3973
          [{'ActionRequest',0,asn1_NOVALUE,asn1_NOVALUE,
 
3974
            [{'CommandRequest',
 
3975
              {modReq,
 
3976
               {'AmmRequest',
 
3977
                [{megaco_term_id,false,["root"]}],
 
3978
                [{digitMapDescriptor,
 
3979
                  {'DigitMapDescriptor',"dialplan1",
 
3980
                   {'DigitMapValue',asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,[],
 
3981
                    asn1_NOVALUE}}}]}},
 
3982
              asn1_NOVALUE,asn1_NOVALUE}]}]}}]}}}.
 
3983
 
 
3984
cmp_otp7671_msg05(#'MegacoMessage'{authHeader = asn1_NOVALUE, 
 
3985
                                   mess       = M1}, 
 
3986
                  #'MegacoMessage'{authHeader = asn1_NOVALUE, 
 
3987
                                   mess       = M2}) ->
 
3988
    #'Message'{messageBody = Body1} = M1,
 
3989
    #'Message'{messageBody = Body2} = M2,
 
3990
    {transactions, Trans1} = Body1,
 
3991
    {transactions, Trans2} = Body2,
 
3992
    [{transactionRequest, TR1}] = Trans1,
 
3993
    [{transactionRequest, TR2}] = Trans2,
 
3994
    #'TransactionRequest'{actions = Acts1} = TR1,
 
3995
    #'TransactionRequest'{actions = Acts2} = TR2,
 
3996
    [#'ActionRequest'{commandRequests = CR1}] = Acts1,
 
3997
    [#'ActionRequest'{commandRequests = CR2}] = Acts2,
 
3998
    [#'CommandRequest'{command = Cmd1}] = CR1,
 
3999
    [#'CommandRequest'{command = Cmd2}] = CR2,
 
4000
    {modReq, #'AmmRequest'{descriptors = Descs1}} = Cmd1,
 
4001
    {modReq, #'AmmRequest'{descriptors = Descs2}} = Cmd2,
 
4002
    [{digitMapDescriptor, 
 
4003
      #'DigitMapDescriptor'{digitMapName = Name, 
 
4004
                            digitMapValue = Value1}}] = Descs1,
 
4005
    [{digitMapDescriptor, 
 
4006
      #'DigitMapDescriptor'{digitMapName = Name, 
 
4007
                            digitMapValue = Value2}}] = Descs2,
 
4008
    #'DigitMapValue'{startTimer    = asn1_NOVALUE,
 
4009
                     shortTimer    = asn1_NOVALUE,
 
4010
                     longTimer     = asn1_NOVALUE,
 
4011
                     digitMapBody  = [],
 
4012
                     durationTimer = asn1_NOVALUE} = Value1,
 
4013
    asn1_NOVALUE = Value2,
 
4014
    ok.
 
4015
    
 
4016
 
3818
4017
%% ==============================================================
3819
4018
%%
3820
4019
%% F l e x   P r e t t y   T e s t c a s e s
7914
8113
 
7915
8114
 
7916
8115
%% DigitMap related
 
8116
cre_DigitMapDesc() ->
 
8117
    ?MSG_LIB:cre_DigitMapDescriptor().
 
8118
cre_DigitMapDesc(NameOrVal) ->
 
8119
    ?MSG_LIB:cre_DigitMapDescriptor(NameOrVal).
7917
8120
cre_DigitMapDesc(Name, Val) ->
7918
8121
    ?MSG_LIB:cre_DigitMapDescriptor(Name, Val).
7919
8122