diff options
author | Rickard Green <rickard@erlang.org> | 2019-11-06 13:06:39 +0100 |
---|---|---|
committer | Rickard Green <rickard@erlang.org> | 2019-11-06 13:06:39 +0100 |
commit | a3891040414b2b7ca6d37343681b9abf0a3045f8 (patch) | |
tree | f75dd6b3032860b007b4ec7e79b61b58daf3cbc4 /erts/emulator/test/binary_SUITE.erl | |
parent | c32840ae780dd46ba0507ca8c595c82cd9945ed7 (diff) | |
parent | ac7c06e56968d841e141a51b471e5eb16f8d05fb (diff) | |
download | erlang-a3891040414b2b7ca6d37343681b9abf0a3045f8.tar.gz |
Merge branch 'maint'
* maint:
erts: Fix bug for --enable-sharing-preserving and bit strings
Diffstat (limited to 'erts/emulator/test/binary_SUITE.erl')
-rw-r--r-- | erts/emulator/test/binary_SUITE.erl | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/erts/emulator/test/binary_SUITE.erl b/erts/emulator/test/binary_SUITE.erl index 57c3c8e499..6227148614 100644 --- a/erts/emulator/test/binary_SUITE.erl +++ b/erts/emulator/test/binary_SUITE.erl @@ -60,6 +60,7 @@ t_iolist_size_deep_short_lists/1, t_iolist_size_deep_tiny_lists/1, t_hash/1, + sub_bin_copy/1, bad_size/1, bad_term_to_binary/1, bad_binary_to_term_2/1,safe_binary_to_term2/1, @@ -92,7 +93,8 @@ all() -> b2t_used_big, bad_binary_to_term_2, safe_binary_to_term2, bad_binary_to_term, bad_terms, t_hash, bad_size, - bad_term_to_binary, t2b_system_limit, term_to_iovec, more_bad_terms, + sub_bin_copy, bad_term_to_binary, t2b_system_limit, + term_to_iovec, more_bad_terms, otp_5484, otp_5933, ordering, unaligned_order, gc_test, bit_sized_binary_sizes, otp_6817, otp_8117, deep, @@ -1859,6 +1861,42 @@ cmp_old_impl(Config) when is_list(Config) -> ok end. +%% OTP-16265 +%% This testcase is mainly targeted toward --enable-sharing-preserving. +sub_bin_copy(Config) when is_list(Config) -> + Papa = self(), + Echo = spawn_link(fun() -> echo(Papa) end), + HeapBin = list_to_binary(lists:seq(1,3)), + sub_bin_copy_1(HeapBin, Echo), + ProcBin = list_to_binary(lists:seq(1,65)), + sub_bin_copy_1(ProcBin, Echo), + unlink(Echo), + exit(Echo, kill), + ok. + +sub_bin_copy_1(RealBin, Echo) -> + Bits = bit_size(RealBin) - 1, + <<SubBin:Bits/bits, _/bits>> = RealBin, + + %% Send (copy) messages consisting of combinations of both + %% the SubBin and the RealBin it refers to. + [begin + Echo ! Combo, + {_, Combo} = {Combo, receive M -> M end} + end + || Len <- lists:seq(2,5), Combo <- combos([RealBin, SubBin], Len)], + ok. + +combos(_, 0) -> + [[]]; +combos(Elements, Len) -> + [[E | C] || E <- Elements, C <- combos(Elements,Len-1)]. + +echo(Papa) -> + receive M -> Papa ! M end, + echo(Papa). + + %% Utilities. huge_iolist(Lim) -> |