Commit 47e13ff1 authored by Jan Kiene's avatar Jan Kiene
Browse files

get paths to tools once at startup

parent cff44693
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ from itertools import product, permutations
from allpairspy import AllPairs
from typing import Optional
import random
import platform 
from pathlib import Path
import numpy as np
import os
@@ -40,6 +41,14 @@ HERE = Path(__file__).parent
TESTV_PATH = Path(os.environ.get("BE_TESTV_DIR", HERE.joinpath("testv")))
REF_PATH = Path(os.environ.get("BE_REF_DIR", HERE.joinpath("ref")))
DUT_PATH = HERE.joinpath("dut")
TOOLS_PATH_BASE = HERE.parent.parent.joinpath("scripts/tools")
TOOLS_PATH_FOR_OS = {
    "Windows": "Win32/{}.exe",
    "Linux": "Linux/{}",
    "Darwin": "Darwin/{}",
}
EID_XOR_PATH = TOOLS_PATH_BASE.joinpath(TOOLS_PATH_FOR_OS[platform.system()].format("eid-xor"))
NET_SIM_PATH = TOOLS_PATH_BASE.joinpath(TOOLS_PATH_FOR_OS[platform.system()].format("networkSimulator_g192"))


def collapse_into_list_of_pairs(params):
+4 −37
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ the United Nations Convention on Contracts on the International Sales of Goods.

import numpy as np
import pytest
import platform 
from contextlib import contextmanager
from typing import Union
from pathlib import Path
@@ -54,6 +53,8 @@ from ..constants import (
    EXOF_OPTIONS,
    RENDER_CONFIG_OPTIONS,
    DPID_OPTIONS,
    EID_XOR_PATH,
    NET_SIM_PATH,
)


@@ -141,25 +142,8 @@ def get_bitstream_and_options(
        bitstream_out = Path(tmp_dir).joinpath(bitstream.stem + f".{processing}.192")
        if processing == BS_PROC_FER_15:
            ep_path = TESTV_PATH.joinpath("ltv_ep_015.192")
            
            # get the pathname to the eid-xor tool respecting the running platform
            if platform.system() == "Windows":
                eid_xor_binary = [
                    HERE.joinpath(
                        "../../scripts/tools/Win32/eid-xor.exe"
                    )
                ]
            elif platform.system() in ["Linux", "Darwin"]:
                eid_xor_binary = [
                    HERE.joinpath(
                        "../../scripts/tools/Linux/eid-xor"
                    )
                ]
            else:
                assert False, f"eid-xor not available for {platform.system()}"
            
            cmd = [
                str(eid_xor_binary),
                str(EID_XOR_PATH),
                "-fer",
                "-vbr",
                str(bitstream),
@@ -173,26 +157,9 @@ def get_bitstream_and_options(
                "../../scripts/dly_error_profiles/dly_error_profile_5.dat"
            )
            tracefile_path = Path(tmp_dir).joinpath(bitstream_out.with_suffix(".trace"))
            
            # get the pathname to the networkSimulator_g192 tool respecting the running platform
            if platform.system() == "Windows":
                networkSimulator_g192_binary = [
                    HERE.joinpath(
                        "../../scripts/tools/Win32/networkSimulator_g192.exe"
                    )
                ]
            elif platform.system() in ["Linux", "Darwin"]:
                networkSimulator_g192_binary = [
                    HERE.joinpath(
                        "../../scripts/tools/Linux/networkSimulator_g192"
                    )
                ]
            else:
                assert False, f"networkSimulator_g192 not available for {platform.system()}"
            
            # TODO: get number of frames per packet from error profile name
            cmd = [
                str(networkSimulator_g192_binary),
                str(NET_SIM_PATH),
                str(dly_profile_path),
                str(bitstream),
                str(bitstream_out),