From 300698da10e777c2a466dd02accf6179dd79e130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 29 Jun 2016 14:23:30 +0200 Subject: bif_SUITE: Cover the remaining uncovered lines --- lib/compiler/test/bif_SUITE.erl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'lib/compiler/test') diff --git a/lib/compiler/test/bif_SUITE.erl b/lib/compiler/test/bif_SUITE.erl index 6bde2f1da9..bba2058f2f 100644 --- a/lib/compiler/test/bif_SUITE.erl +++ b/lib/compiler/test/bif_SUITE.erl @@ -23,7 +23,7 @@ -export([all/0,suite/0,groups/0,init_per_suite/1,end_per_suite/1, init_per_group/2,end_per_group/2, - beam_validator/1,trunc_and_friends/1]). + beam_validator/1,trunc_and_friends/1,cover_safe_bifs/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -35,7 +35,8 @@ all() -> groups() -> [{p,[parallel], [beam_validator, - trunc_and_friends + trunc_and_friends, + cover_safe_bifs ]}]. init_per_suite(Config) -> @@ -104,3 +105,18 @@ trunc_template(Func, Bif) -> try begin _@Bif@(a), ok end catch error:badarg -> ok end, ok."). + +cover_safe_bifs(Config) -> + _ = get(), + _ = get_keys(a), + _ = group_leader(), + _ = is_alive(), + _ = min(Config, []), + _ = nodes(), + _ = erlang:ports(), + _ = pre_loaded(), + _ = processes(), + _ = registered(), + _ = term_to_binary(Config), + + ok. -- cgit v1.2.3 From 97820c026969de7e98d948b301da1e6956f0504d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 29 Jun 2016 06:08:29 +0200 Subject: bs_match_SUITE: Add a test case for beam_utils During development, a bug in beam_utils caused a compiler failure in xmerl. If the bug reappears, make sure that we catch it when compiling the compiler test suite. --- lib/compiler/test/bs_match_SUITE.erl | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'lib/compiler/test') diff --git a/lib/compiler/test/bs_match_SUITE.erl b/lib/compiler/test/bs_match_SUITE.erl index 224abf6c29..f8af070c44 100644 --- a/lib/compiler/test/bs_match_SUITE.erl +++ b/lib/compiler/test/bs_match_SUITE.erl @@ -38,7 +38,8 @@ no_partition/1,calling_a_binary/1,binary_in_map/1, match_string_opt/1,select_on_integer/1, map_and_binary/1,unsafe_branch_caching/1, - bad_literals/1,good_literals/1,constant_propagation/1]). + bad_literals/1,good_literals/1,constant_propagation/1, + parse_xml/1]). -export([coverage_id/1,coverage_external_ignore/2]). @@ -69,7 +70,7 @@ groups() -> no_partition,calling_a_binary,binary_in_map, match_string_opt,select_on_integer, map_and_binary,unsafe_branch_caching, - bad_literals,good_literals,constant_propagation]}]. + bad_literals,good_literals,constant_propagation,parse_xml]}]. init_per_suite(Config) -> @@ -1451,6 +1452,26 @@ constant_propagation_c() -> X end. +parse_xml(_Config) -> + <<"> = do_parse_xml(<<">), + <<" ">> = do_parse_xml(<<">), + ok. + +do_parse_xml(<<"> = Bytes) -> + %% Delayed sub-binary creation is not safe. A buggy (development) + %% version of check_liveness_everywhere() in beam_utils would turn + %% on the optimization. + Rest1 = case is_next_char_whitespace(Rest) of + false -> + Bytes; + true -> + id(Rest) + end, + id(Rest1). + +is_next_char_whitespace(<>) -> + C =:= $\s. + check(F, R) -> R = F(). -- cgit v1.2.3 From 01835845579e9f0a8da3574864747cd3ba10db6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 23 May 2016 20:13:48 +0200 Subject: Simplify beam_utils When beam_utils was first written, it did not have the functions for testing whether a register was not used. Those were added later, in sort of a hacky way. Also, is_killed*() and is_not_used*() for Y registers would return the same answer. Fix that to make the API more consistent (an Y register can only be killed by a deallocate/1 instruction). We will need to change beam_trim to call beam_utils:is_not_used/3 instead of beam_utils:is_killed/3. --- lib/compiler/test/beam_utils_SUITE.erl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/compiler/test') diff --git a/lib/compiler/test/beam_utils_SUITE.erl b/lib/compiler/test/beam_utils_SUITE.erl index f6d4a311bb..5e29f8d7b4 100644 --- a/lib/compiler/test/beam_utils_SUITE.erl +++ b/lib/compiler/test/beam_utils_SUITE.erl @@ -283,6 +283,9 @@ coverage(_Config) -> {'EXIT',{function_clause,_}} = (catch town(overall, {{abc},alcohol})), + self() ! junk_message, + {"url",#{true:="url"}} = appointment(#{"resolution" => "url"}), + ok. %% Cover check_liveness/3. @@ -352,6 +355,9 @@ yellow(Hill) -> Hill, id(42). +do(A, B) -> {A,B}. +appointment(#{"resolution" := Url}) -> + do(receive _ -> Url end, #{true => Url}). %% The identity function. id(I) -> I. -- cgit v1.2.3