From 738c34d4bb8f1a3811acd00af8c6c12107f8315b Mon Sep 17 00:00:00 2001 From: Bruce Yinhe Date: Thu, 18 Jun 2015 11:31:02 +0200 Subject: Change license text to APLv2 --- erts/emulator/test/crypto_SUITE.erl | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'erts/emulator/test/crypto_SUITE.erl') diff --git a/erts/emulator/test/crypto_SUITE.erl b/erts/emulator/test/crypto_SUITE.erl index a82bd4fe38..3622592586 100644 --- a/erts/emulator/test/crypto_SUITE.erl +++ b/erts/emulator/test/crypto_SUITE.erl @@ -3,16 +3,17 @@ %% %% Copyright Ericsson AB 1999-2011. All Rights Reserved. %% -%% The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved online at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. %% %% %CopyrightEnd% %% -- cgit v1.2.3 From 03fcb7dabf8861e60ffab4121a909b347bccfec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 15 Feb 2016 15:33:12 +0100 Subject: Eliminate use of test_server.hrl and test_server_line.hrl As a first step to removing the test_server application as as its own separate application, change the inclusion of test_server.hrl to an inclusion of ct.hrl and remove the inclusion of test_server_line.hrl. --- erts/emulator/test/crypto_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/emulator/test/crypto_SUITE.erl') diff --git a/erts/emulator/test/crypto_SUITE.erl b/erts/emulator/test/crypto_SUITE.erl index 3622592586..41fe6a226c 100644 --- a/erts/emulator/test/crypto_SUITE.erl +++ b/erts/emulator/test/crypto_SUITE.erl @@ -20,7 +20,7 @@ -module(crypto_SUITE). --include_lib("test_server/include/test_server.hrl"). +-include_lib("common_test/include/ct.hrl"). -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, -- cgit v1.2.3 From c062dfc485ad0d51d648701950f77ef8f51d4f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Tue, 8 Mar 2016 19:35:31 +0100 Subject: Modernize use of timetraps --- erts/emulator/test/crypto_SUITE.erl | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'erts/emulator/test/crypto_SUITE.erl') diff --git a/erts/emulator/test/crypto_SUITE.erl b/erts/emulator/test/crypto_SUITE.erl index 41fe6a226c..e9498028cb 100644 --- a/erts/emulator/test/crypto_SUITE.erl +++ b/erts/emulator/test/crypto_SUITE.erl @@ -22,40 +22,23 @@ -include_lib("common_test/include/ct.hrl"). --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2, +-export([all/0, suite/0, t_md5/1,t_md5_update/1,error/1,unaligned_context/1,random_lists/1, misc_errors/1]). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}]. all() -> [t_md5, t_md5_update, error, unaligned_context, random_lists, misc_errors]. -groups() -> - []. - -init_per_suite(Config) -> - Config. - -end_per_suite(_Config) -> - ok. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. - - - misc_errors(doc) -> ["Test crc32, adler32 and md5 error cases not covered by other tests"]; misc_errors(suite) -> []; misc_errors(Config) when is_list(Config) -> - ?line Dog = test_server:timetrap(test_server:minutes(2)), + ct:timetrap({minutes, 2}), ?line 1 = erlang:adler32([]), ?line L = lists:duplicate(600,3), ?line 1135871753 = erlang:adler32(L), @@ -78,7 +61,6 @@ misc_errors(Config) when is_list(Config) -> ?line {'EXIT', {badarg,_}} = (catch erlang:adler32_combine(3,3,Big)), ?line {'EXIT', {badarg,_}} = (catch erlang:md5_update(<<"hej">>,<<"hej">>)), ?line {'EXIT', {badarg,_}} = (catch erlang:md5_final(<<"hej">>)), - ?line test_server:timetrap_cancel(Dog), ok. @@ -132,7 +114,7 @@ random_lists(doc) -> random_lists(suite) -> []; random_lists(Config) when is_list(Config) -> - ?line Dog = test_server:timetrap(test_server:minutes(5)), + ct:timetrap({minutes, 5}), ?line Num = erlang:system_info(schedulers_online), ?line B = list_to_binary( lists:duplicate( @@ -232,7 +214,6 @@ random_lists(Config) when is_list(Config) -> fun() -> random_iolist:run2(150,ADLER32_1_L_2,ADLER32_3_L_2) end}, {?LINE, fun() -> random_iolist:run2(150,MD5_1_L_2,MD5_2_L_2) end}], ?line run_in_para(Wlist1,Num), - ?line test_server:timetrap_cancel(Dog), ok. %% -- cgit v1.2.3 From 33b0c5f37b7b5baa42d4999d1a2be32470fb1bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 10 Mar 2016 17:59:23 +0100 Subject: Eliminate use of doc and suite clauses Those clause are obsolete and never used by common_test. --- erts/emulator/test/crypto_SUITE.erl | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'erts/emulator/test/crypto_SUITE.erl') diff --git a/erts/emulator/test/crypto_SUITE.erl b/erts/emulator/test/crypto_SUITE.erl index e9498028cb..8ff77b3880 100644 --- a/erts/emulator/test/crypto_SUITE.erl +++ b/erts/emulator/test/crypto_SUITE.erl @@ -33,10 +33,7 @@ all() -> [t_md5, t_md5_update, error, unaligned_context, random_lists, misc_errors]. -misc_errors(doc) -> - ["Test crc32, adler32 and md5 error cases not covered by other tests"]; -misc_errors(suite) -> - []; +%% Test crc32, adler32 and md5 error cases not covered by other tests" misc_errors(Config) when is_list(Config) -> ct:timetrap({minutes, 2}), ?line 1 = erlang:adler32([]), @@ -108,11 +105,7 @@ collect_workers([{L,{Pid,Ref}}|T]) -> exit({error_at_line,L,Other}) end. -random_lists(doc) -> - ["Test crc32, adler32 and md5 on a number of pseudo-randomly generated " - "lists."]; -random_lists(suite) -> - []; +%% Test crc32, adler32 and md5 on a number of pseudo-randomly generated lists. random_lists(Config) when is_list(Config) -> ct:timetrap({minutes, 5}), ?line Num = erlang:system_info(schedulers_online), @@ -216,11 +209,7 @@ random_lists(Config) when is_list(Config) -> ?line run_in_para(Wlist1,Num), ok. -%% -%% -t_md5(doc) -> - ["Generate MD5 message digests and check the result. Examples are " - "from RFC-1321."]; +%% Generate MD5 message digests and check the result. Examples are from RFC-1321. t_md5(Config) when is_list(Config) -> ?line t_md5_test("", "d41d8cd98f00b204e9800998ecf8427e"), ?line t_md5_test("a", "0cc175b9c0f1b6a831c399e269772661"), @@ -238,11 +227,8 @@ t_md5(Config) when is_list(Config) -> "57edf4a22be3c955ac49da2e2107b67a"), ok. -%% -%% -t_md5_update(doc) -> - ["Generate MD5 message using md5_init, md5_update, and md5_final, and" - "check the result. Examples are from RFC-1321."]; +%% Generate MD5 message using md5_init, md5_update, and md5_final, and +%% check the result. Examples are from RFC-1321. t_md5_update(Config) when is_list(Config) -> ?line t_md5_update_1(fun(Str) -> Str end), ?line t_md5_update_1(fun(Str) -> list_to_binary(Str) end), -- cgit v1.2.3 From 20ae6a9238d3fd09587bd3f4179a8ae25f1e3aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 10 Mar 2016 18:19:16 +0100 Subject: Remove ?line macros --- erts/emulator/test/crypto_SUITE.erl | 344 ++++++++++++++++++------------------ 1 file changed, 171 insertions(+), 173 deletions(-) (limited to 'erts/emulator/test/crypto_SUITE.erl') diff --git a/erts/emulator/test/crypto_SUITE.erl b/erts/emulator/test/crypto_SUITE.erl index 8ff77b3880..6212997272 100644 --- a/erts/emulator/test/crypto_SUITE.erl +++ b/erts/emulator/test/crypto_SUITE.erl @@ -23,8 +23,8 @@ -include_lib("common_test/include/ct.hrl"). -export([all/0, suite/0, - t_md5/1,t_md5_update/1,error/1,unaligned_context/1,random_lists/1, - misc_errors/1]). + t_md5/1,t_md5_update/1,error/1,unaligned_context/1,random_lists/1, + misc_errors/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -36,28 +36,28 @@ all() -> %% Test crc32, adler32 and md5 error cases not covered by other tests" misc_errors(Config) when is_list(Config) -> ct:timetrap({minutes, 2}), - ?line 1 = erlang:adler32([]), - ?line L = lists:duplicate(600,3), - ?line 1135871753 = erlang:adler32(L), - ?line L2 = lists:duplicate(22000,3), - ?line 1100939744 = erlang:adler32(L2), - ?line {'EXIT', {badarg,_}} = (catch erlang:adler32(L++[a])), - ?line {'EXIT', {badarg,_}} = (catch erlang:crc32(L++[a])), - ?line {'EXIT', {badarg,_}} = (catch erlang:crc32([1,2,3|<<25:7>>])), - ?line {'EXIT', {badarg,_}} = (catch erlang:crc32([1,2,3|4])), - ?line Big = 111111111111111111111111111111, - ?line {'EXIT', {badarg,_}} = (catch erlang:crc32(Big,<<"hej">>)), - ?line {'EXIT', {badarg,_}} = (catch erlang:crc32(25,[1,2,3|4])), - ?line {'EXIT', {badarg,_}} = (catch erlang:crc32_combine(Big,3,3)), - ?line {'EXIT', {badarg,_}} = (catch erlang:crc32_combine(3,Big,3)), - ?line {'EXIT', {badarg,_}} = (catch erlang:crc32_combine(3,3,Big)), - ?line {'EXIT', {badarg,_}} = (catch erlang:adler32(Big,<<"hej">>)), - ?line {'EXIT', {badarg,_}} = (catch erlang:adler32(25,[1,2,3|4])), - ?line {'EXIT', {badarg,_}} = (catch erlang:adler32_combine(Big,3,3)), - ?line {'EXIT', {badarg,_}} = (catch erlang:adler32_combine(3,Big,3)), - ?line {'EXIT', {badarg,_}} = (catch erlang:adler32_combine(3,3,Big)), - ?line {'EXIT', {badarg,_}} = (catch erlang:md5_update(<<"hej">>,<<"hej">>)), - ?line {'EXIT', {badarg,_}} = (catch erlang:md5_final(<<"hej">>)), + 1 = erlang:adler32([]), + L = lists:duplicate(600,3), + 1135871753 = erlang:adler32(L), + L2 = lists:duplicate(22000,3), + 1100939744 = erlang:adler32(L2), + {'EXIT', {badarg,_}} = (catch erlang:adler32(L++[a])), + {'EXIT', {badarg,_}} = (catch erlang:crc32(L++[a])), + {'EXIT', {badarg,_}} = (catch erlang:crc32([1,2,3|<<25:7>>])), + {'EXIT', {badarg,_}} = (catch erlang:crc32([1,2,3|4])), + Big = 111111111111111111111111111111, + {'EXIT', {badarg,_}} = (catch erlang:crc32(Big,<<"hej">>)), + {'EXIT', {badarg,_}} = (catch erlang:crc32(25,[1,2,3|4])), + {'EXIT', {badarg,_}} = (catch erlang:crc32_combine(Big,3,3)), + {'EXIT', {badarg,_}} = (catch erlang:crc32_combine(3,Big,3)), + {'EXIT', {badarg,_}} = (catch erlang:crc32_combine(3,3,Big)), + {'EXIT', {badarg,_}} = (catch erlang:adler32(Big,<<"hej">>)), + {'EXIT', {badarg,_}} = (catch erlang:adler32(25,[1,2,3|4])), + {'EXIT', {badarg,_}} = (catch erlang:adler32_combine(Big,3,3)), + {'EXIT', {badarg,_}} = (catch erlang:adler32_combine(3,Big,3)), + {'EXIT', {badarg,_}} = (catch erlang:adler32_combine(3,3,Big)), + {'EXIT', {badarg,_}} = (catch erlang:md5_update(<<"hej">>,<<"hej">>)), + {'EXIT', {badarg,_}} = (catch erlang:md5_final(<<"hej">>)), ok. @@ -72,7 +72,7 @@ nicesplit(N,L) -> nicesplit(0,Tail,Acc) -> {lists:reverse(Acc),Tail}; nicesplit(_,[],Acc) -> - {lists:reverse(Acc),[]}; + {lists:reverse(Acc),[]}; nicesplit(N,[H|Tail],Acc) -> nicesplit(N-1,Tail,[H|Acc]). @@ -81,17 +81,17 @@ run_in_para([],_) -> run_in_para(FunList,Schedulers) -> {ThisTime,NextTime} = nicesplit(Schedulers,FunList), case length(ThisTime) of - 1 -> - [{L,Fun}] = ThisTime, - try - Fun() + 1 -> + [{L,Fun}] = ThisTime, + try + Fun() catch - _:Reason -> - exit({error_at_line,L,Reason}) - end; + _:Reason -> + exit({error_at_line,L,Reason}) + end; _ -> - These = [ {L,erlang:spawn_monitor(F)} || {L,F} <- ThisTime ], - collect_workers(These) + These = [ {L,erlang:spawn_monitor(F)} || {L,F} <- ThisTime ], + collect_workers(These) end, run_in_para(NextTime,Schedulers). @@ -99,147 +99,147 @@ collect_workers([]) -> ok; collect_workers([{L,{Pid,Ref}}|T]) -> receive - {'DOWN',Ref,process,Pid,normal} -> - collect_workers(T); - {'DOWN',Ref,process,Pid,Other} -> - exit({error_at_line,L,Other}) + {'DOWN',Ref,process,Pid,normal} -> + collect_workers(T); + {'DOWN',Ref,process,Pid,Other} -> + exit({error_at_line,L,Other}) end. %% Test crc32, adler32 and md5 on a number of pseudo-randomly generated lists. random_lists(Config) when is_list(Config) -> ct:timetrap({minutes, 5}), - ?line Num = erlang:system_info(schedulers_online), - ?line B = list_to_binary( - lists:duplicate( - (erlang:system_info(context_reductions)*10) - 50,$!)), - ?line CRC32_1 = fun(L) -> erlang:crc32(L) end, - ?line CRC32_2 = fun(L) -> ?REF:crc32(L) end, - ?line ADLER32_1 = fun(L) -> erlang:adler32(L) end, - ?line ADLER32_2 = fun(L) -> ?REF:adler32(L) end, - ?line MD5_1 = fun(L) -> erlang:md5(L) end, - ?line MD5_2 = fun(L) -> ?REF:md5_final( - ?REF:md5_update(?REF:md5_init(),L)) end, - ?line MD5_3 = fun(L) -> erlang:md5_final( - erlang:md5_update(erlang:md5_init(),L)) end, - ?line CRC32_1_L = fun(L) -> erlang:crc32([B|L]) end, - ?line CRC32_2_L = fun(L) -> ?REF:crc32([B|L]) end, - ?line ADLER32_1_L = fun(L) -> erlang:adler32([B|L]) end, - ?line ADLER32_2_L = fun(L) -> ?REF:adler32([B|L]) end, - ?line MD5_1_L = fun(L) -> erlang:md5([B|L]) end, - ?line MD5_2_L = fun(L) -> ?REF:md5_final( - ?REF:md5_update(?REF:md5_init(),[B|L])) end, - ?line MD5_3_L = fun(L) -> erlang:md5_final( - erlang:md5_update( - erlang:md5_init(),[B|L])) end, - ?line Wlist0 = - [{?LINE, fun() -> random_iolist:run(150, CRC32_1, CRC32_2) end}, - {?LINE, fun() -> random_iolist:run(150, ADLER32_1, ADLER32_2) end}, - {?LINE, fun() -> random_iolist:run(150,MD5_1,MD5_2) end}, - {?LINE, fun() -> random_iolist:run(150,MD5_1,MD5_3) end}, - {?LINE, fun() -> random_iolist:run(150, CRC32_1_L, CRC32_2_L) end}, - {?LINE, - fun() -> random_iolist:run(150, ADLER32_1_L, ADLER32_2_L) end}, - {?LINE, fun() -> random_iolist:run(150,MD5_1_L,MD5_2_L) end}, - {?LINE, fun() -> random_iolist:run(150,MD5_1_L,MD5_3_L) end}], - ?line run_in_para(Wlist0,Num), - ?line CRC32_1_2 = fun(L1,L2) -> erlang:crc32([L1,L2]) end, - ?line CRC32_2_2 = fun(L1,L2) -> erlang:crc32(erlang:crc32(L1),L2) end, - ?line CRC32_3_2 = fun(L1,L2) -> erlang:crc32_combine( - erlang:crc32(L1), - erlang:crc32(L2), - erlang:iolist_size(L2)) - end, - ?line ADLER32_1_2 = fun(L1,L2) -> erlang:adler32([L1,L2]) end, - ?line ADLER32_2_2 = fun(L1,L2) -> erlang:adler32( - erlang:adler32(L1),L2) end, - ?line ADLER32_3_2 = fun(L1,L2) -> erlang:adler32_combine( - erlang:adler32(L1), - erlang:adler32(L2), - erlang:iolist_size(L2)) - end, - ?line MD5_1_2 = fun(L1,L2) -> erlang:md5([L1,L2]) end, - ?line MD5_2_2 = fun(L1,L2) -> - erlang:md5_final( - erlang:md5_update( - erlang:md5_update( - erlang:md5_init(), - L1), - L2)) - end, - ?line CRC32_1_L_2 = fun(L1,L2) -> erlang:crc32([[B|L1],[B|L2]]) end, - ?line CRC32_2_L_2 = fun(L1,L2) -> erlang:crc32( - erlang:crc32([B|L1]),[B|L2]) end, - ?line CRC32_3_L_2 = fun(L1,L2) -> erlang:crc32_combine( - erlang:crc32([B|L1]), - erlang:crc32([B|L2]), - erlang:iolist_size([B|L2])) - end, - ?line ADLER32_1_L_2 = fun(L1,L2) -> erlang:adler32([[B|L1],[B|L2]]) end, - ?line ADLER32_2_L_2 = fun(L1,L2) -> erlang:adler32( - erlang:adler32([B|L1]), - [B|L2]) - end, - ?line ADLER32_3_L_2 = fun(L1,L2) -> erlang:adler32_combine( - erlang:adler32([B|L1]), - erlang:adler32([B|L2]), - erlang:iolist_size([B|L2])) - end, - ?line MD5_1_L_2 = fun(L1,L2) -> erlang:md5([[B|L1],[B|L2]]) end, - ?line MD5_2_L_2 = fun(L1,L2) -> - erlang:md5_final( - erlang:md5_update( - erlang:md5_update( - erlang:md5_init(), - [B|L1]), - [B|L2])) - end, - ?line Wlist1 = - [{?LINE, fun() -> random_iolist:run2(150,CRC32_1_2,CRC32_2_2) end}, - {?LINE, fun() -> random_iolist:run2(150,CRC32_1_2,CRC32_3_2) end}, - {?LINE, fun() -> random_iolist:run2(150,ADLER32_1_2,ADLER32_2_2) end}, - {?LINE, fun() -> random_iolist:run2(150,ADLER32_1_2,ADLER32_3_2) end}, - {?LINE, fun() -> random_iolist:run2(150,MD5_1_2,MD5_2_2) end}, - {?LINE, fun() -> random_iolist:run2(150,CRC32_1_L_2,CRC32_2_L_2) end}, - {?LINE, fun() -> random_iolist:run2(150,CRC32_1_L_2,CRC32_3_L_2) end}, - {?LINE, - fun() -> random_iolist:run2(150,ADLER32_1_L_2,ADLER32_2_L_2) end}, - {?LINE, - fun() -> random_iolist:run2(150,ADLER32_1_L_2,ADLER32_3_L_2) end}, - {?LINE, fun() -> random_iolist:run2(150,MD5_1_L_2,MD5_2_L_2) end}], - ?line run_in_para(Wlist1,Num), + Num = erlang:system_info(schedulers_online), + B = list_to_binary( + lists:duplicate( + (erlang:system_info(context_reductions)*10) - 50,$!)), + CRC32_1 = fun(L) -> erlang:crc32(L) end, + CRC32_2 = fun(L) -> ?REF:crc32(L) end, + ADLER32_1 = fun(L) -> erlang:adler32(L) end, + ADLER32_2 = fun(L) -> ?REF:adler32(L) end, + MD5_1 = fun(L) -> erlang:md5(L) end, + MD5_2 = fun(L) -> ?REF:md5_final( + ?REF:md5_update(?REF:md5_init(),L)) end, + MD5_3 = fun(L) -> erlang:md5_final( + erlang:md5_update(erlang:md5_init(),L)) end, + CRC32_1_L = fun(L) -> erlang:crc32([B|L]) end, + CRC32_2_L = fun(L) -> ?REF:crc32([B|L]) end, + ADLER32_1_L = fun(L) -> erlang:adler32([B|L]) end, + ADLER32_2_L = fun(L) -> ?REF:adler32([B|L]) end, + MD5_1_L = fun(L) -> erlang:md5([B|L]) end, + MD5_2_L = fun(L) -> ?REF:md5_final( + ?REF:md5_update(?REF:md5_init(),[B|L])) end, + MD5_3_L = fun(L) -> erlang:md5_final( + erlang:md5_update( + erlang:md5_init(),[B|L])) end, + Wlist0 = + [{?LINE, fun() -> random_iolist:run(150, CRC32_1, CRC32_2) end}, + {?LINE, fun() -> random_iolist:run(150, ADLER32_1, ADLER32_2) end}, + {?LINE, fun() -> random_iolist:run(150,MD5_1,MD5_2) end}, + {?LINE, fun() -> random_iolist:run(150,MD5_1,MD5_3) end}, + {?LINE, fun() -> random_iolist:run(150, CRC32_1_L, CRC32_2_L) end}, + {?LINE, + fun() -> random_iolist:run(150, ADLER32_1_L, ADLER32_2_L) end}, + {?LINE, fun() -> random_iolist:run(150,MD5_1_L,MD5_2_L) end}, + {?LINE, fun() -> random_iolist:run(150,MD5_1_L,MD5_3_L) end}], + run_in_para(Wlist0,Num), + CRC32_1_2 = fun(L1,L2) -> erlang:crc32([L1,L2]) end, + CRC32_2_2 = fun(L1,L2) -> erlang:crc32(erlang:crc32(L1),L2) end, + CRC32_3_2 = fun(L1,L2) -> erlang:crc32_combine( + erlang:crc32(L1), + erlang:crc32(L2), + erlang:iolist_size(L2)) + end, + ADLER32_1_2 = fun(L1,L2) -> erlang:adler32([L1,L2]) end, + ADLER32_2_2 = fun(L1,L2) -> erlang:adler32( + erlang:adler32(L1),L2) end, + ADLER32_3_2 = fun(L1,L2) -> erlang:adler32_combine( + erlang:adler32(L1), + erlang:adler32(L2), + erlang:iolist_size(L2)) + end, + MD5_1_2 = fun(L1,L2) -> erlang:md5([L1,L2]) end, + MD5_2_2 = fun(L1,L2) -> + erlang:md5_final( + erlang:md5_update( + erlang:md5_update( + erlang:md5_init(), + L1), + L2)) + end, + CRC32_1_L_2 = fun(L1,L2) -> erlang:crc32([[B|L1],[B|L2]]) end, + CRC32_2_L_2 = fun(L1,L2) -> erlang:crc32( + erlang:crc32([B|L1]),[B|L2]) end, + CRC32_3_L_2 = fun(L1,L2) -> erlang:crc32_combine( + erlang:crc32([B|L1]), + erlang:crc32([B|L2]), + erlang:iolist_size([B|L2])) + end, + ADLER32_1_L_2 = fun(L1,L2) -> erlang:adler32([[B|L1],[B|L2]]) end, + ADLER32_2_L_2 = fun(L1,L2) -> erlang:adler32( + erlang:adler32([B|L1]), + [B|L2]) + end, + ADLER32_3_L_2 = fun(L1,L2) -> erlang:adler32_combine( + erlang:adler32([B|L1]), + erlang:adler32([B|L2]), + erlang:iolist_size([B|L2])) + end, + MD5_1_L_2 = fun(L1,L2) -> erlang:md5([[B|L1],[B|L2]]) end, + MD5_2_L_2 = fun(L1,L2) -> + erlang:md5_final( + erlang:md5_update( + erlang:md5_update( + erlang:md5_init(), + [B|L1]), + [B|L2])) + end, + Wlist1 = + [{?LINE, fun() -> random_iolist:run2(150,CRC32_1_2,CRC32_2_2) end}, + {?LINE, fun() -> random_iolist:run2(150,CRC32_1_2,CRC32_3_2) end}, + {?LINE, fun() -> random_iolist:run2(150,ADLER32_1_2,ADLER32_2_2) end}, + {?LINE, fun() -> random_iolist:run2(150,ADLER32_1_2,ADLER32_3_2) end}, + {?LINE, fun() -> random_iolist:run2(150,MD5_1_2,MD5_2_2) end}, + {?LINE, fun() -> random_iolist:run2(150,CRC32_1_L_2,CRC32_2_L_2) end}, + {?LINE, fun() -> random_iolist:run2(150,CRC32_1_L_2,CRC32_3_L_2) end}, + {?LINE, + fun() -> random_iolist:run2(150,ADLER32_1_L_2,ADLER32_2_L_2) end}, + {?LINE, + fun() -> random_iolist:run2(150,ADLER32_1_L_2,ADLER32_3_L_2) end}, + {?LINE, fun() -> random_iolist:run2(150,MD5_1_L_2,MD5_2_L_2) end}], + run_in_para(Wlist1,Num), ok. %% Generate MD5 message digests and check the result. Examples are from RFC-1321. t_md5(Config) when is_list(Config) -> - ?line t_md5_test("", "d41d8cd98f00b204e9800998ecf8427e"), - ?line t_md5_test("a", "0cc175b9c0f1b6a831c399e269772661"), - ?line t_md5_test("abc", "900150983cd24fb0d6963f7d28e17f72"), - ?line t_md5_test(["message ","digest"], "f96b697d7cb7938d525a2f31aaf161d0"), - ?line t_md5_test(["message ",unaligned_sub_bin(<<"digest">>)], - "f96b697d7cb7938d525a2f31aaf161d0"), - ?line t_md5_test("abcdefghijklmnopqrstuvwxyz", - "c3fcd3d76192e4007dfb496cca67e13b"), - ?line t_md5_test("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" - "0123456789", - "d174ab98d277d9f5a5611c2c9f419d9f"), - ?line t_md5_test("12345678901234567890123456789012345678901234567890" - "123456789012345678901234567890", - "57edf4a22be3c955ac49da2e2107b67a"), + t_md5_test("", "d41d8cd98f00b204e9800998ecf8427e"), + t_md5_test("a", "0cc175b9c0f1b6a831c399e269772661"), + t_md5_test("abc", "900150983cd24fb0d6963f7d28e17f72"), + t_md5_test(["message ","digest"], "f96b697d7cb7938d525a2f31aaf161d0"), + t_md5_test(["message ",unaligned_sub_bin(<<"digest">>)], + "f96b697d7cb7938d525a2f31aaf161d0"), + t_md5_test("abcdefghijklmnopqrstuvwxyz", + "c3fcd3d76192e4007dfb496cca67e13b"), + t_md5_test("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789", + "d174ab98d277d9f5a5611c2c9f419d9f"), + t_md5_test("12345678901234567890123456789012345678901234567890" + "123456789012345678901234567890", + "57edf4a22be3c955ac49da2e2107b67a"), ok. %% Generate MD5 message using md5_init, md5_update, and md5_final, and %% check the result. Examples are from RFC-1321. t_md5_update(Config) when is_list(Config) -> - ?line t_md5_update_1(fun(Str) -> Str end), - ?line t_md5_update_1(fun(Str) -> list_to_binary(Str) end), - ?line t_md5_update_1(fun(Str) -> unaligned_sub_bin(list_to_binary(Str)) end), + t_md5_update_1(fun(Str) -> Str end), + t_md5_update_1(fun(Str) -> list_to_binary(Str) end), + t_md5_update_1(fun(Str) -> unaligned_sub_bin(list_to_binary(Str)) end), ok. t_md5_update_1(Tr) when is_function(Tr, 1) -> Ctx = erlang:md5_init(), Ctx1 = erlang:md5_update(Ctx, Tr("ABCDEFGHIJKLMNOPQRSTUVWXYZ")), Ctx2 = erlang:md5_update(Ctx1, Tr("abcdefghijklmnopqrstuvwxyz" - "0123456789")), + "0123456789")), m(erlang:md5_final(Ctx2), hexstr2bin("d174ab98d277d9f5a5611c2c9f419d9f")), ok. @@ -247,28 +247,28 @@ t_md5_update_1(Tr) when is_function(Tr, 1) -> %% %% error(Config) when is_list(Config) -> - ?line {'EXIT',{badarg,_}} = (catch erlang:md5(bit_sized_binary(<<"abc">>))), - ?line Ctx0 = erlang:md5_init(), - ?line {'EXIT',{badarg,_}} = - (catch erlang:md5_update(Ctx0, bit_sized_binary(<<"abcfjldjd">>))), - ?line {'EXIT',{badarg,_}} = - (catch erlang:md5_update(Ctx0, ["something",bit_sized_binary(<<"abcfjldjd">>)])), - ?line {'EXIT',{badarg,_}} = - (catch erlang:md5_update(bit_sized_binary(Ctx0), "something")), - ?line {'EXIT',{badarg,_}} = (catch erlang:md5_final(bit_sized_binary(Ctx0))), - ?line m(erlang:md5_final(Ctx0), hexstr2bin("d41d8cd98f00b204e9800998ecf8427e")), + {'EXIT',{badarg,_}} = (catch erlang:md5(bit_sized_binary(<<"abc">>))), + Ctx0 = erlang:md5_init(), + {'EXIT',{badarg,_}} = + (catch erlang:md5_update(Ctx0, bit_sized_binary(<<"abcfjldjd">>))), + {'EXIT',{badarg,_}} = + (catch erlang:md5_update(Ctx0, ["something",bit_sized_binary(<<"abcfjldjd">>)])), + {'EXIT',{badarg,_}} = + (catch erlang:md5_update(bit_sized_binary(Ctx0), "something")), + {'EXIT',{badarg,_}} = (catch erlang:md5_final(bit_sized_binary(Ctx0))), + m(erlang:md5_final(Ctx0), hexstr2bin("d41d8cd98f00b204e9800998ecf8427e")), ok. %% %% unaligned_context(Config) when is_list(Config) -> - ?line Ctx0 = erlang:md5_init(), - ?line Ctx1 = erlang:md5_update(unaligned_sub_bin(Ctx0), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), - ?line Ctx = erlang:md5_update(unaligned_sub_bin(Ctx1), - "abcdefghijklmnopqrstuvwxyz0123456789"), - ?line m(erlang:md5_final(unaligned_sub_bin(Ctx)), - hexstr2bin("d174ab98d277d9f5a5611c2c9f419d9f")), + Ctx0 = erlang:md5_init(), + Ctx1 = erlang:md5_update(unaligned_sub_bin(Ctx0), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), + Ctx = erlang:md5_update(unaligned_sub_bin(Ctx1), + "abcdefghijklmnopqrstuvwxyz0123456789"), + m(erlang:md5_final(unaligned_sub_bin(Ctx)), + hexstr2bin("d174ab98d277d9f5a5611c2c9f419d9f")), ok. %% @@ -314,5 +314,3 @@ bit_sized_binary(Bin0) -> Bin. id(I) -> I. - - -- cgit v1.2.3 From 6664eed554974336909d3ffe03f20349cc4c38fd Mon Sep 17 00:00:00 2001 From: Henrik Nord Date: Tue, 15 Mar 2016 15:19:56 +0100 Subject: update copyright-year --- erts/emulator/test/crypto_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/emulator/test/crypto_SUITE.erl') diff --git a/erts/emulator/test/crypto_SUITE.erl b/erts/emulator/test/crypto_SUITE.erl index 6212997272..afb1be7332 100644 --- a/erts/emulator/test/crypto_SUITE.erl +++ b/erts/emulator/test/crypto_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2011. All Rights Reserved. +%% Copyright Ericsson AB 1999-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. -- cgit v1.2.3