📄 megaco_codec_prev3c_test.erl
字号:
[ flex_compact_otp4299_msg1 ]. 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_otp5085_msg8, pretty_otp5600_msg1, pretty_otp5600_msg2, pretty_otp5601_msg1, pretty_otp5793_msg01, pretty_otp5803_msg01, pretty_otp5803_msg02, pretty_otp5805_msg01, pretty_otp5836_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_otp5085_msg8, flex_pretty_otp5600_msg1, flex_pretty_otp5600_msg2, flex_pretty_otp5601_msg1, flex_pretty_otp5793_msg01, flex_pretty_otp5803_msg01, flex_pretty_otp5803_msg02, flex_pretty_otp5805_msg01, flex_pretty_otp5836_msg01 ]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%pretty_test_msgs(suite) -> [];pretty_test_msgs(Config) when list(Config) -> ?ACQUIRE_NODES(1, Config), Msgs = msgs1a(text) ++ msgs1b(text) ++ msgs3525(text) ++ msgs5(text) ++ msgs6(text) ++ msgs7(text), %% Msgs = msgs1a(text), %% Msgs = msgs1b(text), %% Msgs = msgs35525(text), %% Msgs = msgs5(text), %% Msgs = msgs6(text), %% Msgs = msgs7(text), DynamicDecode = false, test_msgs(megaco_pretty_text_encoder, DynamicDecode, ?EC, 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 = msgs1a(text) ++ msgs1b(text) ++ msgs3525(text) ++ msgs5(text) ++ msgs6(text) ++ msgs7(text), Conf = flex_scanner_conf(Config), DynamicDecode = false, test_msgs(megaco_pretty_text_encoder, DynamicDecode, [?EC_V3,Conf], Msgs).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%compact_test_msgs(suite) -> [];compact_test_msgs(Config) when list(Config) -> ?ACQUIRE_NODES(1, Config), Msgs = msgs1a(text) ++ msgs1b(text) ++ msgs3525(text) ++ msgs5(text) ++ msgs6(text) ++ msgs7(text), %% Msgs = msgs7(text), DynamicDecode = false, test_msgs(megaco_compact_text_encoder, DynamicDecode, ?EC, 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 = msgs1a(text) ++ msgs1b(text) ++ msgs3525(text) ++ msgs5(text) ++ msgs6(text) ++ msgs7(text), Conf = flex_scanner_conf(Config), DynamicDecode = true, test_msgs(megaco_compact_text_encoder, DynamicDecode, [?EC_V3,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, [?EC_V3,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, [?EC_V3,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, [?EC_V3,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, [?EC_V3,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, [?EC_V3,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, [?EC_V3,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, [?EC_V3,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, [?EC_V3,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 TMRs -> ok; {error, Reason} -> exit({invalid_timer, {TMRs, Reason}}); TMRs1 -> exit({invalid_timer_values, {TMRs, TMRs1}}) 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;get_dm_timers3([_|Ars]) -> get_dm_timers3(Ars);get_dm_timers3([]) -> {error, {no_timers, 'ActionRequest'}}.get_dm_timers4([#'CommandRequest'{command = Cmd}|Cmds]) -> case get_dm_timers5(Cmd) of {ok, Timers} -> {ok, Timers}; _ -> get_dm_timers4(Cmds) end;get_dm_timers4([_|Cmds]) -> get_dm_timers4(Cmds);get_dm_timers4([]) -> {error, {no_timers, 'CommandRequest'}}.get_dm_timers5({modReq, #'AmmRequest'{descriptors = Descriptors}}) -> get_dm_timers6(Descriptors);get_dm_timers5(R) -> {error, {no_modReq, R}}.get_dm_timers6([{digitMapDescriptor, #'DigitMapDescriptor'{digitMapValue = Val}}|_]) -> case Val of #'DigitMapValue'{startTimer = T, shortTimer = S, longTimer = L, durationTimer = asn1_NOVALUE} -> {ok, {T, S, L}}; #'DigitMapValue'{startTimer = T, shortTimer = S, longTimer = L, durationTimer = Z} -> {ok, {T, S, L, Z}}; _ -> {error, no_value_in_dm} end;get_dm_timers6([_|Descs]) -> get_dm_timers6(Descs);get_dm_timers6([]) -> {error, {no_timers, descriptors}}.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%bin_test_msgs(suite) -> [];bin_test_msgs(Config) when list(Config) -> ?ACQUIRE_NODES(1, Config), Msgs = msgs1a(binary) ++ msgs5(binary) ++ msgs6(binary) ++ msgs7(binary), %% Msgs = msgs6(binary), DynamicDecode = false, test_msgs(megaco_binary_encoder, DynamicDecode, ?EC, Msgs). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ber_test_msgs(suite) -> [];ber_test_msgs(Config) when list(Config) -> ?ACQUIRE_NODES(1, Config), Msgs = msgs1a(binary) ++ msgs5(binary) ++ msgs6(binary) ++ msgs7(binary), %% Msgs = msgs7(binary), DynamicDecode = false, test_msgs(megaco_ber_encoder, DynamicDecode, ?EC, Msgs). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -