File 1277-Emulator-tests-Correct-invalid-BEAM-code-file.patch of Package erlang

From b31681a463fda8ad0567d2c5aa0addf405e0e2c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Wed, 8 Sep 2021 06:04:22 +0200
Subject: [PATCH] Emulator tests: Correct invalid BEAM code file

In 55eef00e9e0, the literal_case_expression.S file (used by
beam_literals_SUITE) was manually edited to add some more
functions. Unfortunately, the new functions zi1/0 and zi2/0 got the
same entry label (16), but that mistake was not caught at the time,
because the beam_peep pass happened to repair that problem while
renumbering labels.

While at it, also stop the compiler from doing some optimizations.
After all, the purpose of the test suite is to test how the loader and
BEAM machine handles literals.
---
 erts/emulator/test/beam_literals_SUITE.erl                   | 5 +++--
 .../test/beam_literals_SUITE_data/literal_case_expression.S  | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/erts/emulator/test/beam_literals_SUITE.erl b/erts/emulator/test/beam_literals_SUITE.erl
index 7b49a99a60..0a87c95527 100644
--- a/erts/emulator/test/beam_literals_SUITE.erl
+++ b/erts/emulator/test/beam_literals_SUITE.erl
@@ -57,7 +57,7 @@ end_per_group(_GroupName, Config) ->
 
 %% Test creating lists and tuples containing big number literals.
 putting(Config) when is_list(Config) ->
-    -773973888575883407313908 = chksum(putting1(8987697898797)).
+    -773973888575883407313908 = chksum(putting1(id(8987697898797))).
 
 putting1(X) ->
     {8797987987987987872256443, [1324483773773], {3.1415, 2.71, [2.5, 35.125|9.31]},
@@ -522,7 +522,8 @@ fconv_2(F) when is_float(F) ->
 literal_case_expression(Config) when is_list(Config) ->
     DataDir = proplists:get_value(data_dir, Config),
     Src = filename:join(DataDir, "literal_case_expression"),
-    {ok,literal_case_expression=Mod,Code} = compile:file(Src, [from_asm,binary]),
+    Opts = [from_asm,binary,no_postopt],
+    {ok,literal_case_expression=Mod,Code} = compile:file(Src, Opts),
     {module,Mod} = code:load_binary(Mod, Src, Code),
     ok = Mod:x(),
     ok = Mod:y(),
diff --git a/erts/emulator/test/beam_literals_SUITE_data/literal_case_expression.S b/erts/emulator/test/beam_literals_SUITE_data/literal_case_expression.S
index bfdfc079dc..e64e98787a 100644
--- a/erts/emulator/test/beam_literals_SUITE_data/literal_case_expression.S
+++ b/erts/emulator/test/beam_literals_SUITE_data/literal_case_expression.S
@@ -73,7 +73,7 @@
   {label,19}.
     {case_end,{integer,42}}.
 
-{function, zi2, 0, 16}.
+{function, zi2, 0, 21}.
   {label,20}.
     {func_info,{atom,literal_case_expression},{atom,zi2},0}.
   {label,21}.
-- 
2.31.1

openSUSE Build Service is sponsored by