Commit 49cb246c authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

append random suffix to eid-xor output filename

parent 0264ccd3
Loading
Loading
Loading
Loading
+16 −11
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ from typing import Optional, Union
import os
from tests import testconfig
import pytest
import tempfile

logger = logging.getLogger(__name__)
USE_LOGGER_FOR_DBG = False  # current tests do not make use of the logger feature
@@ -415,21 +416,25 @@ class DecoderFrontend:
                raise ValueError(f'Wrong system "{system}"!')
                
            if not os.path.isfile(eid_path):
                raise FileNotFoundError(f"eid-xor binary {eid_path} not found!\n!")
                raise FileNotFoundError(f"eid-xor binary {eid_path} not found!\n")
        
            eid_command = f"{eid_path} -fer -vbr -bs g192 -ep g192".split()
            eid_command += [str(input_bitstream_path), str(plc_file), str(input_bitstream_path + ".fer")]
            eid_command = [eid_path]
            eid_command.extend(["-fer", "-vbr", "-bs", "g192", "-ep", "g192"])
            eid_output_suffix = "." + next(tempfile._get_candidate_names()) + ".fer"
            eid_command += [
                str(input_bitstream_path),
                str(plc_file),
                str(input_bitstream_path) + eid_output_suffix
            ]
            
            try:
                result = run(eid_command, check=True, stderr=STDOUT)
            except CalledProcessError as e:
                result = run(eid_command, check=True)
            except Exception as e:
                print(result.stderr)
                print(result.stdout)
                pytest.fail(f"eid-xor operation failed!")

            input_bitstream_path += ".fer"
            
            # os.remove(input_bitstream_path)
            # os.rename(input_bitstream_path + ".fer", input_bitstream_path)
            input_bitstream_path += eid_output_suffix
                
        if add_option_list is not None:
            command.extend(add_option_list)