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

« 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-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%<copyright>
2
 
%% <year>2006-2007</year>
 
2
%% <year>2006-2008</year>
3
3
%% <holder>Ericsson AB, All Rights Reserved</holder>
4
4
%%</copyright>
5
5
%%<legalnotice>
135
135
 
136
136
         flex_compact_tickets/1, 
137
137
         flex_compact_otp4299_msg1/1, 
 
138
         flex_compact_otp7431_msg01/1,
 
139
         flex_compact_otp7431_msg02/1,
 
140
         flex_compact_otp7431_msg03/1,
 
141
         flex_compact_otp7431_msg04/1,
 
142
         flex_compact_otp7431_msg05/1,
 
143
         flex_compact_otp7431_msg06/1,
 
144
         flex_compact_otp7431_msg07/1,
 
145
 
138
146
 
139
147
         pretty_tickets/1, 
140
148
         pretty_otp4632_msg1/1, 
196
204
         flex_pretty_otp5803_msg02/1,
197
205
         flex_pretty_otp5805_msg01/1,
198
206
         flex_pretty_otp5836_msg01/1,
 
207
         flex_pretty_otp7431_msg01/1,
 
208
         flex_pretty_otp7431_msg02/1,
 
209
         flex_pretty_otp7431_msg03/1,
 
210
         flex_pretty_otp7431_msg04/1,
 
211
         flex_pretty_otp7431_msg05/1,
 
212
         flex_pretty_otp7431_msg06/1,
 
213
         flex_pretty_otp7431_msg07/1,
199
214
 
200
215
         init_per_testcase/2, fin_per_testcase/2]).  
201
216
 
485
500
 
486
501
flex_compact_tickets_cases() ->
487
502
    [
488
 
     flex_compact_otp4299_msg1
 
503
     flex_compact_otp4299_msg1,
 
504
     flex_compact_otp7431_msg01,
 
505
     flex_compact_otp7431_msg02,
 
506
     flex_compact_otp7431_msg03, 
 
507
     flex_compact_otp7431_msg04,
 
508
     flex_compact_otp7431_msg05,
 
509
     flex_compact_otp7431_msg06,
 
510
     flex_compact_otp7431_msg07
489
511
    ].
490
512
 
491
513
                
557
579
     flex_pretty_otp5803_msg01,
558
580
     flex_pretty_otp5803_msg02,
559
581
     flex_pretty_otp5805_msg01,
560
 
     flex_pretty_otp5836_msg01
 
582
     flex_pretty_otp5836_msg01,
 
583
     flex_pretty_otp7431_msg01,
 
584
     flex_pretty_otp7431_msg02,
 
585
     flex_pretty_otp7431_msg03, 
 
586
     flex_pretty_otp7431_msg04,
 
587
     flex_pretty_otp7431_msg05,
 
588
     flex_pretty_otp7431_msg06,
 
589
     flex_pretty_otp7431_msg07
561
590
    ].
562
591
 
563
592
                
2198
2227
    ok.
2199
2228
 
2200
2229
 
 
2230
flex_compact_otp7431_msg01(suite) ->
 
2231
    [];
 
2232
flex_compact_otp7431_msg01(Config) when list(Config) ->
 
2233
    %% put(severity,trc),
 
2234
    %% put(dbg,true),
 
2235
    d("flex_comppact_otp7431_msg01 -> entry", []),
 
2236
    Conf = flex_scanner_conf(Config),
 
2237
    flex_compact_otp7431(ok, flex_compact_otp7431_msg1(), [Conf]).
 
2238
 
 
2239
flex_compact_otp7431_msg02(suite) ->
 
2240
    [];
 
2241
flex_compact_otp7431_msg02(Config) when list(Config) ->
 
2242
    %% put(severity,trc),
 
2243
    %% put(dbg,true),
 
2244
    d("flex_comppact_otp7431_msg02 -> entry", []),
 
2245
    Conf = flex_scanner_conf(Config),
 
2246
    flex_compact_otp7431(error, flex_compact_otp7431_msg2(), [Conf]).
 
2247
 
 
2248
flex_compact_otp7431_msg03(suite) ->
 
2249
    [];
 
2250
flex_compact_otp7431_msg03(Config) when list(Config) ->
 
2251
    %% put(severity,trc),
 
2252
    %% put(dbg,true),
 
2253
    d("flex_comppact_otp7431_msg03 -> entry", []),
 
2254
    Conf = flex_scanner_conf(Config),
 
2255
    flex_compact_otp7431(error, flex_compact_otp7431_msg3(), [Conf]).
 
2256
 
 
2257
flex_compact_otp7431_msg04(suite) ->
 
2258
    [];
 
2259
flex_compact_otp7431_msg04(Config) when list(Config) ->
 
2260
    %% put(severity,trc),
 
2261
    %% put(dbg,true),
 
2262
    d("flex_comppact_otp7431_msg04 -> entry", []),
 
2263
    Conf = flex_scanner_conf(Config),
 
2264
    flex_compact_otp7431(error, flex_compact_otp7431_msg4(), [Conf]).
 
2265
 
 
2266
flex_compact_otp7431_msg05(suite) ->
 
2267
    [];
 
2268
flex_compact_otp7431_msg05(Config) when list(Config) ->
 
2269
    %% put(severity,trc),
 
2270
    %% put(dbg,true),
 
2271
    d("flex_comppact_otp7431_msg05 -> entry", []),
 
2272
    Conf = flex_scanner_conf(Config),
 
2273
    flex_compact_otp7431(error, flex_compact_otp7431_msg5(), [Conf]).
 
2274
 
 
2275
flex_compact_otp7431_msg06(suite) ->
 
2276
    [];
 
2277
flex_compact_otp7431_msg06(Config) when list(Config) ->
 
2278
    %% put(severity,trc),
 
2279
    %% put(dbg,true),
 
2280
    d("flex_comppact_otp7431_msg06 -> entry", []),
 
2281
    Conf = flex_scanner_conf(Config),
 
2282
    flex_compact_otp7431(error, flex_compact_otp7431_msg6(), [Conf]).
 
2283
 
 
2284
flex_compact_otp7431_msg07(suite) ->
 
2285
    [];
 
2286
flex_compact_otp7431_msg07(Config) when list(Config) ->
 
2287
    %% put(severity,trc),
 
2288
    %% put(dbg,true),
 
2289
    d("flex_comppact_otp7431_msg07 -> entry", []),
 
2290
    Conf = flex_scanner_conf(Config),
 
2291
    flex_compact_otp7431(error, flex_compact_otp7431_msg7(), [Conf]).
 
2292
 
 
2293
 
 
2294
flex_compact_otp7431(Expected, Msg, Conf) ->
 
2295
    otp7431(Expected, megaco_compact_text_encoder, Msg, Conf).
 
2296
 
 
2297
flex_compact_otp7431_msg1() ->
 
2298
    "!/1 [124.124.124.222]:55555
 
2299
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
2300
v=0
 
2301
o=- 2890844526 2890842807 IN IP4 124.124.124.222
 
2302
s=-
 
2303
t= 0 0
 
2304
c=IN IP4 124.124.124.222
 
2305
m=audio 2222 RTP/AVP 4
 
2306
a=ptime:30
 
2307
a=recvonly
 
2308
}}}}}}".
 
2309
 
 
2310
flex_compact_otp7431_msg2() ->
 
2311
    "!/1 [124.124.124.222]:55555
 
2312
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
2313
v=0
 
2314
o=- 2890844526 2890842807 IN IP4 124.124.124.222
 
2315
s=-
 
2316
t= 0 0
 
2317
c=IN IP4 124.124.124.222
 
2318
m=audio 2222 RTP/AVP 4
 
2319
a=ptime:30
 
2320
a=     }
 
2321
}}}}}".
 
2322
 
 
2323
 
 
2324
flex_compact_otp7431_msg3() ->
 
2325
    "!/1 [124.124.124.222]:55555
 
2326
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
2327
v=0
 
2328
o=- 2890844526 2890842807 IN IP4 124.124.124.222
 
2329
s=-
 
2330
t= 0 0
 
2331
c=IN IP4 124.124.124.222
 
2332
m=audio 2222 RTP/AVP 4
 
2333
a=ptime:30
 
2334
a     }
 
2335
}}}}}".
 
2336
 
 
2337
 
 
2338
flex_compact_otp7431_msg4() ->
 
2339
    "!/1 [124.124.124.222]:55555
 
2340
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
2341
v=0
 
2342
o=- 2890844526 2890842807 IN IP4 124.124.124.222
 
2343
s=-
 
2344
t= 0 0
 
2345
c=IN IP4 124.124.124.222
 
2346
m=audio 2222 RTP/AVP 4
 
2347
a=ptime:30
 
2348
a}
 
2349
}}}}}".
 
2350
 
 
2351
 
 
2352
flex_compact_otp7431_msg5() ->
 
2353
    "!/1 [124.124.124.222]:55555
 
2354
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
2355
v=       }
 
2356
}}}}}".
 
2357
 
 
2358
 
 
2359
flex_compact_otp7431_msg6() ->
 
2360
    "!/1 [124.124.124.222]:55555
 
2361
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
2362
v       }
 
2363
}}}}}".
 
2364
 
 
2365
flex_compact_otp7431_msg7() ->
 
2366
    "!/1 [124.124.124.222]:55555
 
2367
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
2368
v}
 
2369
}}}}}".
 
2370
 
 
2371
 
2201
2372
%% ==============================================================
2202
2373
%%
2203
2374
%% P r e t t y   T e s t c a s e s
3891
4062
    ok.
3892
4063
 
3893
4064
 
 
4065
flex_pretty_otp7431_msg01(suite) ->
 
4066
    [];
 
4067
flex_pretty_otp7431_msg01(Config) when list(Config) ->
 
4068
    d("flex_pretty_otp7431_msg01 -> entry", []),
 
4069
    ?ACQUIRE_NODES(1, Config),
 
4070
    Conf = flex_scanner_conf(Config),
 
4071
    flex_pretty_otp7431(ok, flex_pretty_otp7431_msg1(), [Conf]).
 
4072
 
 
4073
flex_pretty_otp7431_msg02(suite) ->
 
4074
    [];
 
4075
flex_pretty_otp7431_msg02(Config) when list(Config) ->
 
4076
    %%     put(severity,trc),
 
4077
    %%     put(dbg,true),
 
4078
    d("flex_pretty_otp7431_msg02 -> entry", []),
 
4079
    ?ACQUIRE_NODES(1, Config),
 
4080
    Conf = flex_scanner_conf(Config),
 
4081
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg2(), [Conf]).
 
4082
 
 
4083
flex_pretty_otp7431_msg03(suite) ->
 
4084
    [];
 
4085
flex_pretty_otp7431_msg03(Config) when list(Config) ->
 
4086
    %%     put(severity,trc),
 
4087
    %%     put(dbg,true),
 
4088
    d("flex_pretty_otp7431_msg03 -> entry", []),
 
4089
    ?ACQUIRE_NODES(1, Config),
 
4090
    Conf = flex_scanner_conf(Config),
 
4091
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg3(), [Conf]).
 
4092
 
 
4093
flex_pretty_otp7431_msg04(suite) ->
 
4094
    [];
 
4095
flex_pretty_otp7431_msg04(Config) when list(Config) ->
 
4096
    d("flex_pretty_otp7431_msg04 -> entry", []),
 
4097
    ?ACQUIRE_NODES(1, Config),
 
4098
    Conf = flex_scanner_conf(Config),
 
4099
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg4(), [Conf]).
 
4100
 
 
4101
flex_pretty_otp7431_msg05(suite) ->
 
4102
    [];
 
4103
flex_pretty_otp7431_msg05(Config) when list(Config) ->
 
4104
    d("flex_pretty_otp7431_msg05 -> entry", []),
 
4105
    ?ACQUIRE_NODES(1, Config),
 
4106
    Conf = flex_scanner_conf(Config),
 
4107
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg5(), [Conf]).
 
4108
 
 
4109
flex_pretty_otp7431_msg06(suite) ->
 
4110
    [];
 
4111
flex_pretty_otp7431_msg06(Config) when list(Config) ->
 
4112
    d("flex_pretty_otp7431_msg06 -> entry", []),
 
4113
    ?ACQUIRE_NODES(1, Config),
 
4114
    Conf = flex_scanner_conf(Config),
 
4115
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg6(), [Conf]).
 
4116
 
 
4117
flex_pretty_otp7431_msg07(suite) ->
 
4118
    [];
 
4119
flex_pretty_otp7431_msg07(Config) when list(Config) ->
 
4120
    d("flex_pretty_otp7431_msg07 -> entry", []),
 
4121
    ?ACQUIRE_NODES(1, Config),
 
4122
    Conf = flex_scanner_conf(Config),
 
4123
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg7(), [Conf]).
 
4124
 
 
4125
flex_pretty_otp7431(Expected, Msg, Conf) ->
 
4126
    otp7431(Expected, megaco_pretty_text_encoder, Msg, Conf).
 
4127
 
 
4128
otp7431(Expected, Codec, Msg0, Conf0) ->
 
4129
    Bin0 = list_to_binary(Msg0),
 
4130
    Conf = [?EC_V3|Conf0], 
 
4131
    case decode_message(Codec, false, Conf, Bin0) of
 
4132
        {ok, _Msg1} when Expected =:= ok ->
 
4133
            io:format(" decoded", []);
 
4134
        {error, {bad_property_parm, Reason}} when (Expected =:= error) andalso 
 
4135
                                                  is_list(Reason) ->
 
4136
            io:format("expected result: ~s", [Reason]),
 
4137
            ok;
 
4138
        Else ->
 
4139
            io:format("unexpected result", []),
 
4140
            exit({unexpected_decode_result, Else})
 
4141
    end.
 
4142
 
 
4143
 
 
4144
flex_pretty_otp7431_msg1() ->
 
4145
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
4146
   Context = 2000 {
 
4147
               Add = A4444,
 
4148
               Add = A4445 {
 
4149
                       Media {
 
4150
                         Stream = 1 {
 
4151
                                    Local { 
 
4152
                                      v=0 
 
4153
                                      o=- 2890844526 2890842807 IN IP4 124.124.124.222 
 
4154
                                      s=- 
 
4155
                                      t= 0 0 
 
4156
                                      c=IN IP4 124.124.124.222 
 
4157
                                      m=audio 2222 RTP/AVP 4 
 
4158
                                      a=ptime:30 
 
4159
                                      a=recvonly 
 
4160
                                     } ; RTP profile for G.723.1 is 4
 
4161
                                   }
 
4162
                        }
 
4163
                      }
 
4164
              } 
 
4165
       }".
 
4166
 
 
4167
flex_pretty_otp7431_msg2() ->
 
4168
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
4169
   Context = 2000 {
 
4170
               Add = A4444,
 
4171
               Add = A4445 {
 
4172
                       Media {
 
4173
                         Stream = 1 {
 
4174
                                    Local { 
 
4175
                                      v=0 
 
4176
                                      o=- 2890844526 2890842807 IN IP4 124.124.124.222 
 
4177
                                      s=- 
 
4178
                                      t= 0 0 
 
4179
                                      c=IN IP4 124.124.124.222 
 
4180
                                      m=audio 2222 RTP/AVP 4 
 
4181
                                      a=ptime:30 
 
4182
                                      a=             }
 
4183
                                   }
 
4184
                        }
 
4185
                      }
 
4186
              } 
 
4187
       }".
 
4188
 
 
4189
flex_pretty_otp7431_msg3() ->
 
4190
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
4191
   Context = 2000 {
 
4192
               Add = A4444,
 
4193
               Add = A4445 {
 
4194
                       Media {
 
4195
                         Stream = 1 {
 
4196
                                    Local { 
 
4197
                                      v=0 
 
4198
                                      o=- 2890844526 2890842807 IN IP4 124.124.124.222 
 
4199
                                      s=- 
 
4200
                                      t= 0 0 
 
4201
                                      c=IN IP4 124.124.124.222 
 
4202
                                      m=audio 2222 RTP/AVP 4 
 
4203
                                      a=ptime:30 
 
4204
                                      a             }
 
4205
                                   }
 
4206
                        }
 
4207
                      }
 
4208
              } 
 
4209
       }".
 
4210
 
 
4211
flex_pretty_otp7431_msg4() ->
 
4212
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
4213
   Context = 2000 {
 
4214
               Add = A4444,
 
4215
               Add = A4445 {
 
4216
                       Media {
 
4217
                         Stream = 1 {
 
4218
                                    Local { 
 
4219
                                      v=0 
 
4220
                                      o=- 2890844526 2890842807 IN IP4 124.124.124.222 
 
4221
                                      s=- 
 
4222
                                      t= 0 0 
 
4223
                                      c=IN IP4 124.124.124.222 
 
4224
                                      m=audio 2222 RTP/AVP 4 
 
4225
                                      a=ptime:30 
 
4226
                                      a}
 
4227
                                   }
 
4228
                        }
 
4229
                      }
 
4230
              } 
 
4231
       }".
 
4232
 
 
4233
flex_pretty_otp7431_msg5() ->
 
4234
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
4235
   Context = 2000 {
 
4236
               Add = A4444,
 
4237
               Add = A4445 {
 
4238
                       Media {
 
4239
                         Stream = 1 {
 
4240
                                    Local { 
 
4241
                                      v=            }
 
4242
                                   }
 
4243
                        }
 
4244
                      }
 
4245
              } 
 
4246
       }".
 
4247
 
 
4248
flex_pretty_otp7431_msg6() ->
 
4249
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
4250
   Context = 2000 {
 
4251
               Add = A4444,
 
4252
               Add = A4445 {
 
4253
                       Media {
 
4254
                         Stream = 1 {
 
4255
                                    Local { 
 
4256
                                      v            }
 
4257
                                   }
 
4258
                        }
 
4259
                      }
 
4260
              } 
 
4261
       }".
 
4262
 
 
4263
flex_pretty_otp7431_msg7() ->
 
4264
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
4265
   Context = 2000 {
 
4266
               Add = A4444,
 
4267
               Add = A4445 {
 
4268
                       Media {
 
4269
                         Stream = 1 {
 
4270
                                    Local { 
 
4271
                                      v}
 
4272
                                   }
 
4273
                        }
 
4274
                      }
 
4275
              } 
 
4276
       }".
 
4277
 
 
4278
 
3894
4279
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3895
4280
 
3896
4281
msgs() ->