diff options
author | Björn Gustavsson <[email protected]> | 2019-03-22 10:22:24 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-03-25 09:58:58 +0100 |
commit | 6f248d2f73475319b25ad00676168ec75f682489 (patch) | |
tree | 233da8f9b99bb103bd8245b9c76c0c1ae6c2bd0a /lib/compiler/test | |
parent | f3293ecdb3c223ec10babbbf26569e00f89ae28d (diff) | |
download | otp-6f248d2f73475319b25ad00676168ec75f682489.tar.gz otp-6f248d2f73475319b25ad00676168ec75f682489.tar.bz2 otp-6f248d2f73475319b25ad00676168ec75f682489.zip |
Add test_lib:highest_opcode/1
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/compile_SUITE.erl | 4 | ||||
-rw-r--r-- | lib/compiler/test/test_lib.erl | 11 |
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/compiler/test/compile_SUITE.erl b/lib/compiler/test/compile_SUITE.erl index 408af80dd9..53627b9d81 100644 --- a/lib/compiler/test/compile_SUITE.erl +++ b/lib/compiler/test/compile_SUITE.erl @@ -1431,9 +1431,7 @@ bc_options(Config) -> highest_opcode(DataDir, Mod, Opt) -> Src = filename:join(DataDir, atom_to_list(Mod)++".erl"), {ok,Mod,Beam} = compile:file(Src, [binary|Opt]), - {ok,{Mod,[{"Code",Code}]}} = beam_lib:chunks(Beam, ["Code"]), - <<16:32,0:32,HighestOpcode:32,_/binary>> = Code, - HighestOpcode. + test_lib:highest_opcode(Beam). deterministic_include(Config) when is_list(Config) -> DataDir = proplists:get_value(data_dir, Config), diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl index 39c26c6142..3348c6e9ea 100644 --- a/lib/compiler/test/test_lib.erl +++ b/lib/compiler/test/test_lib.erl @@ -22,7 +22,8 @@ -include_lib("common_test/include/ct.hrl"). -compile({no_auto_import,[binary_part/2]}). -export([id/1,recompile/1,parallel/0,uniq/0,opt_opts/1,get_data_dir/1, - is_cloned_mod/1,smoke_disasm/1,p_run/2]). + is_cloned_mod/1,smoke_disasm/1,p_run/2, + highest_opcode/1]). %% Used by test case that override BIFs. -export([binary_part/2,binary/1]). @@ -113,6 +114,14 @@ is_cloned_mod_1("_no_module_opt_SUITE") -> true; is_cloned_mod_1([_|T]) -> is_cloned_mod_1(T); is_cloned_mod_1([]) -> false. +%% Return the highest opcode use in the BEAM module. + +highest_opcode(Beam) -> + {ok,{_Mod,[{"Code",Code}]}} = beam_lib:chunks(Beam, ["Code"]), + FormatNumber = 0, + <<16:32,FormatNumber:32,HighestOpcode:32,_/binary>> = Code, + HighestOpcode. + %% p_run(fun(Data) -> ok|error, List) -> ok %% Will fail the test case if there were any errors. |