diff options
Diffstat (limited to 'erts/emulator/test/bs_match_bin_SUITE.erl')
-rw-r--r-- | erts/emulator/test/bs_match_bin_SUITE.erl | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/erts/emulator/test/bs_match_bin_SUITE.erl b/erts/emulator/test/bs_match_bin_SUITE.erl index a7f5ad2d6b..c29fbd6be7 100644 --- a/erts/emulator/test/bs_match_bin_SUITE.erl +++ b/erts/emulator/test/bs_match_bin_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2022. All Rights Reserved. +%% Copyright Ericsson AB 1999-2023. 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. @@ -23,17 +23,18 @@ -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, byte_split_binary/1,bit_split_binary/1,match_huge_bin/1, - bs_match_string_edge_case/1]). + bs_match_string_edge_case/1,contexts/1, + empty_binary/1]). -include_lib("common_test/include/ct.hrl"). suite() -> [{ct_hooks,[ts_install_cth]}]. -all() -> +all() -> [byte_split_binary, bit_split_binary, match_huge_bin, - bs_match_string_edge_case]. + bs_match_string_edge_case, contexts, empty_binary]. -groups() -> +groups() -> []. init_per_suite(Config) -> @@ -235,3 +236,50 @@ bs_match_string_edge_case(_Config) -> <<?MATCH512, " ", Tail1/binary>> = Bin, <<" ", Tail1/binary>> = id(Tail0), ok. + +contexts(_Config) -> + Bytes = rand:bytes(12), + _ = [begin + <<B:N/binary,_/binary>> = Bytes, + B = id(get_binary(B)) + end || N <- lists:seq(0, 12)], + ok. + +get_binary(Bin) -> + [A,B,C,D,E,F] = id([1,2,3,4,5,6]), + {Res,_} = get_binary_memory_ctx(A, B, C, D, E, F, Bin), + Res. + + +get_binary_memory_ctx(A, B, C, D, E, F, Bin) -> + %% The match context will be in {x,6}, which is not + %% a X register backed by a CPU register on any platform. + Res = case Bin of + <<Res0:0/binary>> -> Res0; + <<Res0:1/binary>> -> Res0; + <<Res0:2/binary>> -> Res0; + <<Res0:3/binary>> -> Res0; + <<Res0:4/binary>> -> Res0; + <<Res0:5/binary>> -> Res0; + <<Res0:6/binary>> -> Res0; + <<Res0:7/binary>> -> Res0; + <<Res0:8/binary>> -> Res0; + <<Res0:9/binary>> -> Res0; + <<Res0:10/binary>> -> Res0; + <<Res0:11/binary>> -> Res0; + <<Res0:12/binary>> -> Res0 + end, + {Res,{A,B,C,D,E,F}}. + +empty_binary(_Config) -> + _ = do_empty_binary(1_000_000), + ok. + +do_empty_binary(0) -> + ok; +do_empty_binary(N) -> + %% The new bs_match instruction would use more heap space + %% than reserved when matching out an empty binary. + <<V1:0/bits, V1:0/bitstring, V2:0/bytes, V2:0/bits>> = <<>>, + [0|do_empty_binary(N-1)]. + |