From ffe77f0c6458b152b1afb4eab56e41fe2580b150 Mon Sep 17 00:00:00 2001
From: Tim Jammer <tim.jammer@tu-darmstadt.de>
Date: Thu, 2 May 2024 20:14:34 +0200
Subject: [PATCH] fix previous fix about doubly allocating buffers

---
 scripts/errors/coll/Correct.py           | 2 +-
 scripts/errors/coll/ParamMatching.py     | 3 ++-
 scripts/errors/coll/ParamMatchingType.py | 4 +++-
 scripts/errors/dtypes/DtypeMissmatch.py  | 4 +++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/scripts/errors/coll/Correct.py b/scripts/errors/coll/Correct.py
index 07cd7cbcb..59b2d4d19 100644
--- a/scripts/errors/coll/Correct.py
+++ b/scripts/errors/coll/Correct.py
@@ -31,7 +31,7 @@ class CorrectColl(ErrorGenerator):
             tm.set_description("Correct-" + func_to_use, "Correct code")
             yield tm
 
-        # Separate function called depending of process ID
+        # Separate function called depending on process ID
         for func_to_use in self.functions_to_use:
             tm = get_two_collective_template(func_to_use, func_to_use)
             tm.set_description("Correct-" + func_to_use + "-" + func_to_use, "Correct code")
diff --git a/scripts/errors/coll/ParamMatching.py b/scripts/errors/coll/ParamMatching.py
index 5a8c297e9..69880b110 100644
--- a/scripts/errors/coll/ParamMatching.py
+++ b/scripts/errors/coll/ParamMatching.py
@@ -6,6 +6,7 @@ from scripts.Infrastructure.MPICallFactory import MPICallFactory, CorrectMPICall
 from scripts.Infrastructure.CorrectParameter import CorrectParameterFactory, get_matching_recv
 from scripts.Infrastructure.Template import TemplateManager
 from scripts.Infrastructure.TemplateFactory import get_collective_template, get_two_collective_template
+from scripts.Infrastructure.Variables import BASIC_TEST_LEVEL
 
 
 class InvalidComErrorColl(ErrorGenerator):
@@ -92,5 +93,5 @@ class InvalidComErrorColl(ErrorGenerator):
 
             yield tm
 
-        if not generate_full_set:
+        if generate_level <= BASIC_TEST_LEVEL:
             return
diff --git a/scripts/errors/coll/ParamMatchingType.py b/scripts/errors/coll/ParamMatchingType.py
index a415a42bc..ca13a3acd 100644
--- a/scripts/errors/coll/ParamMatchingType.py
+++ b/scripts/errors/coll/ParamMatchingType.py
@@ -108,7 +108,9 @@ def get_correct_case(type_1, count_1, func_to_use, comm):
         comm_var_name = get_intercomm(comm, tm)
 
     if type_1 in predefined_types:
-        buf_name = get_buffer_for_type(type_1, count_1)
+        buf_alloc = get_buffer_for_type(type_1, count_1)
+        tm.insert_instruction(buf_alloc, before_instruction=tm._instructions[0])
+        buf_name = buf_alloc.get_name()
         type_var = type_1
     else:
         buf_name, type_var = get_buffer_for_usertype(type_1, tm, tm._instructions[0], count_1)
diff --git a/scripts/errors/dtypes/DtypeMissmatch.py b/scripts/errors/dtypes/DtypeMissmatch.py
index febd74583..422a4f358 100644
--- a/scripts/errors/dtypes/DtypeMissmatch.py
+++ b/scripts/errors/dtypes/DtypeMissmatch.py
@@ -55,7 +55,9 @@ def get_correct_case(type_1, size_1, send_func, recv_func, comm):
     call = tm.get_instruction(identifier="MPICALL", rank_excuting=1)
 
     if type_1 in predefined_types:
-        buf_name = get_buffer_for_type(type_1, size_1)
+        buf_alloc = get_buffer_for_type(type_1, size_1)
+        tm.insert_instruction(buf_alloc,before_instruction=tm._instructions[0])
+        buf_name = buf_alloc.get_name()
         type_var = type_1
     else:
         buf_name, type_var = get_buffer_for_usertype(type_1, tm, tm._instructions[0], size_1)
-- 
GitLab