aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-09-13 09:49:49 +0200
committerBjörn Gustavsson <[email protected]>2011-09-13 09:51:17 +0200
commitc5eb04243f480d860626e955c1d6b82b938cdf02 (patch)
treea4883915bc4564c1442dcdb009c31e1dc00f842a /lib
parent4c747daecf8bfd22dafaf0e0d649ad02ec813f13 (diff)
downloadotp-c5eb04243f480d860626e955c1d6b82b938cdf02.tar.gz
otp-c5eb04243f480d860626e955c1d6b82b938cdf02.tar.bz2
otp-c5eb04243f480d860626e955c1d6b82b938cdf02.zip
beam_lib_SUITE: Don't assume that "Abst" is the last chunk
"Line" is now the last chunk in a BEAM file, causing beam_lib_SUITE:error/1 to fail. To avoid being bitten by this problem again, don't simply change "Abst" to "Line", but use beam_lib:info/1 to find out the name of the last chunk.
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/test/beam_lib_SUITE.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/stdlib/test/beam_lib_SUITE.erl b/lib/stdlib/test/beam_lib_SUITE.erl
index b7fb1f618f..1788dcc85e 100644
--- a/lib/stdlib/test/beam_lib_SUITE.erl
+++ b/lib/stdlib/test/beam_lib_SUITE.erl
@@ -181,7 +181,8 @@ error(Conf) when is_list(Conf) ->
?line verify(not_a_beam_file, beam_lib:info(<<"short">>)),
?line {Binary1, _} = split_binary(Binary, byte_size(Binary)-10),
- ?line verify(chunk_too_big, beam_lib:chunks(Binary1, ["Abst"])),
+ LastChunk = last_chunk(Binary),
+ ?line verify(chunk_too_big, beam_lib:chunks(Binary1, [LastChunk])),
?line Chunks = chunk_info(Binary),
?line {value, {_, AbstractStart, _}} = lists:keysearch("Abst", 1, Chunks),
?line {Binary2, _} = split_binary(Binary, AbstractStart),
@@ -205,6 +206,12 @@ error(Conf) when is_list(Conf) ->
?line file:delete(ACopy),
ok.
+last_chunk(Bin) ->
+ L = beam_lib:info(Bin),
+ {chunks,Chunks} = lists:keyfind(chunks, 1, L),
+ {Last,_,_} = lists:last(Chunks),
+ Last.
+
do_error(BeamFile, ACopy) ->
% evil tests
?line Chunks = chunk_info(BeamFile),