Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncio issues with cocotb-test under python 3.7 #216

Closed
alexforencich opened this issue Jan 18, 2023 · 1 comment · Fixed by #218
Closed

asyncio issues with cocotb-test under python 3.7 #216

alexforencich opened this issue Jan 18, 2023 · 1 comment · Fixed by #218

Comments

@alexforencich
Copy link
Contributor

alexforencich commented Jan 18, 2023

I'm running in to some very strange issues on github actions that seem to be related to cocotb-test, but I'm rather at a loss as to exactly what is going on. Tests are failing on python 3.7.15 with the following trace, with the tests completing without error on other python versions (3.8, 3.9, 3.10):

tox: py37
  py37: commands[0]> pytest --cov=cocotbext --cov=tests --cov-branch -n auto
  ============================= test session starts ==============================
  platform linux -- Python 3.7.15, pytest-7.2.1, pluggy-1.0.0
  cachedir: .tox/py37/.pytest_cache
  rootdir: /home/runner/work/cocotbext-axi/cocotbext-axi, configfile: setup.cfg, testpaths: tests
  plugins: xdist-3.1.0, cocotb-test-0.2.3, cov-4.0.0
  gw0 I / gw1 I
  gw0 [10] / gw1 [10]
  
  sys:1: RuntimeWarning: coroutine 'Simulator._exec' was never awaited
  RuntimeWarning: Enable tracemalloc to get the object allocation traceback
  ..F.F.F...                                                               [100%]
  =================================== FAILURES ===================================
  _________________________________ test_axil[8] _________________________________
  [gw0] linux -- Python 3.7.15 /home/runner/work/cocotbext-axi/cocotbext-axi/.tox/py37/bin/python
  
  request = <FixtureRequest for <Function test_axil[8]>>, data_width = 8
  
      @pytest.mark.parametrize("data_width", [8, 16, 32])
      def test_axil(request, data_width):
          dut = "test_axil"
          module = os.path.splitext(os.path.basename(__file__))[0]
          toplevel = dut
      
          verilog_sources = [
              os.path.join(os.path.dirname(__file__), f"{dut}.v"),
          ]
      
          parameters = {}
      
          parameters['DATA_WIDTH'] = data_width
          parameters['ADDR_WIDTH'] = 32
          parameters['STRB_WIDTH'] = parameters['DATA_WIDTH'] // 8
      
          extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()}
      
          sim_build = os.path.join(tests_dir, "sim_build",
              request.node.name.replace('[', '-').replace(']', ''))
      
          cocotb_test.simulator.run(
              python_search=[tests_dir],
              verilog_sources=verilog_sources,
              toplevel=toplevel,
              module=module,
              parameters=parameters,
              sim_build=sim_build,
  >           extra_env=extra_env,
          )
  
  tests/axil/test_axil.py:339: 
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/runners.py:41: in run
      events.set_event_loop(loop)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/events.py:757: in set_event_loop
      get_event_loop_policy().set_event_loop(loop)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:1134: in set_event_loop
      self._watcher.attach_loop(loop)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:889: in attach_loop
      self._do_waitpid_all()
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:959: in _do_waitpid_all
      self._do_waitpid(pid)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:993: in _do_waitpid
      callback(pid, returncode, *args)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:204: in _child_watcher_callback
      self.call_soon_threadsafe(transp._process_exited, returncode)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/base_events.py:736: in call_soon_threadsafe
      self._check_closed()
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  
  self = <_UnixSelectorEventLoop running=False closed=True debug=False>
  
      def _check_closed(self):
          if self._closed:
  >           raise RuntimeError('Event loop is closed')
  E           RuntimeError: Event loop is closed
  
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/base_events.py:479: RuntimeError
  ------------------------------ Captured log call -------------------------------
  INFO     cocotb:simulator.py:315 Running command: iverilog -o /home/runner/work/cocotbext-axi/cocotbext-axi/tests/axil/sim_build/test_axil-8/test_axil.vvp -D COCOTB_SIM=1 -g2012 -s test_axil -Ptest_axil.DATA_WIDTH=8 -Ptest_axil.ADDR_WIDTH=32 -Ptest_axil.STRB_WIDTH=1 /home/runner/work/cocotbext-axi/cocotbext-axi/tests/axil/test_axil.v
  ________________________________ test_axil[32] _________________________________
  [gw0] linux -- Python 3.7.15 /home/runner/work/cocotbext-axi/cocotbext-axi/.tox/py37/bin/python
  
  request = <FixtureRequest for <Function test_axil[32]>>, data_width = 32
  
      @pytest.mark.parametrize("data_width", [8, 16, 32])
      def test_axil(request, data_width):
          dut = "test_axil"
          module = os.path.splitext(os.path.basename(__file__))[0]
          toplevel = dut
      
          verilog_sources = [
              os.path.join(os.path.dirname(__file__), f"{dut}.v"),
          ]
      
          parameters = {}
      
          parameters['DATA_WIDTH'] = data_width
          parameters['ADDR_WIDTH'] = 32
          parameters['STRB_WIDTH'] = parameters['DATA_WIDTH'] // 8
      
          extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()}
      
          sim_build = os.path.join(tests_dir, "sim_build",
              request.node.name.replace('[', '-').replace(']', ''))
      
          cocotb_test.simulator.run(
              python_search=[tests_dir],
              verilog_sources=verilog_sources,
              toplevel=toplevel,
              module=module,
              parameters=parameters,
              sim_build=sim_build,
  >           extra_env=extra_env,
          )
  
  tests/axil/test_axil.py:339: 
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/runners.py:41: in run
      events.set_event_loop(loop)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/events.py:757: in set_event_loop
      get_event_loop_policy().set_event_loop(loop)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:1134: in set_event_loop
      self._watcher.attach_loop(loop)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:889: in attach_loop
      self._do_waitpid_all()
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:959: in _do_waitpid_all
      self._do_waitpid(pid)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:993: in _do_waitpid
      callback(pid, returncode, *args)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:204: in _child_watcher_callback
      self.call_soon_threadsafe(transp._process_exited, returncode)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/base_events.py:736: in call_soon_threadsafe
      self._check_closed()
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  
  self = <_UnixSelectorEventLoop running=False closed=True debug=False>
  
      def _check_closed(self):
          if self._closed:
  >           raise RuntimeError('Event loop is closed')
  E           RuntimeError: Event loop is closed
  
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/base_events.py:479: RuntimeError
  ------------------------------ Captured log call -------------------------------
  INFO     cocotb:simulator.py:315 Running command: iverilog -o /home/runner/work/cocotbext-axi/cocotbext-axi/tests/axil/sim_build/test_axil-32/test_axil.vvp -D COCOTB_SIM=1 -g2012 -s test_axil -Ptest_axil.DATA_WIDTH=32 -Ptest_axil.ADDR_WIDTH=32 -Ptest_axil.STRB_WIDTH=4 /home/runner/work/cocotbext-axi/cocotbext-axi/tests/axil/test_axil.v
  ________________________________ test_axis[16] _________________________________
  [gw0] linux -- Python 3.7.15 /home/runner/work/cocotbext-axi/cocotbext-axi/.tox/py37/bin/python
  
  request = <FixtureRequest for <Function test_axis[16]>>, data_width = 16
  
      @pytest.mark.parametrize("data_width", [8, 16, 32])
      def test_axis(request, data_width):
          dut = "test_axis"
          module = os.path.splitext(os.path.basename(__file__))[0]
          toplevel = dut
      
          verilog_sources = [
              os.path.join(tests_dir, f"{dut}.v"),
          ]
      
          parameters = {}
      
          parameters['DATA_WIDTH'] = data_width
          parameters['KEEP_WIDTH'] = parameters['DATA_WIDTH'] // 8
          parameters['ID_WIDTH'] = 8
          parameters['DEST_WIDTH'] = 8
          parameters['USER_WIDTH'] = 1
      
          extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()}
      
          sim_build = os.path.join(tests_dir, "sim_build",
              request.node.name.replace('[', '-').replace(']', ''))
      
          cocotb_test.simulator.run(
              python_search=[tests_dir],
              verilog_sources=verilog_sources,
              toplevel=toplevel,
              module=module,
              parameters=parameters,
              sim_build=sim_build,
  >           extra_env=extra_env,
          )
  
  tests/axis/test_axis.py:183: 
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/runners.py:41: in run
      events.set_event_loop(loop)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/events.py:757: in set_event_loop
      get_event_loop_policy().set_event_loop(loop)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:1134: in set_event_loop
      self._watcher.attach_loop(loop)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:889: in attach_loop
      self._do_waitpid_all()
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:959: in _do_waitpid_all
      self._do_waitpid(pid)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:993: in _do_waitpid
      callback(pid, returncode, *args)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:204: in _child_watcher_callback
      self.call_soon_threadsafe(transp._process_exited, returncode)
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/base_events.py:736: in call_soon_threadsafe
      self._check_closed()
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  
  self = <_UnixSelectorEventLoop running=False closed=True debug=False>
  
      def _check_closed(self):
          if self._closed:
  >           raise RuntimeError('Event loop is closed')
  E           RuntimeError: Event loop is closed
  
  /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/base_events.py:479: RuntimeError
  ------------------------------ Captured log call -------------------------------
  INFO     cocotb:simulator.py:315 Running command: iverilog -o /home/runner/work/cocotbext-axi/cocotbext-axi/tests/axis/sim_build/test_axis-16/test_axis.vvp -D COCOTB_SIM=1 -g2012 -s test_axis -Ptest_axis.DATA_WIDTH=16 -Ptest_axis.KEEP_WIDTH=2 -Ptest_axis.ID_WIDTH=8 -Ptest_axis.DEST_WIDTH=8 -Ptest_axis.USER_WIDTH=1 /home/runner/work/cocotbext-axi/cocotbext-axi/tests/axis/test_axis.v
  =============================== warnings summary ===============================
  tests/axi/test_axi.py::test_axi[8]
  tests/axil/test_axil.py::test_axil[16]
  tests/axis/test_axis.py::test_axis[8]
  tests/axis/test_axis.py::test_axis[32]
    /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/asyncio/unix_events.py:878: RuntimeWarning: A loop is being detached from a child watcher with pending handlers
      RuntimeWarning)
  
  -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
  
  ---------- coverage: platform linux, python 3.7.15-final-0 -----------
  Name                               Stmts   Miss Branch BrPart  Cover
  --------------------------------------------------------------------
  cocotbext/axi/__init__.py             16     16      0      0     0%
  cocotbext/axi/address_space.py       239    239     60      0     0%
  cocotbext/axi/axi_channels.py         53     53      0      0     0%
  cocotbext/axi/axi_master.py          714    714    252      0     0%
  cocotbext/axi/axi_ram.py              19     19      0      0     0%
  cocotbext/axi/axi_slave.py           223    223     72      0     0%
  cocotbext/axi/axil_channels.py        53     53      0      0     0%
  cocotbext/axi/axil_master.py         396    396    126      0     0%
  cocotbext/axi/axil_ram.py             19     19      0      0     0%
  cocotbext/axi/axil_slave.py          164    164     48      0     0%
  cocotbext/axi/axis.py                530    530    281      0     0%
  cocotbext/axi/buddy_allocator.py      44     44     20      0     0%
  cocotbext/axi/constants.py            55     55      0      0     0%
  cocotbext/axi/memory.py               57     57      6      0     0%
  cocotbext/axi/reset.py                32     32      8      0     0%
  cocotbext/axi/stream.py              268    268    106      0     0%
  cocotbext/axi/utils.py                19     19      6      0     0%
  cocotbext/axi/version.py               1      1      0      0     0%
  tests/axi/test_axi.py                221    179     64      1    16%
  tests/axil/test_axil.py              203    167     60      1    15%
  tests/axis/test_axis.py               98     62     13      1    35%
  tests/test_buddy_allocator.py         14      0      4      0   100%
  --------------------------------------------------------------------
  TOTAL                               3438   3310   1126      3     3%
  
  =========================== short test summary info ============================
  FAILED tests/axil/test_axil.py::test_axil[8] - RuntimeError: Event loop is cl...
  FAILED tests/axil/test_axil.py::test_axil[32] - RuntimeError: Event loop is c...
  FAILED tests/axis/test_axis.py::test_axis[16] - RuntimeError: Event loop is c...
  ============= 3 failed, 7 passed, 4 warnings in 547.53s (0:09:07) ==============
  py37: exit 1 (548.78 seconds) /home/runner/work/cocotbext-axi/cocotbext-axi> pytest --cov=cocotbext --cov=tests --cov-branch -n auto pid=2098
.pkg: _exit> python /opt/hostedtoolcache/Python/3.7.15/x64/lib/python3.7/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
  py37: FAIL code 1 (562.11=setup[13.33]+cmd[548.78] seconds)
  evaluation failed :( (562.43 seconds)

The warning sys:1: RuntimeWarning: coroutine 'Simulator._exec' was never awaited seems to be rather strange as it looks like that coroutine should be getting passed directly to asyncio.run.

The full CI runs are here: https://github.com/alexforencich/cocotbext-axi/actions/runs/3953695453/jobs/6770251737

@themperek
Copy link
Owner

Will check. Maybe should test on more version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants