~ubuntu-branches/ubuntu/karmic/erlang/karmic

« back to all changes in this revision

Viewing changes to lib/megaco/test/megaco_codec_prev3a_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>2005-2008</year>
3
 
%% <holder>Ericsson AB, All Rights Reserved</holder>
4
 
%%</copyright>
5
 
%%<legalnotice>
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%% 
 
4
%% Copyright Ericsson AB 2005-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
178
179
         pretty_otp6490_msg04/1, 
179
180
         pretty_otp6490_msg05/1, 
180
181
         pretty_otp6490_msg06/1, 
 
182
         pretty_otp7671_msg01/1,
 
183
         pretty_otp7671_msg02/1,
 
184
         pretty_otp7671_msg03/1,
 
185
         pretty_otp7671_msg04/1,
 
186
         pretty_otp7671_msg05/1,
181
187
 
182
188
         flex_pretty_tickets/1, 
183
189
         flex_pretty_otp5042_msg1/1, 
524
530
     pretty_otp6490_msg03,
525
531
     pretty_otp6490_msg04,
526
532
     pretty_otp6490_msg05,
527
 
     pretty_otp6490_msg06
 
533
     pretty_otp6490_msg06,
 
534
     pretty_otp7671_msg01,
 
535
     pretty_otp7671_msg02,
 
536
     pretty_otp7671_msg03,
 
537
     pretty_otp7671_msg04,
 
538
     pretty_otp7671_msg05
528
539
    ].
529
540
 
530
541
flex_pretty_tickets(suite) ->
4145
4156
    
4146
4157
 
4147
4158
 
 
4159
%% --------------------------------------------------------------
 
4160
%%
 
4161
 
 
4162
pretty_otp7671_msg01(suite) ->
 
4163
    [];
 
4164
pretty_otp7671_msg01(Config) when is_list(Config) ->
 
4165
%%     put(severity, trc),
 
4166
%%     put(dbg,      true),
 
4167
    d("pretty_otp7671_msg01 -> entry", []),
 
4168
    %% ?ACQUIRE_NODES(1, Config),
 
4169
    ok = pretty_otp7671( pretty_otp7671_msg01(), [] ),
 
4170
%%     erase(dbg),
 
4171
%%     erase(severity),
 
4172
    ok.
 
4173
 
 
4174
pretty_otp7671_msg02(suite) ->
 
4175
    [];
 
4176
pretty_otp7671_msg02(Config) when is_list(Config) ->
 
4177
%%     put(severity, trc),
 
4178
%%     put(dbg,      true),
 
4179
    d("pretty_otp7671_msg02 -> entry", []),
 
4180
    %% ?ACQUIRE_NODES(1, Config),
 
4181
    ok = pretty_otp7671( pretty_otp7671_msg02(), [] ),
 
4182
%%     erase(dbg),
 
4183
%%     erase(severity),
 
4184
   ok.
 
4185
 
 
4186
pretty_otp7671_msg03(suite) ->
 
4187
    [];
 
4188
pretty_otp7671_msg03(Config) when is_list(Config) ->
 
4189
%%     put(severity, trc),
 
4190
%%     put(dbg,      true),
 
4191
    d("pretty_otp7671_msg03 -> entry", []),
 
4192
    %% ?ACQUIRE_NODES(1, Config),
 
4193
    ok = pretty_otp7671( pretty_otp7671_msg03(), [] ),
 
4194
%%     erase(dbg),
 
4195
%%     erase(severity),
 
4196
    ok.
 
4197
 
 
4198
pretty_otp7671_msg04(suite) ->
 
4199
    [];
 
4200
pretty_otp7671_msg04(Config) when is_list(Config) ->
 
4201
%%     put(severity, trc),
 
4202
%%     put(dbg,      true),
 
4203
    d("pretty_otp7671_msg04 -> entry", []),
 
4204
    %% ?ACQUIRE_NODES(1, Config),
 
4205
    ok = pretty_otp7671( pretty_otp7671_msg04(), [] , error, ignore),
 
4206
%%     erase(dbg),
 
4207
%%     erase(severity),
 
4208
    ok.
 
4209
 
 
4210
pretty_otp7671_msg05(suite) ->
 
4211
    [];
 
4212
pretty_otp7671_msg05(Config) when is_list(Config) ->
 
4213
%%     put(severity, trc),
 
4214
%%     put(dbg,      true),
 
4215
    d("pretty_otp7671_msg05 -> entry", []),
 
4216
    Check = fun(M1, M2) -> cmp_otp7671_msg05(M1, M2) end,
 
4217
    ok = pretty_otp7671( pretty_otp7671_msg05(), [] , ok, ok, Check),
 
4218
%%     erase(dbg),
 
4219
%%     erase(severity),
 
4220
    ok.
 
4221
 
 
4222
 
 
4223
pretty_otp7671(Msg, Conf) ->
 
4224
    pretty_otp7671(Msg, Conf, ok).
 
4225
 
 
4226
pretty_otp7671(Msg, Conf, ExpectedEncode) ->
 
4227
    pretty_otp7671(Msg, Conf, ExpectedEncode, ok).
 
4228
 
 
4229
pretty_otp7671(Msg, Conf, ExpectedEncode, ExpectedDecode) ->
 
4230
    otp7671(Msg, megaco_pretty_text_encoder, Conf,
 
4231
            ExpectedEncode, ExpectedDecode).
 
4232
 
 
4233
pretty_otp7671(Msg, Conf, ExpectedEncode, ExpectedDecode, Check) ->
 
4234
    otp7671(Msg, megaco_pretty_text_encoder, Conf,
 
4235
            ExpectedEncode, ExpectedDecode, Check).
 
4236
 
 
4237
otp7671(Msg, Codec, Conf, ExpectedEncode, ExpectedDecode) ->
 
4238
    Check = fun(M1, M2) -> 
 
4239
                    exit({unexpected_decode_result, M1, M2})
 
4240
            end,
 
4241
    otp7671(Msg, Codec, Conf, ExpectedEncode, ExpectedDecode, Check).
 
4242
 
 
4243
otp7671(Msg, Codec, Conf, ExpectedEncode, ExpectedDecode, Check) ->
 
4244
    case (catch encode_message(Codec, Conf, Msg)) of
 
4245
        {error, _Reason} when ExpectedEncode =:= error ->
 
4246
            ok;
 
4247
        {error, Reason} when ExpectedEncode =:= ok ->
 
4248
            exit({unexpected_encode_failure, Reason});
 
4249
        {ok, Bin} when ExpectedEncode =:= error ->
 
4250
            exit({unexpected_encode_success, Msg, binary_to_list(Bin)});
 
4251
        {ok, Bin} when ExpectedEncode =:= ok ->
 
4252
            case decode_message(Codec, false, Conf, Bin) of
 
4253
                {ok, Msg} when ExpectedDecode =:= ok ->
 
4254
                    ok;
 
4255
                {ok, Msg2} when ExpectedDecode =:= ok ->
 
4256
                    Check(Msg, Msg2);
 
4257
                {ok, Msg} when ExpectedDecode =:= error ->
 
4258
                    exit({unexpected_decode_success, Msg});
 
4259
                {ok, Msg2} when ExpectedDecode =:= error ->
 
4260
                    exit({unexpected_decode_success, Msg, Msg2});
 
4261
                {error, _Reason} when ExpectedDecode =:= error ->
 
4262
                    ok;
 
4263
                {error, Reason} when ExpectedDecode == ok ->
 
4264
                    exit({unexpected_decode_failure, Msg, Reason})
 
4265
            end
 
4266
    end.
 
4267
 
 
4268
 
 
4269
pretty_otp7671_msg(DigitMapDesc) ->
 
4270
    AmmReq = cre_AmmReq([#megaco_term_id{id = ?A4444}],
 
4271
                        [{digitMapDescriptor, DigitMapDesc}]),
 
4272
    CmdReq = cre_CmdReq({modReq, AmmReq}),
 
4273
    msg_request(?MGC_MID, 10001, ?megaco_null_context_id, [CmdReq]).
 
4274
 
 
4275
pretty_otp7671_msg01() ->
 
4276
    Name         = "dialplan01",
 
4277
    DigitMapDesc = cre_DigitMapDesc(Name),
 
4278
    pretty_otp7671_msg(DigitMapDesc).
 
4279
 
 
4280
pretty_otp7671_msg02() ->
 
4281
    Name         = "dialplan02",
 
4282
    Body         = "(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)",
 
4283
    Value        = cre_DigitMapValue(Body),
 
4284
    DigitMapDesc = cre_DigitMapDesc(Name, Value),
 
4285
    pretty_otp7671_msg(DigitMapDesc).
 
4286
 
 
4287
pretty_otp7671_msg03() ->
 
4288
    Body         = "(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)",
 
4289
    Value        = cre_DigitMapValue(Body),
 
4290
    DigitMapDesc = cre_DigitMapDesc(Value),
 
4291
    pretty_otp7671_msg(DigitMapDesc).
 
4292
 
 
4293
pretty_otp7671_msg04() ->
 
4294
    DigitMapDesc = cre_DigitMapDesc(),
 
4295
    pretty_otp7671_msg(DigitMapDesc).
 
4296
 
 
4297
pretty_otp7671_msg05() ->
 
4298
    {'MegacoMessage',asn1_NOVALUE,
 
4299
     {'Message',?VERSION,
 
4300
      {domainName,{'DomainName',"tgc",asn1_NOVALUE}},
 
4301
      {transactions,
 
4302
       [{transactionRequest,
 
4303
         {'TransactionRequest',12582952,
 
4304
          [{'ActionRequest',0,asn1_NOVALUE,asn1_NOVALUE,
 
4305
            [{'CommandRequest',
 
4306
              {modReq,
 
4307
               {'AmmRequest',
 
4308
                [{megaco_term_id,false,["root"]}],
 
4309
                [{digitMapDescriptor,
 
4310
                  {'DigitMapDescriptor',"dialplan1",
 
4311
                   {'DigitMapValue',asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,[],
 
4312
                    asn1_NOVALUE}}}]}},
 
4313
              asn1_NOVALUE,asn1_NOVALUE}]}]}}]}}}.
 
4314
 
 
4315
cmp_otp7671_msg05(#'MegacoMessage'{authHeader = asn1_NOVALUE, 
 
4316
                                   mess       = M1}, 
 
4317
                  #'MegacoMessage'{authHeader = asn1_NOVALUE, 
 
4318
                                   mess       = M2}) ->
 
4319
    #'Message'{messageBody = Body1} = M1,
 
4320
    #'Message'{messageBody = Body2} = M2,
 
4321
    {transactions, Trans1} = Body1,
 
4322
    {transactions, Trans2} = Body2,
 
4323
    [{transactionRequest, TR1}] = Trans1,
 
4324
    [{transactionRequest, TR2}] = Trans2,
 
4325
    #'TransactionRequest'{actions = Acts1} = TR1,
 
4326
    #'TransactionRequest'{actions = Acts2} = TR2,
 
4327
    [#'ActionRequest'{commandRequests = CR1}] = Acts1,
 
4328
    [#'ActionRequest'{commandRequests = CR2}] = Acts2,
 
4329
    [#'CommandRequest'{command = Cmd1}] = CR1,
 
4330
    [#'CommandRequest'{command = Cmd2}] = CR2,
 
4331
    {modReq, #'AmmRequest'{descriptors = Descs1}} = Cmd1,
 
4332
    {modReq, #'AmmRequest'{descriptors = Descs2}} = Cmd2,
 
4333
    [{digitMapDescriptor, 
 
4334
      #'DigitMapDescriptor'{digitMapName = Name, 
 
4335
                            digitMapValue = Value1}}] = Descs1,
 
4336
    [{digitMapDescriptor, 
 
4337
      #'DigitMapDescriptor'{digitMapName = Name, 
 
4338
                            digitMapValue = Value2}}] = Descs2,
 
4339
    #'DigitMapValue'{startTimer    = asn1_NOVALUE,
 
4340
                     shortTimer    = asn1_NOVALUE,
 
4341
                     longTimer     = asn1_NOVALUE,
 
4342
                     digitMapBody  = [],
 
4343
                     durationTimer = asn1_NOVALUE} = Value1,
 
4344
    asn1_NOVALUE = Value2,
 
4345
    ok.
 
4346
 
 
4347
 
4148
4348
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4149
4349
 
4150
4350
expect_codec(Expect, Codec, Msg, Conf) ->
6864
7064
 
6865
7065
 
6866
7066
%% DigitMap related
 
7067
cre_DigitMapDesc() ->
 
7068
    ?MSG_LIB:cre_DigitMapDescriptor().
 
7069
cre_DigitMapDesc(NameOrVal) ->
 
7070
    ?MSG_LIB:cre_DigitMapDescriptor(NameOrVal).
6867
7071
cre_DigitMapDesc(Name, Val) ->
6868
7072
    ?MSG_LIB:cre_DigitMapDescriptor(Name, Val).
6869
7073