megaco_codec_v2_test.erl

来自「OTP是开放电信平台的简称」· ERL 代码 · 共 2,258 行 · 第 1/5 页

ERL
2,258
字号
     compact_otp5186_msg03,     compact_otp5186_msg04,     compact_otp5186_msg05,     compact_otp5186_msg06,     compact_otp5290_msg01,     compact_otp5290_msg02,     compact_otp5793_msg01,     compact_otp5993_msg01,     compact_otp5993_msg02,     compact_otp5993_msg03,     compact_otp6017_msg01,     compact_otp6017_msg02,     compact_otp6017_msg03    ].pretty_tickets(suite) ->    [     pretty_otp4632_msg1,     pretty_otp4632_msg2,     pretty_otp4632_msg3,     pretty_otp4632_msg4,     pretty_otp4710_msg1,     pretty_otp4710_msg2,     pretty_otp4945_msg1,     pretty_otp4945_msg2,     pretty_otp4945_msg3,     pretty_otp4945_msg4,     pretty_otp4945_msg5,     pretty_otp4945_msg6,     pretty_otp4949_msg1,     pretty_otp4949_msg2,     pretty_otp4949_msg3,     pretty_otp5042_msg1,     pretty_otp5068_msg1,     pretty_otp5085_msg1,     pretty_otp5085_msg2,     pretty_otp5085_msg3,     pretty_otp5085_msg4,     pretty_otp5085_msg5,     pretty_otp5085_msg6,     pretty_otp5085_msg7,     pretty_otp5600_msg1,     pretty_otp5600_msg2,     pretty_otp5601_msg1,     pretty_otp5793_msg01,     pretty_otp5882_msg01,     pretty_otp6490_msg01,     pretty_otp6490_msg02,     pretty_otp6490_msg03,     pretty_otp6490_msg04,     pretty_otp6490_msg05,     pretty_otp6490_msg06    ].flex_pretty_tickets(suite) ->    {req, [],      {conf, flex_pretty_init, flex_pretty_tickets_cases(),       flex_pretty_finish}}.flex_pretty_tickets_cases() ->    [     flex_pretty_otp5042_msg1,     flex_pretty_otp5085_msg1,     flex_pretty_otp5085_msg2,     flex_pretty_otp5085_msg3,     flex_pretty_otp5085_msg4,     flex_pretty_otp5085_msg5,     flex_pretty_otp5085_msg6,     flex_pretty_otp5085_msg7,     flex_pretty_otp5600_msg1,     flex_pretty_otp5600_msg2,     flex_pretty_otp5601_msg1,     flex_pretty_otp5793_msg01    ].%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%pretty_test_msgs(suite) ->    [];pretty_test_msgs(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    Msgs = msgs1() ++ msgs2() ++ msgs3() ++ msgs4() ++ msgs5(),    %% Msgs = msgs5(),     DynamicDecode = false,    test_msgs(megaco_pretty_text_encoder, DynamicDecode, [], Msgs).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%flex_pretty_init(Config) when list(Config) ->    Flag = process_flag(trap_exit, true),        Res = (catch start_flex_scanner()),    process_flag(trap_exit, Flag),    case Res of	{error, Reason} ->  	    ?LOG("flex_pretty_init -> error: "  		 "~n   Reason: ~p~n", [Reason]),	    skip(Reason);	{Pid, Conf} when pid(Pid) ->	    [{flex_scanner, Pid, Conf}|Config]    end;flex_pretty_init(Config) ->    exit({invalid_config, Config}).    flex_pretty_finish(Config) when list(Config) ->    case lists:keysearch(flex_scanner, 1, Config) of	{value, {flex_scanner, Pid, _Conf}} ->	    stop_flex_scanner(Pid),	    lists:keydelete(flex_scanner, 1, Config);	false ->	    Config    end.    flex_pretty_test_msgs(suite) ->    [];flex_pretty_test_msgs(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    Msgs = msgs1() ++ msgs2() ++ msgs3() ++ msgs4(),    Conf = flex_scanner_conf(Config),    DynamicDecode = false,    test_msgs(megaco_pretty_text_encoder, DynamicDecode, [Conf], Msgs).flex_pretty_otp5042_msg1(suite) ->    [];flex_pretty_otp5042_msg1(Config) when list(Config) ->    d("flex_pretty_otp5042_msg1 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Msg0 = pretty_otp5042_msg1(),    Bin0 = list_to_binary(Msg0),    Conf = flex_scanner_conf(Config),    case decode_message(megaco_pretty_text_encoder, false, [Conf], Bin0) of	{error, [{reason, Reason}|_]} ->	    case Reason of		{_, _Mod, {bad_timeStamp, TimeStamp}} ->		    exit({bad_timeStamp, TimeStamp});		_ ->		    io:format("flex_pretty_otp5042_msg1 -> "			      "~n   Reason: ~w"			      "~n", [Reason]),		    exit({unexpected_decode_result, Reason})	    end;	{ok, M} ->	    t("flex_pretty_otp5042_msg1 -> successfull decode:"	      "~n~p", [M]),	    ok    end.flex_pretty_otp5085_msg1(suite) ->    [];flex_pretty_otp5085_msg1(Config) when list(Config) ->    d("flex_pretty_otp5085_msg1 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5085(ok, pretty_otp5085_msg1(), [Conf]).flex_pretty_otp5085_msg2(suite) ->    [];flex_pretty_otp5085_msg2(Config) when list(Config) ->    d("flex_pretty_otp5085_msg2 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5085(error, pretty_otp5085_msg2(), [Conf]).flex_pretty_otp5085_msg3(suite) ->    [];flex_pretty_otp5085_msg3(Config) when list(Config) ->    d("flex_pretty_otp5085_msg3 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5085(ok, pretty_otp5085_msg3(), [Conf]).flex_pretty_otp5085_msg4(suite) ->    [];flex_pretty_otp5085_msg4(Config) when list(Config) ->    d("flex_pretty_otp5085_msg4 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5085(ok, pretty_otp5085_msg4(), [Conf]).flex_pretty_otp5085_msg5(suite) ->    [];flex_pretty_otp5085_msg5(Config) when list(Config) ->    d("flex_pretty_otp5085_msg5 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5085(ok, pretty_otp5085_msg5(), [Conf]).flex_pretty_otp5085_msg6(suite) ->    [];flex_pretty_otp5085_msg6(Config) when list(Config) ->    d("flex_pretty_otp5085_msg6 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5085(ok, pretty_otp5085_msg6(), [Conf]).flex_pretty_otp5085_msg7(suite) ->    [];flex_pretty_otp5085_msg7(Config) when list(Config) ->    d("flex_pretty_otp5085_msg7 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5085(ok, pretty_otp5085_msg7(), [Conf]).flex_pretty_otp5600_msg1(suite) ->    [];flex_pretty_otp5600_msg1(Config) when list(Config) ->    d("flex_pretty_otp5600_msg1 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5600(ok, pretty_otp5600_msg1(), [Conf]).flex_pretty_otp5600_msg2(suite) ->    [];flex_pretty_otp5600_msg2(Config) when list(Config) ->    d("flex_pretty_otp5600_msg2 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5600(ok, pretty_otp5600_msg2(), [Conf]). flex_pretty_otp5601_msg1(suite) ->    [];flex_pretty_otp5601_msg1(Config) when list(Config) ->    d("flex_pretty_otp5601_msg1 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5601(ok, pretty_otp5601_msg1(), [Conf]).flex_pretty_otp5793_msg01(suite) ->    [];flex_pretty_otp5793_msg01(Config) when list(Config) ->    d("flex_pretty_otp5793_msg01 -> entry", []),    ?ACQUIRE_NODES(1, Config),    Conf = flex_scanner_conf(Config),    pretty_otp5793(ok, pretty_otp5793_msg1(), [Conf]).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%compact_test_msgs(suite) ->    [];compact_test_msgs(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    Msgs = msgs1() ++ msgs2() ++ msgs3() ++ msgs4(),    DynamicDecode = false,    test_msgs(megaco_compact_text_encoder, DynamicDecode, [], Msgs).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%flex_compact_init(Config) when list(Config) ->    Flag = process_flag(trap_exit, true),        Res = (catch start_flex_scanner()),    process_flag(trap_exit, Flag),    case Res of	{error, Reason} -> 	    ?LOG("flex_compact_init -> error: " 		 "~n   Reason: ~p~n", [Reason]),	    skip(Reason);	{Pid, Conf} when pid(Pid) ->	    [{flex_scanner, Pid, Conf}|Config]    end.    flex_compact_finish(Config) when list(Config) ->    case lists:keysearch(flex_scanner, 1, Config) of	{value, {flex_scanner, Pid, _Conf}} ->	    stop_flex_scanner(Pid),	    lists:keydelete(flex_scanner, 1, Config);	false ->	    Config    end.    flex_compact_test_msgs(suite) ->    [];flex_compact_test_msgs(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    Msgs = msgs1() ++ msgs2() ++ msgs3() ++ msgs4(),    Conf = flex_scanner_conf(Config),     DynamicDecode = true,    test_msgs(megaco_compact_text_encoder, DynamicDecode, [Conf], Msgs).flex_compact_dm_timers1(suite) ->    [];flex_compact_dm_timers1(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    M = build_dm_timers_message("1", "2", "3"),    B = list_to_binary(M),    Conf = flex_scanner_conf(Config),     case decode_message(megaco_compact_text_encoder, false, [Conf], B) of	{ok, M1} when record(M1,'MegacoMessage') ->	    t("flex_compact_dm_timers1 -> "	      "~n   M:  ~s"	      "~n   M1: ~p", [M, M1]),	    verify_dm_timers({1,2,3}, M1);	Else ->	    exit({decode_failed, M, Else})    end.flex_compact_dm_timers2(suite) ->    [];flex_compact_dm_timers2(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    M = build_dm_timers_message("02", "03", "04"),    B = list_to_binary(M),    Conf = flex_scanner_conf(Config),     case decode_message(megaco_compact_text_encoder, false, [Conf], B) of	{ok, M1} when record(M1,'MegacoMessage') ->	    t("flex_compact_dm_timers2 -> "	      "~n   M:  ~s"	      "~n   M1: ~p", [M, M1]),	    verify_dm_timers({2,3,4}, M1);	Else ->	    exit({decode_failed, M, Else})    end.flex_compact_dm_timers3(suite) ->    [];flex_compact_dm_timers3(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    M = build_dm_timers_message("1", "02", "31"),    B = list_to_binary(M),    Conf = flex_scanner_conf(Config),     case decode_message(megaco_compact_text_encoder, false, [Conf], B) of	{ok, M1} when record(M1,'MegacoMessage') ->	    t("flex_compact_dm_timers3 -> "	      "~n   M:  ~s"	      "~n   M1: ~p", [M, M1]),	    verify_dm_timers({1,2,31}, M1);	Else ->	    exit({decode_failed, M, Else})    end.flex_compact_dm_timers4(suite) ->    [];flex_compact_dm_timers4(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    M = build_dm_timers_message("10", "21", "99"),    B = list_to_binary(M),    Conf = flex_scanner_conf(Config),     case decode_message(megaco_compact_text_encoder, false, [Conf], B) of	{ok, M1} when record(M1,'MegacoMessage') ->	    t("flex_compact_dm_timers4 -> "	      "~n   M:  ~s"	      "~n   M1: ~p", [M, M1]),	    verify_dm_timers({10,21,99}, M1);	Else ->	    exit({decode_failed, M, Else})    end.flex_compact_dm_timers5(suite) ->    [];flex_compact_dm_timers5(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    M = build_dm_timers_message("99", "23", "11"),    B = list_to_binary(M),    Conf = flex_scanner_conf(Config),     case decode_message(megaco_compact_text_encoder, false, [Conf], B) of	{ok, M1} when record(M1,'MegacoMessage') ->	    t("flex_compact_dm_timers5 -> "	      "~n   M:  ~s"	      "~n   M1: ~p", [M, M1]),	    verify_dm_timers({99,23,11}, M1);	Else ->	    exit({decode_failed, M, Else})    end.flex_compact_dm_timers6(suite) ->    [];flex_compact_dm_timers6(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    M = build_dm_timers_message("77", "09", "1"),    B = list_to_binary(M),    Conf = flex_scanner_conf(Config),     case decode_message(megaco_compact_text_encoder, false, [Conf], B) of	{ok, M1} when record(M1,'MegacoMessage') ->	    t("flex_compact_dm_timers6 -> "	      "~n   M:  ~s"	      "~n   M1: ~p", [M, M1]),	    verify_dm_timers({77,9,1}, M1);	Else ->	    exit({decode_failed, M, Else})    end.flex_compact_dm_timers7(suite) ->    [];flex_compact_dm_timers7(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    M = build_dm_timers_message("77", "09", "1", "99"),    B = list_to_binary(M),    Conf = flex_scanner_conf(Config),     case decode_message(megaco_compact_text_encoder, false, [Conf], B) of	{ok, M1} when record(M1,'MegacoMessage') ->	    t("flex_compact_dm_timers7 -> "	      "~n   M:  ~s"	      "~n   M1: ~p", [M, M1]),	    verify_dm_timers({77,9,1,99}, M1);	Else ->	    exit({decode_failed, M, Else})    end.flex_compact_dm_timers8(suite) ->    [];flex_compact_dm_timers8(Config) when list(Config) ->    ?ACQUIRE_NODES(1, Config),    M = build_dm_timers_message("01", "09", "01", "02"),    B = list_to_binary(M),    Conf = flex_scanner_conf(Config),     case decode_message(megaco_compact_text_encoder, false, [Conf], B) of	{ok, M1} when record(M1,'MegacoMessage') ->	    t("flex_compact_dm_timers8 -> "	      "~n   M:  ~s"	      "~n   M1: ~p", [M, M1]),	    verify_dm_timers({1,9,1,2}, M1);	Else ->	    exit({decode_failed, M, Else})    end.build_dm_timers_message(T, S, L) ->    TMRs = lists:flatten(io_lib:format("T:~s,S:~s,L:~s", [T, S, L])),    build_dm_timers_message(TMRs).build_dm_timers_message(T, S, L, Z) ->    TMRs = lists:flatten(io_lib:format("T:~s,S:~s,L:~s,Z:~s", [T, S, L,Z])),    build_dm_timers_message(TMRs).build_dm_timers_message(TMRs) ->    M = io_lib:format("!/" ?VERSION_STR " [123.123.123.4]:55555\nT=10001{C=-{MF=11111111/00000000/00000000{E=2223{al/on,dd/ce{DM=dialplan00}},SG{cg/rt},DM=dialplan00{~s,(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)}}}}", [TMRs]),    lists:flatten(M).verify_dm_timers(TMRs, #'MegacoMessage'{mess = Mess}) ->    #'Message'{messageBody = Body} = Mess,    case get_dm_timers(Body) of	{error, Reason} ->	    exit({invalid_timer, {TMRs, Reason}});	TMRs ->	    ok;	TMRs1 ->

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?