# MyHDL Test Suite under WIndows (10) - Cosimulation Fails

**URL:** https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49
**Category:** Support
**Created:** [May 31, 2016, 3:24pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49 "2016-05-31T15:24:35Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [May 31, 2016, 3:24pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/1 "2016-05-31T15:24:35Z")

</div>

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:

```nohighlight
============================= 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 ====================

```

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [May 31, 2016, 3:28pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/2 "2016-05-31T15:28:40Z")

</div>

First action is to remedy the _ImportError: No module named windll.kernel32_.  
In \_compat.py I changed:

```python
        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:

```python
        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 ☹

```nohighlight
============================= 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 …

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [May 31, 2016, 9:14pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/3 "2016-05-31T21:14:02Z")

</div>

Somewhere the _slashes_ in the path got lost:

```nohighlight
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_:

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

```

but now we get an OSerror:

```nohighlight
============================= 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

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [May 31, 2016, 9:53pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/4 "2016-05-31T21:53:41Z")

</div>

Finally got there.  
Found the mustard at [https://www.digitalenginesoftware.com/blog/archives/47-Passing-pipes-to-subprocesses-in-Python-in-Windows.html](https://www.digitalenginesoftware.com/blog/archives/47-Passing-pipes-to-subprocesses-in-Python-in-Windows.html)  
Changed _test\_CoSimulation.py_:  
Added this:

```python
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:

```python
    @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

```nohighlight
============================= 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.

---

<div class="post-metadata">

### Author: ![cfelton](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/cfelton/32/3_2.png) [@cfelton](https://discourse.myhdl.org/u/cfelton)
#### Post date: [June 1, 2016, 2:05pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/5 "2016-06-01T14:05:53Z")

</div>

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

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [June 1, 2016, 2:31pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/6 "2016-06-01T14:31:07Z")

</div>

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 …

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [June 1, 2016, 7:53pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/7 "2016-06-01T19:53:52Z")

</div>

Chris,

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

I still have some issues with _ghdl_, but _vlog_ and _vcom_ are doing fine.

Regards,

Josy

---

<div class="post-metadata">

### Author: ![jck](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/jck/32/107_2.png) [@jck](https://discourse.myhdl.org/u/jck)
#### Post date: [June 2, 2016, 7:07am UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/8 "2016-06-02T07:07:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [June 2, 2016, 7:57am UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/9 "2016-06-02T07:57:50Z")

</div>

Keerthan,

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

Regards,  
Josy

---

<div class="post-metadata">

### Author: ![Ravi\_Jain](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Ravi\_Jain](https://discourse.myhdl.org/u/Ravi_Jain)
#### Post date: [June 2, 2016, 8:30am UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/10 "2016-06-02T08:30:35Z")

</div>

No, it doesnt pass in Python 3.5.

 ![](https://canada1.discourse-cdn.com/flex030/uploads/myhdl/original/1X/0c651af8ef45d9a63246f22f2aa891182ffd47ec.png)

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [June 2, 2016, 10:50am UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/11 "2016-06-02T10:50:31Z")

</div>

Ravi,

I suppose you tested it on the _master_ branch, and not my _WinCoSim_ branch?

Regards,  
Josy

---

<div class="post-metadata">

### Author: ![Ravi\_Jain](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Ravi\_Jain](https://discourse.myhdl.org/u/Ravi_Jain)
#### Post date: [June 2, 2016, 2:10pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/12 "2016-06-02T14:10:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [June 2, 2016, 2:12pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/13 "2016-06-02T14:12:28Z")

</div>

Ravi,

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

Regards,  
Josy

---

<div class="post-metadata">

### Author: ![Ravi\_Jain](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Ravi\_Jain](https://discourse.myhdl.org/u/Ravi_Jain)
#### Post date: [June 2, 2016, 3:53pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/14 "2016-06-02T15:53:02Z")

</div>

A small syntax error prevents pytest from collecting Test\_Cosimulation.

 ![](https://canada1.discourse-cdn.com/flex030/uploads/myhdl/original/1X/4241bd99d2a411d160442f3cbc2cb8524b5185d8.png)

Please add the braces. 🙂

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [June 2, 2016, 3:58pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/15 "2016-06-02T15:58:29Z")

</div>

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_ 🙂

But apart from that it runs … ?

---

<div class="post-metadata">

### Author: ![Ravi\_Jain](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Ravi\_Jain](https://discourse.myhdl.org/u/Ravi_Jain)
#### Post date: [June 2, 2016, 5:12pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/16 "2016-06-02T17:12:46Z")

</div>

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 ====================
```

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [June 2, 2016, 5:26pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/17 "2016-06-02T17:26:38Z")

</div>

Ravi,

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

Regards,  
Josy

---

<div class="post-metadata">

### Author: ![cfelton](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/cfelton/32/3_2.png) [@cfelton](https://discourse.myhdl.org/u/cfelton)
#### Post date: [June 2, 2016, 6:20pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/18 "2016-06-02T18:20:49Z")

</div>

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

---

<div class="post-metadata">

### Author: ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)
#### Post date: [June 2, 2016, 6:27pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/19 "2016-06-02T18:27:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![cfelton](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/cfelton/32/3_2.png) [@cfelton](https://discourse.myhdl.org/u/cfelton)
#### Post date: [June 2, 2016, 6:34pm UTC](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49/20 "2016-06-02T18:34:51Z")

</div>

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

[Next page](https://discourse.myhdl.org/t/myhdl-test-suite-under-windows-10-cosimulation-fails/49.md?page=2)
