Skip to content

Commit

Permalink
Add test and fix for long log line #219
Browse files Browse the repository at this point in the history
  • Loading branch information
themperek authored Jan 22, 2023
1 parent 08746ad commit 4a5f1d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cocotb_test/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,12 @@ def get_abs_paths(self, paths):

async def _log_pipe(self, level, stream):
while not stream.at_eof():
line = await stream.readline()
try:
line = await stream.readline()
except ValueError:
warnings.warn("Logging limit is reached. Log file will be truncated.", RuntimeWarning, stacklevel=2)
continue

if line:
self.logger.log(level, line.decode("utf-8").rstrip())

Expand Down
23 changes: 23 additions & 0 deletions tests/test_long_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import cocotb
from cocotb.triggers import Timer

import pytest
from cocotb_test.simulator import run
import os

hdl_dir = os.path.dirname(__file__)


@cocotb.test()
def run_test_long_log(dut):

yield Timer(1)

dut._log.info("BEFORE")
dut._log.info("LONGLOG" * 100000)
dut._log.info("AFTER")


@pytest.mark.skipif(os.getenv("SIM") == "ghdl", reason="VHDL not suported")
def test_long_log():
run(verilog_sources=[os.path.join(hdl_dir, "dff.sv")], module="test_long_log", toplevel="dff_test")

0 comments on commit 4a5f1d2

Please sign in to comment.