📄 megaco_codec_v1_test.erl
字号:
compact_otp4920_msg11, compact_otp4920_msg12, compact_otp4920_msg20, compact_otp4920_msg21, compact_otp4920_msg22, compact_otp4920_msg23, compact_otp4920_msg24, compact_otp4920_msg25, compact_otp5186_msg01, compact_otp5186_msg02, compact_otp5186_msg03, compact_otp5186_msg04, compact_otp5186_msg05, compact_otp5186_msg06, 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(), 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(), 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, {not_an_integer, PropertyParm}} -> exit({not_an_integer, PropertyParm}); _ -> 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(), 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(), 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.build_dm_timers_message(T, S, L) -> 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{T:~s,S:~s,L:~s,(0s| 00s|[1-7]xlxx|8lxxxxxxx|#xxxxxxx|*xx|9l1xxxxxxxxxx|9l011x.s)}}}}", [T, S, L]), lists:flatten(M).verify_dm_timers(T,S,L, #'MegacoMessage'{mess = Mess}) -> #'Message'{messageBody = Body} = Mess, case get_dm_timers(Body) of {T, S, L} -> ok; {T1, S1, L1} -> exit({invalid_timer_values, {{T, S, L}, {T1, S1, L1}}}); {error, Reason} -> exit({invalid_timer, {T, S, L, Reason}}) end.get_dm_timers({transactions, T}) when list(T) -> get_dm_timers1(T);get_dm_timers(Other) -> {error, {invalid_transactions, Other}}.get_dm_timers1([{transactionRequest,T}|Ts]) when record(T,'TransactionRequest') -> case get_dm_timers2(T) of {ok, Timers} -> Timers; _ -> get_dm_timers1(Ts) end;get_dm_timers1([_|Ts]) -> get_dm_timers1(Ts);get_dm_timers1([]) -> {error, {no_timers, 'TransactionRequest'}}.get_dm_timers2(#'TransactionRequest'{actions = Actions}) when list(Actions) -> get_dm_timers3(Actions).get_dm_timers3([#'ActionRequest'{commandRequests = Cmds}|Ars]) when list(Cmds) -> case get_dm_timers4(Cmds) of {ok, Timers} -> {ok, Timers}; _ -> get_dm_timers3(Ars) end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -