aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/binary_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/test/binary_SUITE.erl')
-rw-r--r--erts/emulator/test/binary_SUITE.erl50
1 files changed, 44 insertions, 6 deletions
diff --git a/erts/emulator/test/binary_SUITE.erl b/erts/emulator/test/binary_SUITE.erl
index babdb3363f..08ab094019 100644
--- a/erts/emulator/test/binary_SUITE.erl
+++ b/erts/emulator/test/binary_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2013. 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
@@ -47,7 +47,8 @@
copy_terms/1, conversions/1, deep_lists/1, deep_bitstr_lists/1,
bad_list_to_binary/1, bad_binary_to_list/1,
t_split_binary/1, bad_split/1,
- terms/1, terms_float/1, external_size/1, t_iolist_size/1,
+ terms/1, terms_float/1, float_middle_endian/1,
+ external_size/1, t_iolist_size/1,
t_hash/1,
bad_size/1,
bad_term_to_binary/1,
@@ -57,10 +58,10 @@
ordering/1,unaligned_order/1,gc_test/1,
bit_sized_binary_sizes/1,
otp_6817/1,deep/1,obsolete_funs/1,robustness/1,otp_8117/1,
- otp_8180/1]).
+ otp_8180/1, ttb_trap/1]).
%% Internal exports.
--export([sleeper/0]).
+-export([sleeper/0,ttb_loop/2]).
suite() -> [{ct_hooks,[ts_install_cth]},
{timetrap,{minutes,2}}].
@@ -69,13 +70,13 @@ all() ->
[copy_terms, conversions, deep_lists, deep_bitstr_lists,
t_split_binary, bad_split,
bad_list_to_binary, bad_binary_to_list, terms,
- terms_float, external_size, t_iolist_size,
+ terms_float, float_middle_endian, external_size, t_iolist_size,
bad_binary_to_term_2, safe_binary_to_term2,
bad_binary_to_term, bad_terms, t_hash, bad_size,
bad_term_to_binary, more_bad_terms, otp_5484, otp_5933,
ordering, unaligned_order, gc_test,
bit_sized_binary_sizes, otp_6817, otp_8117, deep,
- obsolete_funs, robustness, otp_8180].
+ obsolete_funs, robustness, otp_8180, ttb_trap].
groups() ->
[].
@@ -486,6 +487,11 @@ terms_float(Config) when is_list(Config) ->
true = Size1 < Size0
end).
+float_middle_endian(Config) when is_list(Config) ->
+ %% Testing for roundtrip is not enough.
+ ?line <<131,70,63,240,0,0,0,0,0,0>> = term_to_binary(1.0, [{minor_version,1}]),
+ ?line 1.0 = binary_to_term(<<131,70,63,240,0,0,0,0,0,0>>).
+
external_size(Config) when is_list(Config) ->
%% Build a term whose external size only fits in a big num (on 32-bit CPU).
?line external_size_1(16#11111111111111117777777777777777888889999, 0, 16#FFFFFFF),
@@ -1322,6 +1328,38 @@ run_otp_8180(Name) ->
end || Bin <- Bins],
ok.
+%% Test that exit and GC during term_to_binary trap does not crash.
+ttb_trap(Config) when is_list(Config)->
+ case erlang:system_info(wordsize) of
+ N when N < 8 ->
+ {skipped, "Only on 64bit machines"};
+ _ ->
+ do_ttb_trap(5)
+ end.
+
+do_ttb_trap(0) ->
+ ok;
+do_ttb_trap(N) ->
+ Pid = spawn(?MODULE,ttb_loop,[1000,self()]),
+ receive ok -> ok end,
+ receive after 100 -> ok end,
+ erlang:garbage_collect(Pid),
+ receive after 100 -> ok end,
+ exit(Pid,kill),
+ receive after 1 -> ok end,
+ do_ttb_trap(N-1).
+
+ttb_loop(N,Pid) ->
+ Term = lists:duplicate(2000000,2000000),
+ Pid ! ok,
+ ttb_loop2(N,Term).
+ttb_loop2(0,_T) ->
+ ok;
+ttb_loop2(N,T) ->
+ apply(erlang,term_to_binary,[T]),
+ ttb_loop2(N-1,T).
+
+
%% Utilities.
make_sub_binary(Bin) when is_binary(Bin) ->