MyHDL Test Suite under WIndows (10) - Cosimulation Fails

I just revisited virtualenv and installed myhdl1.0-dev, added this as interpreter in Eclipse, and ran the core test-suite, here are the results:

============================= test session starts =============================
platform win32 -- Python 2.7.9, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: C:\Users\Josy\virtualenvs\london_app_dev\myhdl-master, inifile: 
collected 309 items

core\test_Cosimulation.py FFFFFFFFFFF
core\test_ShadowSignal.py .....
core\test_Signal.py ............................................................
core\test_Simulation.py ........................................................................
core\test_always.py ...........
core\test_always_comb.py .........................
core\test_always_seq.py ..
core\test_bin.py ......
core\test_concat.py .....................
core\test_enum.py .......
core\test_inferWaiter.py ..........
core\test_instance.py ...
core\test_intbv.py ..........................................................
core\test_misc.py .
core\test_modbv.py .......
core\test_signed.py ....
core\test_traceSignals.py ......

================================== FAILURES ===================================
________________________ TestCosimulation.testWrongExe ________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x0387AD78>

    def testWrongExe(self):
        with raises_kind(CosimulationError, _error.OSError):
>           Cosimulation('bla -x 45')
E           AttributeError: 'exceptions.ImportError' object has no attribute 'kind'

core\test_Cosimulation.py:66: AttributeError
_______________________ TestCosimulation.testNotUnique ________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x03960DF0>

    def testNotUnique(self):
>       cosim1 = Cosimulation(exe + "cosimNotUnique", **allSigs)

core\test_Cosimulation.py:69: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <myhdl._Cosimulation.Cosimulation object at 0x03786A10>
exe = 'python C:\\Users\\Josy\\virtualenvs\\london_app_dev\\myhdl-master\\myhdl\\test\\core\\test_Cosimulation.py cosimNotUnique'
kwargs = {'a': Signal(2), 'bb': Signal(67), 'ccc': Signal(36), 'd': Signal(0), ...}

    def __init__(self, exe="", **kwargs):
        """ Construct a cosimulation object. """
    
        if _simulator._cosim:
>           raise CosimulationError(_error.MultipleCosim)
E           CosimulationError: Only a single cosimulator allowed

..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_Cosimulation.py:54: CosimulationError
______________________ TestCosimulation.testFromSignals _______________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x038BF6C0>

    def testFromSignals(self):
>       cosim = Cosimulation(exe + "cosimFromSignals", **allSigs)

core\test_Cosimulation.py:85: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_Cosimulation.py:61: in __init__
    set_inheritable(rt, False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

fd = 13, inheritable = False

    def set_inheritable(fd, inheritable):
        # This implementation of set_inheritable is based on a code sample in
        # [PEP 0446](https://www.python.org/dev/peps/pep-0446/) and on the
        # CPython implementation of that proposal which can be browsed [here]
        # (hg.python.org/releasing/3.4/file/8671f89107c8/Modules/posixmodule.c#l11130)
        if sys.platform == "win32":
            import msvcrt
>           import ctypes.windll.kernel32 as kernel32
E           ImportError: No module named windll.kernel32

..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_compat.py:46: ImportError
_______________________ TestCosimulation.testToSignals ________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x038106C0>

    def testToSignals(self):
>       cosim = Cosimulation(exe + "cosimToSignals", **toSigs)

core\test_Cosimulation.py:104: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_Cosimulation.py:61: in __init__
    set_inheritable(rt, False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

fd = 17, inheritable = False

    def set_inheritable(fd, inheritable):
        # This implementation of set_inheritable is based on a code sample in
        # [PEP 0446](https://www.python.org/dev/peps/pep-0446/) and on the
        # CPython implementation of that proposal which can be browsed [here]
        # (hg.python.org/releasing/3.4/file/8671f89107c8/Modules/posixmodule.c#l11130)
        if sys.platform == "win32":
            import msvcrt
>           import ctypes.windll.kernel32 as kernel32
E           ImportError: No module named windll.kernel32

..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_compat.py:46: ImportError
_____________________ TestCosimulation.testFromToSignals ______________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x038D5670>

    def testFromToSignals(self):
>       cosim = Cosimulation(exe + "cosimFromToSignals", **allSigs)

core\test_Cosimulation.py:125: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_Cosimulation.py:61: in __init__
    set_inheritable(rt, False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

fd = 21, inheritable = False

    def set_inheritable(fd, inheritable):
        # This implementation of set_inheritable is based on a code sample in
        # [PEP 0446](https://www.python.org/dev/peps/pep-0446/) and on the
        # CPython implementation of that proposal which can be browsed [here]
        # (hg.python.org/releasing/3.4/file/8671f89107c8/Modules/posixmodule.c#l11130)
        if sys.platform == "win32":
            import msvcrt
>           import ctypes.windll.kernel32 as kernel32
E           ImportError: No module named windll.kernel32

..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_compat.py:46: ImportError
________________________ TestCosimulation.testTimeZero ________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x02CC7788>

    def testTimeZero(self):
        with raises_kind(CosimulationError, _error.TimeZero):
>           Cosimulation(exe + "cosimTimeZero", **allSigs)
E           AttributeError: 'exceptions.ImportError' object has no attribute 'kind'

core\test_Cosimulation.py:150: AttributeError
_________________________ TestCosimulation.testNoComm _________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x0387A4B8>

    def testNoComm(self):
        with raises_kind(CosimulationError, _error.NoCommunication):
>           Cosimulation(exe + "cosimNoComm", **allSigs)
E           AttributeError: 'exceptions.ImportError' object has no attribute 'kind'

core\test_Cosimulation.py:163: AttributeError
____________________ TestCosimulation.testFromSignalsDupl _____________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x037F68C8>

    def testFromSignalsDupl(self):
        with raises_kind(CosimulationError, _error.DuplicateSigNames):
>           Cosimulation(exe + "cosimFromSignalsDupl", **allSigs)
E           AttributeError: 'exceptions.ImportError' object has no attribute 'kind'

core\test_Cosimulation.py:178: AttributeError
_____________________ TestCosimulation.testToSignalsDupl ______________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x038D51E8>

    def testToSignalsDupl(self):
        with raises_kind(CosimulationError, _error.DuplicateSigNames):
>           Cosimulation(exe + "cosimToSignalsDupl", **allSigs)
E           AttributeError: 'exceptions.ImportError' object has no attribute 'kind'

core\test_Cosimulation.py:192: AttributeError
_____________________ TestCosimulation.testFromSignalVals _____________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x038D5D50>

    def testFromSignalVals(self):
>       cosim = Cosimulation(exe + "cosimFromSignalVals", **allSigs)

core\test_Cosimulation.py:205: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_Cosimulation.py:61: in __init__
    set_inheritable(rt, False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

fd = 41, inheritable = False

    def set_inheritable(fd, inheritable):
        # This implementation of set_inheritable is based on a code sample in
        # [PEP 0446](https://www.python.org/dev/peps/pep-0446/) and on the
        # CPython implementation of that proposal which can be browsed [here]
        # (hg.python.org/releasing/3.4/file/8671f89107c8/Modules/posixmodule.c#l11130)
        if sys.platform == "win32":
            import msvcrt
>           import ctypes.windll.kernel32 as kernel32
E           ImportError: No module named windll.kernel32

..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_compat.py:46: ImportError
______________________ TestCosimulation.testToSignalVals ______________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x038BFE68>

    def testToSignalVals(self):
>       cosim = Cosimulation(exe + "cosimToSignalVals", **allSigs)

core\test_Cosimulation.py:229: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_Cosimulation.py:61: in __init__
    set_inheritable(rt, False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

fd = 45, inheritable = False

    def set_inheritable(fd, inheritable):
        # This implementation of set_inheritable is based on a code sample in
        # [PEP 0446](https://www.python.org/dev/peps/pep-0446/) and on the
        # CPython implementation of that proposal which can be browsed [here]
        # (hg.python.org/releasing/3.4/file/8671f89107c8/Modules/posixmodule.c#l11130)
        if sys.platform == "win32":
            import msvcrt
>           import ctypes.windll.kernel32 as kernel32
E           ImportError: No module named windll.kernel32

..\..\..\lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\_compat.py:46: ImportError
=================== 11 failed, 298 passed in 27.47 seconds ====================

First action is to remedy the ImportError: No module named windll.kernel32.
In _compat.py I changed:

        if sys.platform == "win32":
            import msvcrt
            import ctypes.windll.kernel32 as kernel32

            HANDLE_FLAG_INHERIT = 1

            if kernel32.SetHandleInformation(msvcrt.get_osfhandle(fd),
                                             HANDLE_FLAG_INHERIT,
                                             1 if inheritable else 0) == 0:
                raise IOError("Failed on HANDLE_FLAG_INHERIT")

into:

        if sys.platform == "win32":
            import msvcrt
#             import ctypes.windll.kernel32 as kernel32
            import ctypes
            windll = ctypes.LibraryLoader(ctypes.WinDLL)
            SetHandleInformation = windll.kernel32.SetHandleInformation

            HANDLE_FLAG_INHERIT = 1

            if SetHandleInformation(msvcrt.get_osfhandle(fd),
                                             HANDLE_FLAG_INHERIT,
                                             1 if inheritable else 0) == 0:
                raise IOError("Failed on HANDLE_FLAG_INHERIT")

This lifts the first error only :frowning:

============================= test session starts =============================
platform win32 -- Python 2.7.9, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: C:\Users\Josy\virtualenvs\london_app_dev\Lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\test\core, inifile: 
collected 309 items

test\core\test_Cosimulation.py .FFFFFFFFFF
test\core\test_ShadowSignal.py .....
test\core\test_Signal.py ............................................................
test\core\test_Simulation.py ........................................................................
test\core\test_always.py ...........
test\core\test_always_comb.py .........................
test\core\test_always_seq.py ..
test\core\test_bin.py ......
test\core\test_concat.py .....................
test\core\test_enum.py .......
test\core\test_inferWaiter.py ..........
test\core\test_instance.py ...
test\core\test_intbv.py ..........................................................
test\core\test_misc.py .
test\core\test_modbv.py .......
test\core\test_signed.py ....
test\core\test_traceSignals.py ......

================================== FAILURES ===================================
_______________________ TestCosimulation.testNotUnique ________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x03506D28>

    def testNotUnique(self):
>       cosim1 = Cosimulation(exe + "cosimNotUnique", **allSigs)

test\core\test_Cosimulation.py:69: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <myhdl._Cosimulation.Cosimulation object at 0x038F5930>
exe = ['python', 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py', 'cosimNotUnique']
kwargs = {'a': Signal(2), 'bb': Signal(67), 'ccc': Signal(36), 'd': Signal(0), ...}
rt = 13, wt = 14, rf = 15, wf = 16, fromSignames = [], fromSizes = []
fromSigs = []

    def __init__(self, exe="", **kwargs):
        """ Construct a cosimulation object. """
    
        if _simulator._cosim:
            raise CosimulationError(_error.MultipleCosim)
        _simulator._cosim = 1
    
        rt, wt = os.pipe()
        rf, wf = os.pipe()
    
        # Disable inheritance for ends that we don't want the child to have
        set_inheritable(rt, False)
        set_inheritable(wf, False)
    
        # Enable inheritance for child ends
        set_inheritable(wt, True)
        set_inheritable(rf, True)
    
        self._rt = rt
        self._wf = wf
    
        self._fromSignames = fromSignames = []
        self._fromSizes = fromSizes = []
        self._fromSigs = fromSigs = []
        self._toSignames = toSignames = []
        self._toSizes = toSizes = []
        self._toSigs = toSigs = []
        self._toSigDict = toSigDict = {}
        self._hasChange = 0
        self._getMode = 1
    
        env = os.environ.copy()
    
        # In Windows the FDs aren't inheritable when using Popen,
        # only the HANDLEs are
        if sys.platform != "win32":
            env['MYHDL_TO_PIPE'] = str(wt)
            env['MYHDL_FROM_PIPE'] = str(rf)
        else:
            import msvcrt
            env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
            env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))
    
        if isinstance(exe, string_types):
            exe = shlex.split(exe)
    
        try:
            sp = subprocess.Popen(exe, env=env, close_fds=False)
        except OSError as e:
            raise CosimulationError(_error.OSError, str(e))
    
        self._child = sp
    
        os.close(wt)
        os.close(rf)
        while 1:
            s = to_str(os.read(rt, _MAXLINE))
            if not s:
>               raise CosimulationError(_error.SimulationEnd)
E               CosimulationError: Premature simulation end

_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory
______________________ TestCosimulation.testFromSignals _______________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x03A21710>

    def testFromSignals(self):
>       cosim = Cosimulation(exe + "cosimFromSignals", **allSigs)

test\core\test_Cosimulation.py:85: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <myhdl._Cosimulation.Cosimulation object at 0x03AB5590>
exe = 'python C:\\Users\\Josy\\virtualenvs\\london_app_dev\\Lib\\site-packages\\myhdl-1.0.dev0-py2.7.egg\\myhdl\\test\\core\\test_Cosimulation.py cosimFromSignals'
kwargs = {'a': Signal(2), 'bb': Signal(67), 'ccc': Signal(36), 'd': Signal(0), ...}

    def __init__(self, exe="", **kwargs):
        """ Construct a cosimulation object. """
    
        if _simulator._cosim:
>           raise CosimulationError(_error.MultipleCosim)
E           CosimulationError: Only a single cosimulator allowed

_Cosimulation.py:54: CosimulationError
_______________________ TestCosimulation.testToSignals ________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x039F2260>

    def testToSignals(self):
>       cosim = Cosimulation(exe + "cosimToSignals", **toSigs)

test\core\test_Cosimulation.py:104: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <myhdl._Cosimulation.Cosimulation object at 0x03AA9750>
exe = ['python', 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py', 'cosimToSignals']
kwargs = {'d': Signal(0), 'ee': Signal(0), 'fff': Signal(0), 'g': Signal(0)}
rt = 14, wt = 15, rf = 17, wf = 18, fromSignames = [], fromSizes = []
fromSigs = []

    def __init__(self, exe="", **kwargs):
        """ Construct a cosimulation object. """
    
        if _simulator._cosim:
            raise CosimulationError(_error.MultipleCosim)
        _simulator._cosim = 1
    
        rt, wt = os.pipe()
        rf, wf = os.pipe()
    
        # Disable inheritance for ends that we don't want the child to have
        set_inheritable(rt, False)
        set_inheritable(wf, False)
    
        # Enable inheritance for child ends
        set_inheritable(wt, True)
        set_inheritable(rf, True)
    
        self._rt = rt
        self._wf = wf
    
        self._fromSignames = fromSignames = []
        self._fromSizes = fromSizes = []
        self._fromSigs = fromSigs = []
        self._toSignames = toSignames = []
        self._toSizes = toSizes = []
        self._toSigs = toSigs = []
        self._toSigDict = toSigDict = {}
        self._hasChange = 0
        self._getMode = 1
    
        env = os.environ.copy()
    
        # In Windows the FDs aren't inheritable when using Popen,
        # only the HANDLEs are
        if sys.platform != "win32":
            env['MYHDL_TO_PIPE'] = str(wt)
            env['MYHDL_FROM_PIPE'] = str(rf)
        else:
            import msvcrt
            env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
            env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))
    
        if isinstance(exe, string_types):
            exe = shlex.split(exe)
    
        try:
            sp = subprocess.Popen(exe, env=env, close_fds=False)
        except OSError as e:
            raise CosimulationError(_error.OSError, str(e))
    
        self._child = sp
    
        os.close(wt)
        os.close(rf)
        while 1:
            s = to_str(os.read(rt, _MAXLINE))
            if not s:
>               raise CosimulationError(_error.SimulationEnd)
E               CosimulationError: Premature simulation end

_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory
_____________________ TestCosimulation.testFromToSignals ______________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x03AF5788>

    def testFromToSignals(self):
>       cosim = Cosimulation(exe + "cosimFromToSignals", **allSigs)

test\core\test_Cosimulation.py:125: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <myhdl._Cosimulation.Cosimulation object at 0x03931D30>
exe = ['python', 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py', 'cosimFromToSignals']
kwargs = {'a': Signal(2), 'bb': Signal(67), 'ccc': Signal(36), 'd': Signal(0), ...}
rt = 15, wt = 17, rf = 19, wf = 20, fromSignames = [], fromSizes = []
fromSigs = []

    def __init__(self, exe="", **kwargs):
        """ Construct a cosimulation object. """
    
        if _simulator._cosim:
            raise CosimulationError(_error.MultipleCosim)
        _simulator._cosim = 1
    
        rt, wt = os.pipe()
        rf, wf = os.pipe()
    
        # Disable inheritance for ends that we don't want the child to have
        set_inheritable(rt, False)
        set_inheritable(wf, False)
    
        # Enable inheritance for child ends
        set_inheritable(wt, True)
        set_inheritable(rf, True)
    
        self._rt = rt
        self._wf = wf
    
        self._fromSignames = fromSignames = []
        self._fromSizes = fromSizes = []
        self._fromSigs = fromSigs = []
        self._toSignames = toSignames = []
        self._toSizes = toSizes = []
        self._toSigs = toSigs = []
        self._toSigDict = toSigDict = {}
        self._hasChange = 0
        self._getMode = 1
    
        env = os.environ.copy()
    
        # In Windows the FDs aren't inheritable when using Popen,
        # only the HANDLEs are
        if sys.platform != "win32":
            env['MYHDL_TO_PIPE'] = str(wt)
            env['MYHDL_FROM_PIPE'] = str(rf)
        else:
            import msvcrt
            env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
            env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))
    
        if isinstance(exe, string_types):
            exe = shlex.split(exe)
    
        try:
            sp = subprocess.Popen(exe, env=env, close_fds=False)
        except OSError as e:
            raise CosimulationError(_error.OSError, str(e))
    
        self._child = sp
    
        os.close(wt)
        os.close(rf)
        while 1:
            s = to_str(os.read(rt, _MAXLINE))
            if not s:
>               raise CosimulationError(_error.SimulationEnd)
E               CosimulationError: Premature simulation end

_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory
________________________ TestCosimulation.testTimeZero ________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x03506238>

    def testTimeZero(self):
        with raises_kind(CosimulationError, _error.TimeZero):
>           Cosimulation(exe + "cosimTimeZero", **allSigs)
E           assert 'Premature simulation end' == 'myhdl vpi call when not at time 0'
E             - Premature simulation end
E             + myhdl vpi call when not at time 0

test\core\test_Cosimulation.py:150: AssertionError
---------------------------- Captured stderr call -----------------------------
python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory
_________________________ TestCosimulation.testNoComm _________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x035272D8>

    def testNoComm(self):
        with raises_kind(CosimulationError, _error.NoCommunication):
>           Cosimulation(exe + "cosimNoComm", **allSigs)
E           assert 'Premature simulation end' == 'No signals communicating to myhdl'
E             - Premature simulation end
E             + No signals communicating to myhdl

test\core\test_Cosimulation.py:163: AssertionError
---------------------------- Captured stderr call -----------------------------
python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory
____________________ TestCosimulation.testFromSignalsDupl _____________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x03A70788>

    def testFromSignalsDupl(self):
        with raises_kind(CosimulationError, _error.DuplicateSigNames):
>           Cosimulation(exe + "cosimFromSignalsDupl", **allSigs)
E           assert 'Premature simulation end' == 'Duplicate signa... myhdl vpi call'
E             - Premature simulation end
E             + Duplicate signal name in myhdl vpi call

test\core\test_Cosimulation.py:178: AssertionError
---------------------------- Captured stderr call -----------------------------
python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory
_____________________ TestCosimulation.testToSignalsDupl ______________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x0351B800>

    def testToSignalsDupl(self):
        with raises_kind(CosimulationError, _error.DuplicateSigNames):
>           Cosimulation(exe + "cosimToSignalsDupl", **allSigs)
E           assert 'Premature simulation end' == 'Duplicate signa... myhdl vpi call'
E             - Premature simulation end
E             + Duplicate signal name in myhdl vpi call

test\core\test_Cosimulation.py:192: AssertionError
---------------------------- Captured stderr call -----------------------------
python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory
_____________________ TestCosimulation.testFromSignalVals _____________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x03AFD558>

    def testFromSignalVals(self):
>       cosim = Cosimulation(exe + "cosimFromSignalVals", **allSigs)

test\core\test_Cosimulation.py:205: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <myhdl._Cosimulation.Cosimulation object at 0x038DE430>
exe = ['python', 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py', 'cosimFromSignalVals']
kwargs = {'a': Signal(2), 'bb': Signal(67), 'ccc': Signal(36), 'd': Signal(0), ...}
rt = 25, wt = 27, rf = 29, wf = 30, fromSignames = [], fromSizes = []
fromSigs = []

    def __init__(self, exe="", **kwargs):
        """ Construct a cosimulation object. """
    
        if _simulator._cosim:
            raise CosimulationError(_error.MultipleCosim)
        _simulator._cosim = 1
    
        rt, wt = os.pipe()
        rf, wf = os.pipe()
    
        # Disable inheritance for ends that we don't want the child to have
        set_inheritable(rt, False)
        set_inheritable(wf, False)
    
        # Enable inheritance for child ends
        set_inheritable(wt, True)
        set_inheritable(rf, True)
    
        self._rt = rt
        self._wf = wf
    
        self._fromSignames = fromSignames = []
        self._fromSizes = fromSizes = []
        self._fromSigs = fromSigs = []
        self._toSignames = toSignames = []
        self._toSizes = toSizes = []
        self._toSigs = toSigs = []
        self._toSigDict = toSigDict = {}
        self._hasChange = 0
        self._getMode = 1
    
        env = os.environ.copy()
    
        # In Windows the FDs aren't inheritable when using Popen,
        # only the HANDLEs are
        if sys.platform != "win32":
            env['MYHDL_TO_PIPE'] = str(wt)
            env['MYHDL_FROM_PIPE'] = str(rf)
        else:
            import msvcrt
            env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
            env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))
    
        if isinstance(exe, string_types):
            exe = shlex.split(exe)
    
        try:
            sp = subprocess.Popen(exe, env=env, close_fds=False)
        except OSError as e:
            raise CosimulationError(_error.OSError, str(e))
    
        self._child = sp
    
        os.close(wt)
        os.close(rf)
        while 1:
            s = to_str(os.read(rt, _MAXLINE))
            if not s:
>               raise CosimulationError(_error.SimulationEnd)
E               CosimulationError: Premature simulation end

_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory
______________________ TestCosimulation.testToSignalVals ______________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x03AC0F08>

    def testToSignalVals(self):
>       cosim = Cosimulation(exe + "cosimToSignalVals", **allSigs)

test\core\test_Cosimulation.py:229: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <myhdl._Cosimulation.Cosimulation object at 0x0380A6F0>
exe = ['python', 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py', 'cosimToSignalVals']
kwargs = {'a': Signal(2), 'bb': Signal(67), 'ccc': Signal(36), 'd': Signal(0), ...}
rt = 27, wt = 29, rf = 31, wf = 32, fromSignames = [], fromSizes = []
fromSigs = []

    def __init__(self, exe="", **kwargs):
        """ Construct a cosimulation object. """
    
        if _simulator._cosim:
            raise CosimulationError(_error.MultipleCosim)
        _simulator._cosim = 1
    
        rt, wt = os.pipe()
        rf, wf = os.pipe()
    
        # Disable inheritance for ends that we don't want the child to have
        set_inheritable(rt, False)
        set_inheritable(wf, False)
    
        # Enable inheritance for child ends
        set_inheritable(wt, True)
        set_inheritable(rf, True)
    
        self._rt = rt
        self._wf = wf
    
        self._fromSignames = fromSignames = []
        self._fromSizes = fromSizes = []
        self._fromSigs = fromSigs = []
        self._toSignames = toSignames = []
        self._toSizes = toSizes = []
        self._toSigs = toSigs = []
        self._toSigDict = toSigDict = {}
        self._hasChange = 0
        self._getMode = 1
    
        env = os.environ.copy()
    
        # In Windows the FDs aren't inheritable when using Popen,
        # only the HANDLEs are
        if sys.platform != "win32":
            env['MYHDL_TO_PIPE'] = str(wt)
            env['MYHDL_FROM_PIPE'] = str(rf)
        else:
            import msvcrt
            env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
            env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))
    
        if isinstance(exe, string_types):
            exe = shlex.split(exe)
    
        try:
            sp = subprocess.Popen(exe, env=env, close_fds=False)
        except OSError as e:
            raise CosimulationError(_error.OSError, str(e))
    
        self._child = sp
    
        os.close(wt)
        os.close(rf)
        while 1:
            s = to_str(os.read(rt, _MAXLINE))
            if not s:
>               raise CosimulationError(_error.SimulationEnd)
E               CosimulationError: Premature simulation end

_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory
=================== 10 failed, 299 passed in 28.35 seconds ====================

So there is more to it …

Somewhere the slashes in the path got lost:

python: can't open file 'C:UsersJosyvirtualenvslondon_app_devLibsite-packagesmyhdl-1.0.dev0-py2.7.eggmyhdltestcoretest_Cosimulation.py': [Errno 2] No such file or directory

I made the following change in _coSimulation.py:

#             exe = shlex.split(exe)
            exe = exe.split(' ')

but now we get an OSerror:

============================= test session starts =============================
platform win32 -- Python 2.7.9, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: C:\Users\Josy\virtualenvs\london_app_dev\Lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\test\core, inifile: 
collected 11 items

test\core\test_Cosimulation.py .FFFFFFFFFF

================================== FAILURES ===================================
_______________________ TestCosimulation.testNotUnique ________________________

self = <core.test_Cosimulation.TestCosimulation instance at 0x03781A08>

    def testNotUnique(self):
        print( exe )
>       cosim1 = Cosimulation(exe + "cosimNotUnique", **allSigs)

test\core\test_Cosimulation.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <myhdl._Cosimulation.Cosimulation object at 0x0378B370>
exe = ['python', 'C:\\Users\\Josy\\virtualenvs\\london_app_dev\\Lib\\site-packages\\myhdl-1.0.dev0-py2.7.egg\\myhdl\\test\\core\\test_Cosimulation.py', 'cosimNotUnique']
kwargs = {'a': Signal(2), 'bb': Signal(67), 'ccc': Signal(36), 'd': Signal(0), ...}
rt = 13, wt = 14, rf = 15, wf = 16, fromSignames = [], fromSizes = []
fromSigs = []

    def __init__(self, exe="", **kwargs):
        """ Construct a cosimulation object. """
    
        if _simulator._cosim:
            raise CosimulationError(_error.MultipleCosim)
        _simulator._cosim = 1
    
        rt, wt = os.pipe()
        rf, wf = os.pipe()
    
        # Disable inheritance for ends that we don't want the child to have
        set_inheritable(rt, False)
        set_inheritable(wf, False)
    
        # Enable inheritance for child ends
        set_inheritable(wt, True)
        set_inheritable(rf, True)
    
        self._rt = rt
        self._wf = wf
    
        self._fromSignames = fromSignames = []
        self._fromSizes = fromSizes = []
        self._fromSigs = fromSigs = []
        self._toSignames = toSignames = []
        self._toSizes = toSizes = []
        self._toSigs = toSigs = []
        self._toSigDict = toSigDict = {}
        self._hasChange = 0
        self._getMode = 1
    
        env = os.environ.copy()
    
        # In Windows the FDs aren't inheritable when using Popen,
        # only the HANDLEs are
        if sys.platform != "win32":
            env['MYHDL_TO_PIPE'] = str(wt)
            env['MYHDL_FROM_PIPE'] = str(rf)
        else:
            import msvcrt
            env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
            env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))
    
        if isinstance(exe, string_types):
    #             print( exe )
    #             print( exe.split(' ') )
    #             exe = shlex.split(exe)
            exe = exe.split(' ')
            print( exe )
    
        try:
            sp = subprocess.Popen(exe, env=env, close_fds=False)
        except OSError as e:
            raise CosimulationError(_error.OSError, str(e))
    
        self._child = sp
    
        os.close(wt)
    #         os.close(rf)
        while 1:
            s = to_str(os.read(rt, _MAXLINE))
            if not s:
>               raise CosimulationError(_error.SimulationEnd)
E               CosimulationError: Premature simulation end

_Cosimulation.py:112: CosimulationError
---------------------------- Captured stdout call -----------------------------
python C:\Users\Josy\virtualenvs\london_app_dev\Lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\test\core\test_Cosimulation.py 
['python', 'C:\\Users\\Josy\\virtualenvs\\london_app_dev\\Lib\\site-packages\\myhdl-1.0.dev0-py2.7.egg\\myhdl\\test\\core\\test_Cosimulation.py', 'cosimNotUnique']
wt 896
---------------------------- Captured stderr call -----------------------------
Traceback (most recent call last):
  File "C:\Users\Josy\virtualenvs\london_app_dev\Lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\test\core\test_Cosimulation.py", line 277, in <module>
    getattr(TestCosimulation, sys.argv[1])()
  File "C:\Users\Josy\virtualenvs\london_app_dev\Lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\test\core\test_Cosimulation.py", line 80, in cosimNotUnique
    os.write(wt, b"TO 00 a 1")
OSError: [Errno 9] Bad file descriptor

Looks like the file descriptors don’t match: wt: 14 <> 896

Finally got there.
Found the mustard at https://www.digitalenginesoftware.com/blog/archives/47-Passing-pipes-to-subprocesses-in-Python-in-Windows.html
Changed test_CoSimulation.py:
Added this:

import msvcrt

def wtrf():
    if sys.platform != "win32":
        wt = int(os.environ['MYHDL_TO_PIPE'])
        rf = int(os.environ['MYHDL_FROM_PIPE'])
    else:
        wt = msvcrt.open_osfhandle(int(os.environ['MYHDL_TO_PIPE']), os.O_APPEND | os.O_TEXT)
        rf = msvcrt.open_osfhandle(int(os.environ['MYHDL_FROM_PIPE']), os.O_RDONLY | os.O_TEXT)
   
    return wt, rf

and changed the tests:

    @staticmethod
    def cosimNotUnique():
#         wt = int(os.environ['MYHDL_TO_PIPE'])
#         rf = int(os.environ['MYHDL_FROM_PIPE'])
        wt, rf = wtrf()
        os.write(wt, b"TO 00 a 1")
        os.read(rf, MAXLINE)
        os.write(wt, b"FROM 00 d 1")
        os.read(rf, MAXLINE)
        os.write(wt, b"START")
        os.read(rf, MAXLINE)

giving a clean bill of health

============================= test session starts =============================
platform win32 -- Python 2.7.9, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: C:\Users\Josy\virtualenvs\london_app_dev\Lib\site-packages\myhdl-1.0.dev0-py2.7.egg\myhdl\test\core, inifile: 
collected 11 items

test\core\test_Cosimulation.py ...........

========================== 11 passed in 3.46 seconds ==========================

I’ll add a PR later.

@josyb good job! Do you have this in a clean branch that I could pull from and test?

I have it in my virtualenv which other than the above changes is pristine.
I’ll make a PR soon (it was too late last night) and now I have to make some (almost overdue) reports for a major project. Perhaps later tonight.
There is also some tidying up to do …

Chris,

you can find the ‘WinCoSIm’ branch on https://github.com/josyb/myhdl

I still have some issues with ghdl, but vlog and vcom are doing fine.

Regards,

Josy

Could one of you windows users check if the tests pass in Python 3.5?

Keerthan,

I will later this evening. I was going to install Python 3.5 anyway to check Ravi’s async issue.

Regards,
Josy

No, it doesnt pass in Python 3.5.

Ravi,

I suppose you tested it on the master branch, and not my WinCoSim branch?

Regards,
Josy

Yes, I used master branch. Should I test on your WinCoSim branch?

Ravi,

Yes, the master branch had the errors, otherwise I wouldn’t have tried to fix it …

Regards,
Josy

A small syntax error prevents pytest from collecting Test_Cosimulation.

Please add the braces. :slight_smile:

I thought had removed that print function from the code in the branch.
I just read that it would be a good thing to add
from __future__ import absolute_import, division, print_function, unicode_literals .
I always add the from __future__ import print_function but was to lazy here, as it was temporary code :slight_smile:

But apart from that it runs … ?

Nope the tests still fail after i add the braces.


============================= test session starts =============================
platform win32 – Python 3.5.1, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: D:\git\myhdl-WinCoSim\myhdl-WinCoSim, inifile:
collected 309 items

test_Cosimulation.py .FFFFFFFFFF
test_ShadowSignal.py …
test_Signal.py …
test_Simulation.py …
test_always.py …
test_always_comb.py …
test_always_seq.py …
test_bin.py …
test_concat.py …
test_enum.py …
test_inferWaiter.py …
test_instance.py …
test_intbv.py …
test_misc.py .
test_modbv.py …
test_signed.py …
test_traceSignals.py …

================================== FAILURES ===================================
_______________________ TestCosimulation.testNotUnique ________________________

self = <core.test_Cosimulation.TestCosimulation object at 0x02F9B590>

def testNotUnique(self):
  cosim1 = Cosimulation(exe + "cosimNotUnique", **allSigs)

test_Cosimulation.py:85:


self = <myhdl._Cosimulation.Cosimulation object at 0x031A4D10>
exe = [‘python’, ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’, ‘cosimNotUnique’]
kwargs = {‘a’: Signal(2), ‘bb’: Signal(67), ‘ccc’: Signal(36), ‘d’: Signal(0), …}
rt = 13, wt = 14, rf = 15, wf = 16, fromSignames = [], fromSizes = []
fromSigs = []

def __init__(self, exe="", **kwargs):
    """ Construct a cosimulation object. """

    if _simulator._cosim:
        raise CosimulationError(_error.MultipleCosim)
    _simulator._cosim = 1

    rt, wt = os.pipe()
    rf, wf = os.pipe()

    # Disable inheritance for ends that we don't want the child to have
    set_inheritable(rt, False)
    set_inheritable(wf, False)

    # Enable inheritance for child ends
    set_inheritable(wt, True)
    set_inheritable(rf, True)

    self._rt = rt
    self._wf = wf

    self._fromSignames = fromSignames = []
    self._fromSizes = fromSizes = []
    self._fromSigs = fromSigs = []
    self._toSignames = toSignames = []
    self._toSizes = toSizes = []
    self._toSigs = toSigs = []
    self._toSigDict = toSigDict = {}
    self._hasChange = 0
    self._getMode = 1

    env = os.environ.copy()

    # In Windows the FDs aren't inheritable when using Popen,
    # only the HANDLEs are
    if sys.platform != "win32":
        env['MYHDL_TO_PIPE'] = str(wt)
        env['MYHDL_FROM_PIPE'] = str(rf)
    else:
        import msvcrt
        env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
        env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))

    if isinstance(exe, string_types):
        exe = shlex.split(exe)

    try:
        sp = subprocess.Popen(exe, env=env, close_fds=False)
    except OSError as e:
        raise CosimulationError(_error.OSError, str(e))

    self._child = sp

    os.close(wt)
    os.close(rf)
    while 1:
        s = to_str(os.read(rt, _MAXLINE))
        if not s:
          raise CosimulationError(_error.SimulationEnd)

E myhdl.CosimulationError: Premature simulation end

C:\Program Files (x86)\Python35-32\lib\site-packages\myhdl-1.0.dev0-py3.5.egg\myhdl_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can’t open file ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’: [Errno 2] No such file or directory
______________________ TestCosimulation.testFromSignals _______________________

self = <core.test_Cosimulation.TestCosimulation object at 0x031A9650>

def testFromSignals(self):
  cosim = Cosimulation(exe + "cosimFromSignals", **allSigs)

test_Cosimulation.py:101:


self = <myhdl._Cosimulation.Cosimulation object at 0x031A9870>
exe = 'python D:\git\myhdl-WinCoSim\myhdl-WinCoSim\myhdl\test\core\test_Cosimulation.py cosimFromSignals’
kwargs = {‘a’: Signal(2), ‘bb’: Signal(67), ‘ccc’: Signal(36), ‘d’: Signal(0), …}

def __init__(self, exe="", **kwargs):
    """ Construct a cosimulation object. """

    if _simulator._cosim:
      raise CosimulationError(_error.MultipleCosim)

E myhdl.CosimulationError: Only a single cosimulator allowed

C:\Program Files (x86)\Python35-32\lib\site-packages\myhdl-1.0.dev0-py3.5.egg\myhdl_Cosimulation.py:54: CosimulationError
_______________________ TestCosimulation.testToSignals ________________________

self = <core.test_Cosimulation.TestCosimulation object at 0x031F3310>

def testToSignals(self):
  cosim = Cosimulation(exe + "cosimToSignals", **toSigs)

test_Cosimulation.py:119:


self = <myhdl._Cosimulation.Cosimulation object at 0x0319DDF0>
exe = [‘python’, ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’, ‘cosimToSignals’]
kwargs = {‘d’: Signal(0), ‘ee’: Signal(0), ‘fff’: Signal(0), ‘g’: Signal(0)}
rt = 14, wt = 15, rf = 17, wf = 18, fromSignames = [], fromSizes = []
fromSigs = []

def __init__(self, exe="", **kwargs):
    """ Construct a cosimulation object. """

    if _simulator._cosim:
        raise CosimulationError(_error.MultipleCosim)
    _simulator._cosim = 1

    rt, wt = os.pipe()
    rf, wf = os.pipe()

    # Disable inheritance for ends that we don't want the child to have
    set_inheritable(rt, False)
    set_inheritable(wf, False)

    # Enable inheritance for child ends
    set_inheritable(wt, True)
    set_inheritable(rf, True)

    self._rt = rt
    self._wf = wf

    self._fromSignames = fromSignames = []
    self._fromSizes = fromSizes = []
    self._fromSigs = fromSigs = []
    self._toSignames = toSignames = []
    self._toSizes = toSizes = []
    self._toSigs = toSigs = []
    self._toSigDict = toSigDict = {}
    self._hasChange = 0
    self._getMode = 1

    env = os.environ.copy()

    # In Windows the FDs aren't inheritable when using Popen,
    # only the HANDLEs are
    if sys.platform != "win32":
        env['MYHDL_TO_PIPE'] = str(wt)
        env['MYHDL_FROM_PIPE'] = str(rf)
    else:
        import msvcrt
        env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
        env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))

    if isinstance(exe, string_types):
        exe = shlex.split(exe)

    try:
        sp = subprocess.Popen(exe, env=env, close_fds=False)
    except OSError as e:
        raise CosimulationError(_error.OSError, str(e))

    self._child = sp

    os.close(wt)
    os.close(rf)
    while 1:
        s = to_str(os.read(rt, _MAXLINE))
        if not s:
          raise CosimulationError(_error.SimulationEnd)

E myhdl.CosimulationError: Premature simulation end

C:\Program Files (x86)\Python35-32\lib\site-packages\myhdl-1.0.dev0-py3.5.egg\myhdl_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can’t open file ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’: [Errno 2] No such file or directory
_____________________ TestCosimulation.testFromToSignals ______________________

self = <core.test_Cosimulation.TestCosimulation object at 0x031E3850>

def testFromToSignals(self):
  cosim = Cosimulation(exe + "cosimFromToSignals", **allSigs)

test_Cosimulation.py:139:


self = <myhdl._Cosimulation.Cosimulation object at 0x031E3310>
exe = [‘python’, ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’, ‘cosimFromToSignals’]
kwargs = {‘a’: Signal(2), ‘bb’: Signal(67), ‘ccc’: Signal(36), ‘d’: Signal(0), …}
rt = 15, wt = 17, rf = 19, wf = 20, fromSignames = [], fromSizes = []
fromSigs = []

def __init__(self, exe="", **kwargs):
    """ Construct a cosimulation object. """

    if _simulator._cosim:
        raise CosimulationError(_error.MultipleCosim)
    _simulator._cosim = 1

    rt, wt = os.pipe()
    rf, wf = os.pipe()

    # Disable inheritance for ends that we don't want the child to have
    set_inheritable(rt, False)
    set_inheritable(wf, False)

    # Enable inheritance for child ends
    set_inheritable(wt, True)
    set_inheritable(rf, True)

    self._rt = rt
    self._wf = wf

    self._fromSignames = fromSignames = []
    self._fromSizes = fromSizes = []
    self._fromSigs = fromSigs = []
    self._toSignames = toSignames = []
    self._toSizes = toSizes = []
    self._toSigs = toSigs = []
    self._toSigDict = toSigDict = {}
    self._hasChange = 0
    self._getMode = 1

    env = os.environ.copy()

    # In Windows the FDs aren't inheritable when using Popen,
    # only the HANDLEs are
    if sys.platform != "win32":
        env['MYHDL_TO_PIPE'] = str(wt)
        env['MYHDL_FROM_PIPE'] = str(rf)
    else:
        import msvcrt
        env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
        env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))

    if isinstance(exe, string_types):
        exe = shlex.split(exe)

    try:
        sp = subprocess.Popen(exe, env=env, close_fds=False)
    except OSError as e:
        raise CosimulationError(_error.OSError, str(e))

    self._child = sp

    os.close(wt)
    os.close(rf)
    while 1:
        s = to_str(os.read(rt, _MAXLINE))
        if not s:
          raise CosimulationError(_error.SimulationEnd)

E myhdl.CosimulationError: Premature simulation end

C:\Program Files (x86)\Python35-32\lib\site-packages\myhdl-1.0.dev0-py3.5.egg\myhdl_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can’t open file ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’: [Errno 2] No such file or directory
________________________ TestCosimulation.testTimeZero ________________________

self = <core.test_Cosimulation.TestCosimulation object at 0x031A97F0>

def testTimeZero(self):
    with raises_kind(CosimulationError, _error.TimeZero):
      Cosimulation(exe + "cosimTimeZero", **allSigs)

E assert ‘Premature simulation end’ == 'myhdl vpi call when not at time 0’
E - Premature simulation end
E + myhdl vpi call when not at time 0

test_Cosimulation.py:163: AssertionError
---------------------------- Captured stderr call -----------------------------
python: can’t open file ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’: [Errno 2] No such file or directory
_________________________ TestCosimulation.testNoComm _________________________

self = <core.test_Cosimulation.TestCosimulation object at 0x0320C1B0>

def testNoComm(self):
    with raises_kind(CosimulationError, _error.NoCommunication):
      Cosimulation(exe + "cosimNoComm", **allSigs)

E assert ‘Premature simulation end’ == 'No signals communicating to myhdl’
E - Premature simulation end
E + No signals communicating to myhdl

test_Cosimulation.py:175: AssertionError
---------------------------- Captured stderr call -----------------------------
python: can’t open file ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’: [Errno 2] No such file or directory
____________________ TestCosimulation.testFromSignalsDupl _____________________

self = <core.test_Cosimulation.TestCosimulation object at 0x031F3AD0>

def testFromSignalsDupl(self):
    with raises_kind(CosimulationError, _error.DuplicateSigNames):
      Cosimulation(exe + "cosimFromSignalsDupl", **allSigs)

E assert ‘Premature simulation end’ == 'Duplicate signa… myhdl vpi call’
E - Premature simulation end
E + Duplicate signal name in myhdl vpi call

test_Cosimulation.py:189: AssertionError
---------------------------- Captured stderr call -----------------------------
python: can’t open file ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’: [Errno 2] No such file or directory
_____________________ TestCosimulation.testToSignalsDupl ______________________

self = <core.test_Cosimulation.TestCosimulation object at 0x031DF0D0>

def testToSignalsDupl(self):
    with raises_kind(CosimulationError, _error.DuplicateSigNames):
      Cosimulation(exe + "cosimToSignalsDupl", **allSigs)

E assert ‘Premature simulation end’ == 'Duplicate signa… myhdl vpi call’
E - Premature simulation end
E + Duplicate signal name in myhdl vpi call

test_Cosimulation.py:202: AssertionError
---------------------------- Captured stderr call -----------------------------
python: can’t open file ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’: [Errno 2] No such file or directory
_____________________ TestCosimulation.testFromSignalVals _____________________

self = <core.test_Cosimulation.TestCosimulation object at 0x0322F250>

def testFromSignalVals(self):
  cosim = Cosimulation(exe + "cosimFromSignalVals", **allSigs)

test_Cosimulation.py:214:


self = <myhdl._Cosimulation.Cosimulation object at 0x031A9EB0>
exe = [‘python’, ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’, ‘cosimFromSignalVals’]
kwargs = {‘a’: Signal(2), ‘bb’: Signal(67), ‘ccc’: Signal(36), ‘d’: Signal(0), …}
rt = 25, wt = 27, rf = 29, wf = 30, fromSignames = [], fromSizes = []
fromSigs = []

def __init__(self, exe="", **kwargs):
    """ Construct a cosimulation object. """

    if _simulator._cosim:
        raise CosimulationError(_error.MultipleCosim)
    _simulator._cosim = 1

    rt, wt = os.pipe()
    rf, wf = os.pipe()

    # Disable inheritance for ends that we don't want the child to have
    set_inheritable(rt, False)
    set_inheritable(wf, False)

    # Enable inheritance for child ends
    set_inheritable(wt, True)
    set_inheritable(rf, True)

    self._rt = rt
    self._wf = wf

    self._fromSignames = fromSignames = []
    self._fromSizes = fromSizes = []
    self._fromSigs = fromSigs = []
    self._toSignames = toSignames = []
    self._toSizes = toSizes = []
    self._toSigs = toSigs = []
    self._toSigDict = toSigDict = {}
    self._hasChange = 0
    self._getMode = 1

    env = os.environ.copy()

    # In Windows the FDs aren't inheritable when using Popen,
    # only the HANDLEs are
    if sys.platform != "win32":
        env['MYHDL_TO_PIPE'] = str(wt)
        env['MYHDL_FROM_PIPE'] = str(rf)
    else:
        import msvcrt
        env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
        env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))

    if isinstance(exe, string_types):
        exe = shlex.split(exe)

    try:
        sp = subprocess.Popen(exe, env=env, close_fds=False)
    except OSError as e:
        raise CosimulationError(_error.OSError, str(e))

    self._child = sp

    os.close(wt)
    os.close(rf)
    while 1:
        s = to_str(os.read(rt, _MAXLINE))
        if not s:
          raise CosimulationError(_error.SimulationEnd)

E myhdl.CosimulationError: Premature simulation end

C:\Program Files (x86)\Python35-32\lib\site-packages\myhdl-1.0.dev0-py3.5.egg\myhdl_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can’t open file ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’: [Errno 2] No such file or directory
______________________ TestCosimulation.testToSignalVals ______________________

self = <core.test_Cosimulation.TestCosimulation object at 0x031DB330>

def testToSignalVals(self):
  cosim = Cosimulation(exe + "cosimToSignalVals", **allSigs)

test_Cosimulation.py:237:


self = <myhdl._Cosimulation.Cosimulation object at 0x031DB070>
exe = [‘python’, ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’, ‘cosimToSignalVals’]
kwargs = {‘a’: Signal(2), ‘bb’: Signal(67), ‘ccc’: Signal(36), ‘d’: Signal(0), …}
rt = 27, wt = 29, rf = 31, wf = 32, fromSignames = [], fromSizes = []
fromSigs = []

def __init__(self, exe="", **kwargs):
    """ Construct a cosimulation object. """

    if _simulator._cosim:
        raise CosimulationError(_error.MultipleCosim)
    _simulator._cosim = 1

    rt, wt = os.pipe()
    rf, wf = os.pipe()

    # Disable inheritance for ends that we don't want the child to have
    set_inheritable(rt, False)
    set_inheritable(wf, False)

    # Enable inheritance for child ends
    set_inheritable(wt, True)
    set_inheritable(rf, True)

    self._rt = rt
    self._wf = wf

    self._fromSignames = fromSignames = []
    self._fromSizes = fromSizes = []
    self._fromSigs = fromSigs = []
    self._toSignames = toSignames = []
    self._toSizes = toSizes = []
    self._toSigs = toSigs = []
    self._toSigDict = toSigDict = {}
    self._hasChange = 0
    self._getMode = 1

    env = os.environ.copy()

    # In Windows the FDs aren't inheritable when using Popen,
    # only the HANDLEs are
    if sys.platform != "win32":
        env['MYHDL_TO_PIPE'] = str(wt)
        env['MYHDL_FROM_PIPE'] = str(rf)
    else:
        import msvcrt
        env['MYHDL_TO_PIPE'] = str(msvcrt.get_osfhandle(wt))
        env['MYHDL_FROM_PIPE'] = str(msvcrt.get_osfhandle(rf))

    if isinstance(exe, string_types):
        exe = shlex.split(exe)

    try:
        sp = subprocess.Popen(exe, env=env, close_fds=False)
    except OSError as e:
        raise CosimulationError(_error.OSError, str(e))

    self._child = sp

    os.close(wt)
    os.close(rf)
    while 1:
        s = to_str(os.read(rt, _MAXLINE))
        if not s:
          raise CosimulationError(_error.SimulationEnd)

E myhdl.CosimulationError: Premature simulation end

C:\Program Files (x86)\Python35-32\lib\site-packages\myhdl-1.0.dev0-py3.5.egg\myhdl_Cosimulation.py:108: CosimulationError
---------------------------- Captured stderr call -----------------------------
python: can’t open file ‘D:gitmyhdl-WinCoSimmyhdl-WinCoSimmyhdltestcoretest_Cosimulation.py’: [Errno 2] No such file or directory
=================== 10 failed, 299 passed in 26.76 seconds ====================

Ravi,

don’t loose any more time on this, your GSoC work is of higher importance. I’ll check it further myself.

Regards,
Josy

I tried your changes on a windows system I have access. The test/core passed with 3.5.

Good! So I can make a PR from it (after tidying up)?

1 Like

I don’t see a reason not to create a PR (I couldn’t simply say yes, too short - discourse the anit-twitter :).