From ab95cf07716a3c4c91ede0b67ab7c8dd5277945d Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Thu, 26 Nov 2020 10:40:45 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/testCase/utTpfm.erl | 36 ++++++++++++++++++++++---- src/testCase/writeHex.erl | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 src/testCase/writeHex.erl diff --git a/src/testCase/utTpfm.erl b/src/testCase/utTpfm.erl index b8b2cdd..e2f161b 100644 --- a/src/testCase/utTpfm.erl +++ b/src/testCase/utTpfm.erl @@ -517,9 +517,35 @@ listLoop2([One | List]) -> listLoop3(List) -> lists:foreach(fun(X) -> listLoopIn(X) end, List). - - - - - +bits(0, _Fun) -> + ok; +bits(N, Fun) -> + [?MODULE:Fun(BitSize) || BitSize <- [3, 7, 16, 31, 55, 63, 64]], + bits(N - 1, Fun). + +%% 生成一个指定大小且全为1的bitstring +bits_1(BitSize) when BitSize < 8 -> <> = <<16#FF>>, Bits; +bits_1(BitSize) when BitSize =:= 8 -> <<255>>; +bits_1(BitSize) when BitSize < 16 -> Tail = bits_1(BitSize - 8), <<255, Tail/bits>>; +bits_1(BitSize) when BitSize =:= 16 -> <<255, 255>>; +bits_1(BitSize) when BitSize < 24 -> Tail = bits_1(BitSize - 16), <<255, 255, Tail/bits>>; +bits_1(BitSize) when BitSize =:= 24 -> <<255, 255, 255>>; +bits_1(BitSize) when BitSize < 32 -> Tail = bits_1(BitSize - 24), <<255, 255, 255, Tail/bits>>; +bits_1(BitSize) when BitSize =:= 32 -> <<255, 255, 255, 255>>; +bits_1(BitSize) when BitSize < 40 -> Tail = bits_1(BitSize - 32), <<255, 255, 255, 255, Tail/bits>>; +bits_1(BitSize) when BitSize =:= 40 -> <<255, 255, 255, 255, 255>>; +bits_1(BitSize) when BitSize < 48 -> Tail = bits_1(BitSize - 40), <<255, 255, 255, 255, 255, Tail/bits>>; +bits_1(BitSize) when BitSize =:= 48 -> <<255, 255, 255, 255, 255, 255>>; +bits_1(BitSize) when BitSize < 56 -> Tail = bits_1(BitSize - 48), <<255, 255, 255, 255, 255, 255, Tail/bits>>; +bits_1(BitSize) when BitSize =:= 56 -> <<255, 255, 255, 255, 255, 255, 255>>; +bits_1(BitSize) when BitSize < 64 -> Tail = bits_1(BitSize - 56), <<255, 255, 255, 255, 255, 255, 255, Tail/bits>>; +bits_1(BitSize) when BitSize =:= 64 -> <<255, 255, 255, 255, 255, 255, 255, 255>>. + +bits_2(BitSize) -> + <<((1 bsl BitSize) - 1):BitSize>>. + +testHex(0, Mod, Fun, Args, _) -> + Mod:Fun(Args); +testHex(N, Mod, Fun, Args, _) -> + testHex(N - 1, Mod, Fun, Args, Mod:Fun(Args)). diff --git a/src/testCase/writeHex.erl b/src/testCase/writeHex.erl new file mode 100644 index 0000000..0c37e69 --- /dev/null +++ b/src/testCase/writeHex.erl @@ -0,0 +1,54 @@ +-module(writeHex). + +-compile([export_all, nowarn_function, nowarn_unused_vars, nowarn_export_all]). + +write() -> + Head = <<"-module(getHex).\n-compile([export_all, nowarn_function, nowarn_unused_vars, nowarn_export_all]).\n\n">>, + GetStr = makeStr(Head), + ok = file:write_file("./src/testCase/getHex.erl", GetStr). + +makeStr(Head) -> + BinStr = << <<"getHex(", (integer_to_binary(VN))/binary, ") ->16#", (integer_to_binary(getHex(VN), 16))/binary, ";\n">> || VN <- lists:seq(1, 256)>>, + < undefined.">>. + +getHex(X) -> + element(X, + { + 16#3030, 16#3031, 16#3032, 16#3033, 16#3034, 16#3035, 16#3036, + 16#3037, 16#3038, 16#3039, 16#3061, 16#3062, 16#3063, 16#3064, + 16#3065, 16#3066, 16#3130, 16#3131, 16#3132, 16#3133, 16#3134, + 16#3135, 16#3136, 16#3137, 16#3138, 16#3139, 16#3161, 16#3162, + 16#3163, 16#3164, 16#3165, 16#3166, 16#3230, 16#3231, 16#3232, + 16#3233, 16#3234, 16#3235, 16#3236, 16#3237, 16#3238, 16#3239, + 16#3261, 16#3262, 16#3263, 16#3264, 16#3265, 16#3266, 16#3330, + 16#3331, 16#3332, 16#3333, 16#3334, 16#3335, 16#3336, 16#3337, + 16#3338, 16#3339, 16#3361, 16#3362, 16#3363, 16#3364, 16#3365, + 16#3366, 16#3430, 16#3431, 16#3432, 16#3433, 16#3434, 16#3435, + 16#3436, 16#3437, 16#3438, 16#3439, 16#3461, 16#3462, 16#3463, + 16#3464, 16#3465, 16#3466, 16#3530, 16#3531, 16#3532, 16#3533, + 16#3534, 16#3535, 16#3536, 16#3537, 16#3538, 16#3539, 16#3561, + 16#3562, 16#3563, 16#3564, 16#3565, 16#3566, 16#3630, 16#3631, + 16#3632, 16#3633, 16#3634, 16#3635, 16#3636, 16#3637, 16#3638, + 16#3639, 16#3661, 16#3662, 16#3663, 16#3664, 16#3665, 16#3666, + 16#3730, 16#3731, 16#3732, 16#3733, 16#3734, 16#3735, 16#3736, + 16#3737, 16#3738, 16#3739, 16#3761, 16#3762, 16#3763, 16#3764, + 16#3765, 16#3766, 16#3830, 16#3831, 16#3832, 16#3833, 16#3834, + 16#3835, 16#3836, 16#3837, 16#3838, 16#3839, 16#3861, 16#3862, + 16#3863, 16#3864, 16#3865, 16#3866, 16#3930, 16#3931, 16#3932, + 16#3933, 16#3934, 16#3935, 16#3936, 16#3937, 16#3938, 16#3939, + 16#3961, 16#3962, 16#3963, 16#3964, 16#3965, 16#3966, 16#6130, + 16#6131, 16#6132, 16#6133, 16#6134, 16#6135, 16#6136, 16#6137, + 16#6138, 16#6139, 16#6161, 16#6162, 16#6163, 16#6164, 16#6165, + 16#6166, 16#6230, 16#6231, 16#6232, 16#6233, 16#6234, 16#6235, + 16#6236, 16#6237, 16#6238, 16#6239, 16#6261, 16#6262, 16#6263, + 16#6264, 16#6265, 16#6266, 16#6330, 16#6331, 16#6332, 16#6333, + 16#6334, 16#6335, 16#6336, 16#6337, 16#6338, 16#6339, 16#6361, + 16#6362, 16#6363, 16#6364, 16#6365, 16#6366, 16#6430, 16#6431, + 16#6432, 16#6433, 16#6434, 16#6435, 16#6436, 16#6437, 16#6438, + 16#6439, 16#6461, 16#6462, 16#6463, 16#6464, 16#6465, 16#6466, + 16#6530, 16#6531, 16#6532, 16#6533, 16#6534, 16#6535, 16#6536, + 16#6537, 16#6538, 16#6539, 16#6561, 16#6562, 16#6563, 16#6564, + 16#6565, 16#6566, 16#6630, 16#6631, 16#6632, 16#6633, 16#6634, + 16#6635, 16#6636, 16#6637, 16#6638, 16#6639, 16#6661, 16#6662, + 16#6663, 16#6664, 16#6665, 16#6666 + }). From deb338283686e6c24e3df52557b292e239a5ed53 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Thu, 26 Nov 2020 10:56:28 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/measure/utTc.erl | 4 ++-- src/testCase/utTpfm.erl | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/measure/utTc.erl b/src/measure/utTc.erl index 8d37340..3adacd0 100644 --- a/src/measure/utTc.erl +++ b/src/measure/utTc.erl @@ -35,7 +35,7 @@ distribution([], _Aver, Greater, Less) -> ts(LoopTime, M, F, A) -> {Max, Min, Sum, Aver, Greater, Less} = loopTs(LoopTime, M, F, A, LoopTime, 0, 0, 0, []), io:format("=====================~n"), - io:format("execute Args:~p~n", A), + io:format("execute Args:~p~n", [A]), io:format("execute Fun :~p~n", [F]), io:format("execute Mod :~p~n", [M]), io:format("execute LoopTime:~p~n", [LoopTime]), @@ -79,7 +79,7 @@ tm(ProcCnt, LoopTime, M, F, A) -> loopSpawn(ProcCnt, M, F, A, self(), LoopTime), {Max, Min, Sum, Aver, Greater, Less} = collector(ProcCnt, 0, 0, 0, ProcCnt, []), io:format("=====================~n"), - io:format("execute Args:~p~n", A), + io:format("execute Args:~p~n", [A]), io:format("execute Fun :~p~n", [F]), io:format("execute Mod :~p~n", [M]), io:format("execute LoopTime:~p~n", [LoopTime]), diff --git a/src/testCase/utTpfm.erl b/src/testCase/utTpfm.erl index e2f161b..01ffd0b 100644 --- a/src/testCase/utTpfm.erl +++ b/src/testCase/utTpfm.erl @@ -549,3 +549,13 @@ testHex(0, Mod, Fun, Args, _) -> testHex(N, Mod, Fun, Args, _) -> testHex(N - 1, Mod, Fun, Args, Mod:Fun(Args)). +tTuple(0, _) -> + ok; +tTuple(N, {tag, OldN}) -> + tTuple(N -1, {tag, N}). + +tPd(0, _) -> + ok; +tPd(N, _) -> + erlang:put(pdVpSize, N), + tPd(N -1, erlang:get(pdVpSize)). \ No newline at end of file From c7a85fa93d76c427d67a5caf0678bd0c6ae06997 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Sat, 5 Dec 2020 17:02:41 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/testCase/utTpfm.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/testCase/utTpfm.erl b/src/testCase/utTpfm.erl index 01ffd0b..a9c4900 100644 --- a/src/testCase/utTpfm.erl +++ b/src/testCase/utTpfm.erl @@ -552,10 +552,10 @@ testHex(N, Mod, Fun, Args, _) -> tTuple(0, _) -> ok; tTuple(N, {tag, OldN}) -> - tTuple(N -1, {tag, N}). + tTuple(N -1, {tag, OldN}). tPd(0, _) -> ok; tPd(N, _) -> - erlang:put(pdVpSize, N), - tPd(N -1, erlang:get(pdVpSize)). \ No newline at end of file + erlang:put(pdVpSize, 0), + tPd(N -1, erlang:get(pdVpSize)). From 8233b4d3e6e9da315144811467f7e0240946f8d9 Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Sat, 5 Dec 2020 17:30:51 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/testCase/utTryCatchCase.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/testCase/utTryCatchCase.erl b/src/testCase/utTryCatchCase.erl index 765f6cc..5815133 100644 --- a/src/testCase/utTryCatchCase.erl +++ b/src/testCase/utTryCatchCase.erl @@ -238,7 +238,14 @@ testTryCatch2(Type, TestLoop) -> Type:Reason:Strace -> case TestLoop of true -> Strace; - false -> io:format("try .. catch block caught exception of ~p: ~p: ~p:~n", [Type, Reason, Strace]) + false -> + S1 = utParseStack:parseStack(Strace), + S2 = utParseStack:parseStack(element(2, erlang:process_info(self(), current_stacktrace))), + io:format(S1), + io:format(S2), + io:format("try .. catch block caught exception of ~p: ~p: ~n ~s:~n", [Type, Reason, io_lib:format(S1, [])]), + io:format("try .. catch block caught exception of ~p: ~p: ~n ~s:~n", [Type, Reason, io_lib:format(S2, [])]) + end end.