~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20090215164252-dxpjjuq108nz4noa
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>2003-2007</year>
 
2
%% <year>2003-2008</year>
3
3
%% <holder>Ericsson AB, All Rights Reserved</holder>
4
4
%%</copyright>
5
5
%%<legalnotice>
136
136
         compact_otp6017_msg03/1,
137
137
         compact_otp7138_msg01/1,
138
138
         compact_otp7138_msg02/1,
 
139
         compact_otp7457_msg01/1,
 
140
         compact_otp7457_msg02/1,
 
141
         compact_otp7457_msg03/1,
 
142
         compact_otp7534_msg01/1,
 
143
         compact_otp7576_msg01/1,
139
144
 
140
145
         flex_compact_tickets/1, 
141
146
         flex_compact_otp7138_msg01/1, 
142
147
         flex_compact_otp7138_msg02/1, 
 
148
         flex_compact_otp7431_msg01/1,
 
149
         flex_compact_otp7431_msg02/1,
 
150
         flex_compact_otp7431_msg03/1,
 
151
         flex_compact_otp7431_msg04/1,
 
152
         flex_compact_otp7431_msg05/1,
 
153
         flex_compact_otp7431_msg06/1,
 
154
         flex_compact_otp7431_msg07/1,
 
155
         flex_compact_otp7457_msg01/1, 
 
156
         flex_compact_otp7457_msg02/1, 
 
157
         flex_compact_otp7457_msg03/1, 
 
158
         flex_compact_otp7534_msg01/1,
 
159
         flex_compact_otp7573_msg01/1,
 
160
         flex_compact_otp7576_msg01/1, 
143
161
 
144
162
         pretty_tickets/1, 
145
163
         pretty_otp4632_msg1/1, 
192
210
         flex_pretty_otp5600_msg2/1,
193
211
         flex_pretty_otp5601_msg1/1,
194
212
         flex_pretty_otp5793_msg01/1,
 
213
         flex_pretty_otp7431_msg01/1,
 
214
         flex_pretty_otp7431_msg02/1,
 
215
         flex_pretty_otp7431_msg03/1,
 
216
         flex_pretty_otp7431_msg04/1,
 
217
         flex_pretty_otp7431_msg05/1,
 
218
         flex_pretty_otp7431_msg06/1,
 
219
         flex_pretty_otp7431_msg07/1,
195
220
 
196
221
         init_per_testcase/2, fin_per_testcase/2]).  
197
222
 
614
639
     compact_otp6017_msg02,
615
640
     compact_otp6017_msg03,
616
641
     compact_otp7138_msg01,
617
 
     compact_otp7138_msg02
 
642
     compact_otp7138_msg02,
 
643
     compact_otp7457_msg01,
 
644
     compact_otp7457_msg02,
 
645
     compact_otp7457_msg03,
 
646
     compact_otp7534_msg01,
 
647
     compact_otp7576_msg01
618
648
    ].
619
649
 
620
650
flex_compact_tickets(suite) ->
625
655
flex_compact_tickets_cases() ->
626
656
    [
627
657
     flex_compact_otp7138_msg01,
628
 
     flex_compact_otp7138_msg02
 
658
     flex_compact_otp7138_msg02,
 
659
     flex_compact_otp7431_msg01,
 
660
     flex_compact_otp7431_msg02,
 
661
     flex_compact_otp7431_msg03, 
 
662
     flex_compact_otp7431_msg04,
 
663
     flex_compact_otp7431_msg05,
 
664
     flex_compact_otp7431_msg06,
 
665
     flex_compact_otp7431_msg07,
 
666
     flex_compact_otp7138_msg02,
 
667
     flex_compact_otp7457_msg01,
 
668
     flex_compact_otp7457_msg02,
 
669
     flex_compact_otp7457_msg03,
 
670
     flex_compact_otp7534_msg01,
 
671
     flex_compact_otp7573_msg01,
 
672
     flex_compact_otp7576_msg01
629
673
    ].
630
674
 
631
675
pretty_tickets(suite) ->
686
730
     flex_pretty_otp5600_msg1,
687
731
     flex_pretty_otp5600_msg2,
688
732
     flex_pretty_otp5601_msg1,
689
 
     flex_pretty_otp5793_msg01
 
733
     flex_pretty_otp5793_msg01,
 
734
     flex_pretty_otp7431_msg01,
 
735
     flex_pretty_otp7431_msg02,
 
736
     flex_pretty_otp7431_msg03, 
 
737
     flex_pretty_otp7431_msg04,
 
738
     flex_pretty_otp7431_msg05,
 
739
     flex_pretty_otp7431_msg06,
 
740
     flex_pretty_otp7431_msg07
690
741
    ].
691
742
 
692
743
 
836
887
    pretty_otp5793(ok, pretty_otp5793_msg1(), [Conf]).
837
888
 
838
889
 
 
890
flex_pretty_otp7431_msg01(suite) ->
 
891
    [];
 
892
flex_pretty_otp7431_msg01(Config) when list(Config) ->
 
893
    d("flex_pretty_otp7431_msg01 -> entry", []),
 
894
    ?ACQUIRE_NODES(1, Config),
 
895
    Conf = flex_scanner_conf(Config),
 
896
    flex_pretty_otp7431(ok, flex_pretty_otp7431_msg1(), [Conf]).
 
897
 
 
898
flex_pretty_otp7431_msg02(suite) ->
 
899
    [];
 
900
flex_pretty_otp7431_msg02(Config) when list(Config) ->
 
901
    %%     put(severity,trc),
 
902
    %%     put(dbg,true),
 
903
    d("flex_pretty_otp7431_msg02 -> entry", []),
 
904
    ?ACQUIRE_NODES(1, Config),
 
905
    Conf = flex_scanner_conf(Config),
 
906
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg2(), [Conf]).
 
907
 
 
908
flex_pretty_otp7431_msg03(suite) ->
 
909
    [];
 
910
flex_pretty_otp7431_msg03(Config) when list(Config) ->
 
911
    %%     put(severity,trc),
 
912
    %%     put(dbg,true),
 
913
    d("flex_pretty_otp7431_msg03 -> entry", []),
 
914
    ?ACQUIRE_NODES(1, Config),
 
915
    Conf = flex_scanner_conf(Config),
 
916
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg3(), [Conf]).
 
917
 
 
918
flex_pretty_otp7431_msg04(suite) ->
 
919
    [];
 
920
flex_pretty_otp7431_msg04(Config) when list(Config) ->
 
921
    d("flex_pretty_otp7431_msg04 -> entry", []),
 
922
    ?ACQUIRE_NODES(1, Config),
 
923
    Conf = flex_scanner_conf(Config),
 
924
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg4(), [Conf]).
 
925
 
 
926
flex_pretty_otp7431_msg05(suite) ->
 
927
    [];
 
928
flex_pretty_otp7431_msg05(Config) when list(Config) ->
 
929
    d("flex_pretty_otp7431_msg05 -> entry", []),
 
930
    ?ACQUIRE_NODES(1, Config),
 
931
    Conf = flex_scanner_conf(Config),
 
932
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg5(), [Conf]).
 
933
 
 
934
flex_pretty_otp7431_msg06(suite) ->
 
935
    [];
 
936
flex_pretty_otp7431_msg06(Config) when list(Config) ->
 
937
    d("flex_pretty_otp7431_msg06 -> entry", []),
 
938
    ?ACQUIRE_NODES(1, Config),
 
939
    Conf = flex_scanner_conf(Config),
 
940
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg6(), [Conf]).
 
941
 
 
942
flex_pretty_otp7431_msg07(suite) ->
 
943
    [];
 
944
flex_pretty_otp7431_msg07(Config) when list(Config) ->
 
945
    d("flex_pretty_otp7431_msg07 -> entry", []),
 
946
    ?ACQUIRE_NODES(1, Config),
 
947
    Conf = flex_scanner_conf(Config),
 
948
    flex_pretty_otp7431(error, flex_pretty_otp7431_msg7(), [Conf]).
 
949
 
 
950
flex_pretty_otp7431(Expected, Msg, Conf) ->
 
951
    otp7431(Expected, megaco_pretty_text_encoder, Msg, Conf).
 
952
 
 
953
otp7431(Expected, Codec, Msg0, Conf) ->
 
954
    Bin0 = list_to_binary(Msg0),
 
955
    case decode_message(Codec, false, Conf, Bin0) of
 
956
        {ok, _Msg1} when Expected =:= ok ->
 
957
            io:format(" decoded", []);
 
958
        {error, {bad_property_parm, Reason}} when (Expected =:= error) andalso 
 
959
                                                  is_list(Reason) ->
 
960
            io:format("expected result: ~s", [Reason]),
 
961
            ok;
 
962
        Else ->
 
963
            io:format("unexpected result", []),
 
964
            exit({unexpected_decode_result, Else})
 
965
    end.
 
966
 
 
967
 
 
968
flex_pretty_otp7431_msg1() ->
 
969
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
970
   Context = 2000 {
 
971
               Add = A4444,
 
972
               Add = A4445 {
 
973
                       Media {
 
974
                         Stream = 1 {
 
975
                                    Local { 
 
976
                                      v=0 
 
977
                                      o=- 2890844526 2890842807 IN IP4 124.124.124.222 
 
978
                                      s=- 
 
979
                                      t= 0 0 
 
980
                                      c=IN IP4 124.124.124.222 
 
981
                                      m=audio 2222 RTP/AVP 4 
 
982
                                      a=ptime:30 
 
983
                                      a=recvonly 
 
984
                                     } ; RTP profile for G.723.1 is 4
 
985
                                   }
 
986
                        }
 
987
                      }
 
988
              } 
 
989
       }".
 
990
 
 
991
flex_pretty_otp7431_msg2() ->
 
992
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
993
   Context = 2000 {
 
994
               Add = A4444,
 
995
               Add = A4445 {
 
996
                       Media {
 
997
                         Stream = 1 {
 
998
                                    Local { 
 
999
                                      v=0 
 
1000
                                      o=- 2890844526 2890842807 IN IP4 124.124.124.222 
 
1001
                                      s=- 
 
1002
                                      t= 0 0 
 
1003
                                      c=IN IP4 124.124.124.222 
 
1004
                                      m=audio 2222 RTP/AVP 4 
 
1005
                                      a=ptime:30 
 
1006
                                      a=             }
 
1007
                                   }
 
1008
                        }
 
1009
                      }
 
1010
              } 
 
1011
       }".
 
1012
 
 
1013
flex_pretty_otp7431_msg3() ->
 
1014
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
1015
   Context = 2000 {
 
1016
               Add = A4444,
 
1017
               Add = A4445 {
 
1018
                       Media {
 
1019
                         Stream = 1 {
 
1020
                                    Local { 
 
1021
                                      v=0 
 
1022
                                      o=- 2890844526 2890842807 IN IP4 124.124.124.222 
 
1023
                                      s=- 
 
1024
                                      t= 0 0 
 
1025
                                      c=IN IP4 124.124.124.222 
 
1026
                                      m=audio 2222 RTP/AVP 4 
 
1027
                                      a=ptime:30 
 
1028
                                      a             }
 
1029
                                   }
 
1030
                        }
 
1031
                      }
 
1032
              } 
 
1033
       }".
 
1034
 
 
1035
flex_pretty_otp7431_msg4() ->
 
1036
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
1037
   Context = 2000 {
 
1038
               Add = A4444,
 
1039
               Add = A4445 {
 
1040
                       Media {
 
1041
                         Stream = 1 {
 
1042
                                    Local { 
 
1043
                                      v=0 
 
1044
                                      o=- 2890844526 2890842807 IN IP4 124.124.124.222 
 
1045
                                      s=- 
 
1046
                                      t= 0 0 
 
1047
                                      c=IN IP4 124.124.124.222 
 
1048
                                      m=audio 2222 RTP/AVP 4 
 
1049
                                      a=ptime:30 
 
1050
                                      a}
 
1051
                                   }
 
1052
                        }
 
1053
                      }
 
1054
              } 
 
1055
       }".
 
1056
 
 
1057
flex_pretty_otp7431_msg5() ->
 
1058
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
1059
   Context = 2000 {
 
1060
               Add = A4444,
 
1061
               Add = A4445 {
 
1062
                       Media {
 
1063
                         Stream = 1 {
 
1064
                                    Local { 
 
1065
                                      v=            }
 
1066
                                   }
 
1067
                        }
 
1068
                      }
 
1069
              } 
 
1070
       }".
 
1071
 
 
1072
flex_pretty_otp7431_msg6() ->
 
1073
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
1074
   Context = 2000 {
 
1075
               Add = A4444,
 
1076
               Add = A4445 {
 
1077
                       Media {
 
1078
                         Stream = 1 {
 
1079
                                    Local { 
 
1080
                                      v            }
 
1081
                                   }
 
1082
                        }
 
1083
                      }
 
1084
              } 
 
1085
       }".
 
1086
 
 
1087
flex_pretty_otp7431_msg7() ->
 
1088
    "MEGACO/" ?VERSION_STR " [124.124.124.222]:55555 Reply = 10003 {
 
1089
   Context = 2000 {
 
1090
               Add = A4444,
 
1091
               Add = A4445 {
 
1092
                       Media {
 
1093
                         Stream = 1 {
 
1094
                                    Local { 
 
1095
                                      v}
 
1096
                                   }
 
1097
                        }
 
1098
                      }
 
1099
              } 
 
1100
       }".
 
1101
 
 
1102
 
 
1103
 
839
1104
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
840
1105
 
841
1106
compact_test_msgs(suite) ->
2548
2813
    end.
2549
2814
 
2550
2815
            
 
2816
compact_otp7457_msg01(suite) ->
 
2817
    [];
 
2818
compact_otp7457_msg01(Config) when is_list(Config) ->
 
2819
    put(dbg, true),
 
2820
    put(severity, trc),
 
2821
    d("compact_otp7457_msg01 -> entry", []),
 
2822
    ?ACQUIRE_NODES(1, Config),
 
2823
    Msg = compact_otp7457_msg01(),
 
2824
    EC  = [],
 
2825
    ok = compact_otp7457(EC, Msg),
 
2826
    ok.
 
2827
 
 
2828
compact_otp7457_msg02(suite) ->
 
2829
    [];
 
2830
compact_otp7457_msg02(Config) when is_list(Config) ->
 
2831
    put(dbg, true),
 
2832
    put(severity, trc),
 
2833
    d("compact_otp7457_msg02 -> entry", []),
 
2834
    ?ACQUIRE_NODES(1, Config),
 
2835
    Msg = compact_otp7457_msg02(),
 
2836
    EC  = [],
 
2837
    ok = compact_otp7457(EC, Msg),
 
2838
    ok.
 
2839
 
 
2840
compact_otp7457_msg03(suite) ->
 
2841
    [];
 
2842
compact_otp7457_msg03(Config) when is_list(Config) ->
 
2843
    put(dbg, true),
 
2844
    put(severity, trc),
 
2845
    d("compact_otp7457_msg03 -> entry", []),
 
2846
    ?ACQUIRE_NODES(1, Config),
 
2847
    Msg = compact_otp7457_msg03(),
 
2848
    EC  = [],
 
2849
    ok = compact_otp7457(EC, Msg),
 
2850
    ok.
 
2851
 
 
2852
compact_otp7457_msg01() ->
 
2853
    <<"!/2 <mg1>\nT=15{C=-{SC=tdm12/1/1/*{SV{MT=RS,RE=900}}}}\n">>.
 
2854
 
 
2855
compact_otp7457_msg02() ->
 
2856
    <<"!/2 <mg1>\nT=15{C=-{O-SC=tdm12/1/1/*{SV{MT=RS,RE=900}}}}\n">>.
 
2857
 
 
2858
compact_otp7457_msg03() ->
 
2859
    <<"!/2 <mg1>\nT=15{C=-{W-SC=tdm12/1/1/*{SV{MT=RS,RE=900}}}}\n">>.
 
2860
 
 
2861
compact_otp7457(EC, BinMsg) ->
 
2862
    d("compact_otp7457 -> "
 
2863
      "~n   ~p", [binary_to_list(BinMsg)]),
 
2864
    Codec = megaco_compact_text_encoder,
 
2865
    case decode_message(Codec, false, EC, BinMsg) of
 
2866
        {ok, Msg} ->
 
2867
            case encode_message(Codec, EC, Msg) of
 
2868
                {ok, BinMsg} ->
 
2869
                    d("compact_otp7457 -> encode successfull: "
 
2870
                      "~n   ~p", [binary_to_list(BinMsg)]),
 
2871
                    ok;
 
2872
                {ok, BinMsg2} ->
 
2873
                    d("compact_otp7457 -> "
 
2874
                      "encode successfull but result differ: "
 
2875
                      "~n   ~p", [binary_to_list(BinMsg2)]),
 
2876
                    ok;
 
2877
                {error, Reason} ->
 
2878
                    e("encode failed: ~p", [Reason]),
 
2879
                    {error, Reason}
 
2880
            end;
 
2881
        {error, Reason} ->
 
2882
            e("decode failed: ~p", [Reason]),
 
2883
            {error, Reason}
 
2884
    end.
 
2885
 
 
2886
compact_otp7534_msg01(suite) ->
 
2887
    [];
 
2888
compact_otp7534_msg01(Config) when is_list(Config) ->
 
2889
    put(dbg, true),
 
2890
    put(severity, trc),
 
2891
    d("compact_otp7534_msg01 -> entry", []),
 
2892
    Msg = otp7534_msg01(),
 
2893
    compact_otp7534([], Msg).
 
2894
 
 
2895
 
 
2896
compact_otp7576_msg01(suite) ->
 
2897
    [];
 
2898
compact_otp7576_msg01(Config) when list(Config) ->
 
2899
%%     put(dbg, true),
 
2900
%%     put(severity, trc),
 
2901
    d("compact_otp7576_msg01 -> entry", []),
 
2902
    ?ACQUIRE_NODES(1, Config),
 
2903
    Msg = compact_otp7576_msg01(),
 
2904
    EC  = [],
 
2905
    ok = compact_otp7576(EC, Msg),
 
2906
    ok.
 
2907
 
 
2908
compact_otp7576_msg01() ->
 
2909
    M = "!/"  
 
2910
        ?VERSION_STR 
 
2911
        "[130.100.144.37]:2944\nT=10032{C=${tp{*,*,is,st=1},pr=6,a=rtp/2/${m{st=1{o{mo=so,rv=ON},l{
 
2912
v=0
 
2913
c=IN IP4 $
 
2914
m=audio $ RTP/AVP 0
 
2915
b=AS:64
 
2916
a=rtpmap:0 PCMU/8000
 
2917
}}},e=1{G/CAUSE}},a=rtp/2/${m{st=1{o{mo=rc,rv=ON},l{
 
2918
v=0
 
2919
c=IN IP4 $
 
2920
m=audio $ RTP/AVP 0
 
2921
b=AS:64
 
2922
a=rtpmap:0 PCMU/8000
 
2923
},r{
 
2924
v=0
 
2925
c=IN IP4 130.100.126.77
 
2926
m=audio 8014 RTP/AVP 0
 
2927
b=AS:64
 
2928
a=rtpmap:0 PCMU/8000
 
2929
}}},e=1{G/CAUSE}}}}",
 
2930
    list_to_binary(M).
 
2931
 
 
2932
compact_otp7576(EC, BinMsg) ->
 
2933
    d("compact_otp7576 -> "
 
2934
      "~n   ~p", [binary_to_list(BinMsg)]),
 
2935
    Codec = megaco_compact_text_encoder,
 
2936
    case decode_message(Codec, false, EC, BinMsg) of
 
2937
        {ok, Msg} ->
 
2938
            case encode_message(Codec, EC, Msg) of
 
2939
                {ok, BinMsg} ->
 
2940
                    d("compact_otp7138 -> encode successfull: "
 
2941
                      "~n   ~p", [binary_to_list(BinMsg)]),
 
2942
                    ok;
 
2943
                {ok, BinMsg2} ->
 
2944
                    d("compact_otp7138 -> encode successfull but result differ: "
 
2945
                      "~n   ~p", [binary_to_list(BinMsg2)]),
 
2946
                    case decode_message(Codec, false, EC, BinMsg2) of
 
2947
                        {ok, Msg} -> 
 
2948
                            d("compact_otp7138 -> "
 
2949
                              "extra verification decode ok", []),
 
2950
                            ok;
 
2951
                        {ok, Msg2} ->
 
2952
                            e("verification decode generated other message: "
 
2953
                              "~n   Msg:  ~p"
 
2954
                              "~n   Msg2: ~p", [Msg, Msg2]),
 
2955
                            {error, {verification_decode, Msg, Msg2}}
 
2956
                    end;
 
2957
                {error, Reason} ->
 
2958
                    e("encode failed: ~p", [Reason]),
 
2959
                    {error, Reason}
 
2960
            end;
 
2961
        {error, Reason} ->
 
2962
            e("decode failed: ~p", [Reason]),
 
2963
            {error, Reason}
 
2964
    end.
 
2965
 
2551
2966
 
2552
2967
%% ==============================================================
2553
2968
%%
2575
2990
    compact_otp7138([Conf], Msg).
2576
2991
 
2577
2992
 
 
2993
flex_compact_otp7431_msg01(suite) ->
 
2994
    [];
 
2995
flex_compact_otp7431_msg01(Config) when list(Config) ->
 
2996
    %% put(severity,trc),
 
2997
    %% put(dbg,true),
 
2998
    d("flex_comppact_otp7431_msg01 -> entry", []),
 
2999
    Conf = flex_scanner_conf(Config),
 
3000
    flex_compact_otp7431(ok, flex_compact_otp7431_msg1(), [Conf]).
 
3001
 
 
3002
flex_compact_otp7431_msg02(suite) ->
 
3003
    [];
 
3004
flex_compact_otp7431_msg02(Config) when list(Config) ->
 
3005
    %% put(severity,trc),
 
3006
    %% put(dbg,true),
 
3007
    d("flex_comppact_otp7431_msg02 -> entry", []),
 
3008
    Conf = flex_scanner_conf(Config),
 
3009
    flex_compact_otp7431(error, flex_compact_otp7431_msg2(), [Conf]).
 
3010
 
 
3011
flex_compact_otp7431_msg03(suite) ->
 
3012
    [];
 
3013
flex_compact_otp7431_msg03(Config) when list(Config) ->
 
3014
    %% put(severity,trc),
 
3015
    %% put(dbg,true),
 
3016
    d("flex_comppact_otp7431_msg03 -> entry", []),
 
3017
    Conf = flex_scanner_conf(Config),
 
3018
    flex_compact_otp7431(error, flex_compact_otp7431_msg3(), [Conf]).
 
3019
 
 
3020
flex_compact_otp7431_msg04(suite) ->
 
3021
    [];
 
3022
flex_compact_otp7431_msg04(Config) when list(Config) ->
 
3023
    %% put(severity,trc),
 
3024
    %% put(dbg,true),
 
3025
    d("flex_comppact_otp7431_msg04 -> entry", []),
 
3026
    Conf = flex_scanner_conf(Config),
 
3027
    flex_compact_otp7431(error, flex_compact_otp7431_msg4(), [Conf]).
 
3028
 
 
3029
flex_compact_otp7431_msg05(suite) ->
 
3030
    [];
 
3031
flex_compact_otp7431_msg05(Config) when list(Config) ->
 
3032
    %% put(severity,trc),
 
3033
    %% put(dbg,true),
 
3034
    d("flex_comppact_otp7431_msg05 -> entry", []),
 
3035
    Conf = flex_scanner_conf(Config),
 
3036
    flex_compact_otp7431(error, flex_compact_otp7431_msg5(), [Conf]).
 
3037
 
 
3038
flex_compact_otp7431_msg06(suite) ->
 
3039
    [];
 
3040
flex_compact_otp7431_msg06(Config) when list(Config) ->
 
3041
    %% put(severity,trc),
 
3042
    %% put(dbg,true),
 
3043
    d("flex_comppact_otp7431_msg06 -> entry", []),
 
3044
    Conf = flex_scanner_conf(Config),
 
3045
    flex_compact_otp7431(error, flex_compact_otp7431_msg6(), [Conf]).
 
3046
 
 
3047
flex_compact_otp7431_msg07(suite) ->
 
3048
    [];
 
3049
flex_compact_otp7431_msg07(Config) when list(Config) ->
 
3050
    %% put(severity,trc),
 
3051
    %% put(dbg,true),
 
3052
    d("flex_comppact_otp7431_msg07 -> entry", []),
 
3053
    Conf = flex_scanner_conf(Config),
 
3054
    flex_compact_otp7431(error, flex_compact_otp7431_msg7(), [Conf]).
 
3055
 
 
3056
 
 
3057
flex_compact_otp7431(Expected, Msg, Conf) ->
 
3058
    otp7431(Expected, megaco_compact_text_encoder, Msg, Conf).
 
3059
 
 
3060
flex_compact_otp7431_msg1() ->
 
3061
    "!/1 [124.124.124.222]:55555
 
3062
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
3063
v=0
 
3064
o=- 2890844526 2890842807 IN IP4 124.124.124.222
 
3065
s=-
 
3066
t= 0 0
 
3067
c=IN IP4 124.124.124.222
 
3068
m=audio 2222 RTP/AVP 4
 
3069
a=ptime:30
 
3070
a=recvonly
 
3071
}}}}}}".
 
3072
 
 
3073
flex_compact_otp7431_msg2() ->
 
3074
    "!/1 [124.124.124.222]:55555
 
3075
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
3076
v=0
 
3077
o=- 2890844526 2890842807 IN IP4 124.124.124.222
 
3078
s=-
 
3079
t= 0 0
 
3080
c=IN IP4 124.124.124.222
 
3081
m=audio 2222 RTP/AVP 4
 
3082
a=ptime:30
 
3083
a=     }
 
3084
}}}}}".
 
3085
 
 
3086
 
 
3087
flex_compact_otp7431_msg3() ->
 
3088
    "!/1 [124.124.124.222]:55555
 
3089
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
3090
v=0
 
3091
o=- 2890844526 2890842807 IN IP4 124.124.124.222
 
3092
s=-
 
3093
t= 0 0
 
3094
c=IN IP4 124.124.124.222
 
3095
m=audio 2222 RTP/AVP 4
 
3096
a=ptime:30
 
3097
a     }
 
3098
}}}}}".
 
3099
 
 
3100
 
 
3101
flex_compact_otp7431_msg4() ->
 
3102
    "!/1 [124.124.124.222]:55555
 
3103
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
3104
v=0
 
3105
o=- 2890844526 2890842807 IN IP4 124.124.124.222
 
3106
s=-
 
3107
t= 0 0
 
3108
c=IN IP4 124.124.124.222
 
3109
m=audio 2222 RTP/AVP 4
 
3110
a=ptime:30
 
3111
a}
 
3112
}}}}}".
 
3113
 
 
3114
 
 
3115
flex_compact_otp7431_msg5() ->
 
3116
    "!/1 [124.124.124.222]:55555
 
3117
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
3118
v=       }
 
3119
}}}}}".
 
3120
 
 
3121
 
 
3122
flex_compact_otp7431_msg6() ->
 
3123
    "!/1 [124.124.124.222]:55555
 
3124
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
3125
v       }
 
3126
}}}}}".
 
3127
 
 
3128
flex_compact_otp7431_msg7() ->
 
3129
    "!/1 [124.124.124.222]:55555
 
3130
P=10003{C=2000{A=a4444,A=a4445{M{ST=1{L{
 
3131
v}
 
3132
}}}}}".
 
3133
 
 
3134
flex_compact_otp7457_msg01(suite) ->
 
3135
    [];
 
3136
flex_compact_otp7457_msg01(Config) when is_list(Config) ->
 
3137
    put(dbg, true),
 
3138
    put(severity, trc),
 
3139
    d("flex_compact_otp7457_msg01 -> entry", []),
 
3140
    Msg  = compact_otp7457_msg01(),
 
3141
    Conf = flex_scanner_conf(Config),
 
3142
    compact_otp7457([Conf], Msg).
 
3143
 
 
3144
flex_compact_otp7457_msg02(suite) ->
 
3145
    [];
 
3146
flex_compact_otp7457_msg02(Config) when is_list(Config) ->
 
3147
    put(dbg, true),
 
3148
    put(severity, trc),
 
3149
    d("flex_compact_otp7457_msg02 -> entry", []),
 
3150
    Msg  = compact_otp7457_msg02(),
 
3151
    Conf = flex_scanner_conf(Config),
 
3152
    compact_otp7457([Conf], Msg).
 
3153
 
 
3154
flex_compact_otp7457_msg03(suite) ->
 
3155
    [];
 
3156
flex_compact_otp7457_msg03(Config) when is_list(Config) ->
 
3157
    put(dbg, true),
 
3158
    put(severity, trc),
 
3159
    d("flex_compact_otp7457_msg03 -> entry", []),
 
3160
    Msg  = compact_otp7457_msg03(),
 
3161
    Conf = flex_scanner_conf(Config),
 
3162
    compact_otp7457([Conf], Msg).
 
3163
 
 
3164
flex_compact_otp7534_msg01(suite) ->
 
3165
    [];
 
3166
flex_compact_otp7534_msg01(Config) when is_list(Config) ->
 
3167
    put(dbg, true),
 
3168
    put(severity, trc),
 
3169
    d("flex_compact_otp7534_msg01 -> entry", []),
 
3170
    Msg  = otp7534_msg01(),
 
3171
    Conf = flex_scanner_conf(Config),
 
3172
    compact_otp7534([Conf], Msg).
 
3173
 
 
3174
otp7534_msg01() ->
 
3175
    <<"!/2 bgwch3_1\nP=62916991{C=-{AV=root{M{TS{ipra/ar=[interconnect,interconnect1,internal],SI=IV}},PG{root-2,ocp-1,it-1,nt-1,rtp-1,gm-1,ds-1,tman-1,xnq-1}}}}">>.
 
3176
 
 
3177
compact_otp7534(EC, BinMsg) ->
 
3178
    Codec = megaco_compact_text_encoder,
 
3179
    otp7534(Codec, EC, BinMsg).
 
3180
 
 
3181
otp7534(Codec, EC, BinMsg) ->
 
3182
    d("otp7534 -> "
 
3183
      "~n   Codec: ~p"
 
3184
      "~n   ~p", [Codec, binary_to_list(BinMsg)]),
 
3185
    case decode_message(Codec, false, EC, BinMsg) of
 
3186
        {ok, Msg} ->
 
3187
            case encode_message(Codec, EC, Msg) of
 
3188
                {ok, BinMsg} ->
 
3189
                    d("otp7457 -> encode successfull: "
 
3190
                      "~n   ~p", [binary_to_list(BinMsg)]),
 
3191
                    ok;
 
3192
                {ok, BinMsg2} ->
 
3193
                    d("otp7457 -> "
 
3194
                      "encode successfull but result differ: "
 
3195
                      "~n   ~p", [binary_to_list(BinMsg2)]),
 
3196
                    ok;
 
3197
                {error, Reason} ->
 
3198
                    e("encode failed: ~p", [Reason]),
 
3199
                    {error, Reason}
 
3200
            end;
 
3201
        {error, Reason} ->
 
3202
            e("decode failed: ~p", [Reason]),
 
3203
            {error, Reason}
 
3204
    end.
 
3205
 
 
3206
 
 
3207
flex_compact_otp7573_msg01(suite) ->
 
3208
    [];
 
3209
flex_compact_otp7573_msg01(Config) when is_list(Config) ->
 
3210
    put(dbg, true),
 
3211
    put(severity, trc),
 
3212
    d("flex_compact_otp7573_msg01 -> entry", []),
 
3213
    Msg  = otp7573_msg01(),
 
3214
    Conf = flex_scanner_conf(Config),
 
3215
    compact_otp7573([Conf], Msg).
 
3216
 
 
3217
otp7573_msg01() ->
 
3218
    <<"!/2 <aa>\nP=37775561{C=-{AV=root{M{TS{root/maxnumberofcontexts=16000,root/maxterminationspercontext=2,root/normalmgexecutiontime=3000,root/normalmgcexecutiontime=3000,root/mgprovisionalresponsetimervalue=2000,root/mgcprovisionalresponsetimervalue=2000,root/mgcoriginatedpendinglimit=5,root/mgoriginatedpendinglimit=5,ipra/ar=[\"\"],SI=IV}},PG{root-2,ocp-1,it-1,nt-1,rtp-1,gm-1,ds-1,tman-1,xnq-1,ipra-1}}}}">>.
 
3219
 
 
3220
compact_otp7573(EC, BinMsg) ->
 
3221
    Codec = megaco_compact_text_encoder,
 
3222
    otp7573(Codec, EC, BinMsg).
 
3223
 
 
3224
otp7573(Codec, EC, BinMsg) ->
 
3225
    d("otp7573 -> "
 
3226
      "~n   Codec: ~p"
 
3227
      "~n   ~p", [Codec, binary_to_list(BinMsg)]),
 
3228
    case decode_message(Codec, false, EC, BinMsg) of
 
3229
        {ok, Msg} ->
 
3230
            case encode_message(Codec, EC, Msg) of
 
3231
                {ok, BinMsg} ->
 
3232
                    d("otp7573 -> encode successfull: "
 
3233
                      "~n   ~p", [binary_to_list(BinMsg)]),
 
3234
                    ok;
 
3235
                {ok, BinMsg2} ->
 
3236
                    d("otp7573 -> "
 
3237
                      "encode successfull but result differ: "
 
3238
                      "~n   ~p", [binary_to_list(BinMsg2)]),
 
3239
                    ok;
 
3240
                {error, Reason} ->
 
3241
                    e("encode failed: ~p", [Reason]),
 
3242
                    {error, Reason}
 
3243
            end;
 
3244
        {error, Reason} ->
 
3245
            e("decode failed: ~p", [Reason]),
 
3246
            {error, Reason}
 
3247
    end.
 
3248
 
 
3249
 
 
3250
flex_compact_otp7576_msg01(suite) ->
 
3251
    [];
 
3252
flex_compact_otp7576_msg01(Config) when list(Config) ->
 
3253
%%     put(dbg, true),
 
3254
%%     put(severity, trc),
 
3255
    d("flex_compact_otp7576_msg01 -> entry", []),
 
3256
    Msg  = compact_otp7576_msg01(),
 
3257
    Conf = flex_scanner_conf(Config),
 
3258
    compact_otp7576([Conf], Msg).
 
3259
 
 
3260
 
2578
3261
%% ==============================================================
2579
3262
%%
2580
3263
%% P r e t t y   T e s t c a s e s