def test_yield_list(dut): """Example of yielding on a list of triggers""" clock = dut.clk cocotb.scheduler.add(clock_gen(clock)) yield [Timer(1000), Timer(2000)] yield Timer(10000)
async def test_coroutine_kill(dut): """Test that killing a coroutine causes pending routine continue""" global test_flag clk_gen = cocotb.scheduler.add(clock_gen(dut.clk)) await Timer(100, "ns") clk_gen_two = cocotb.fork(clock_yield(clk_gen)) await Timer(100, "ns") clk_gen.kill() assert not test_flag await Timer(1000, "ns") assert test_flag
def test_coroutine_kill(dut): """Test that killing a coroutine causes pending routine continue""" global test_flag clk_gen = cocotb.scheduler.add(clock_gen(dut.clk)) yield Timer(100) clk_gen_two = cocotb.fork(clock_yield(clk_gen)) yield Timer(100) clk_gen.kill() if test_flag is not False: raise TestFailure yield Timer(1000) if test_flag is not True: raise TestFailure
def test_coroutine_syntax_error(dut): """Syntax error in a coroutine that we yield""" yield clock_gen(dut.clk) yield syntax_error()
def test_fork_syntax_error(dut): """Syntax error in a coroutine that we fork""" yield clock_gen(dut.clk) cocotb.fork(syntax_error()) yield clock_gen(dut.clk)
def test_fork_error(dut): """Error in a coroutine that we fork""" yield clock_gen(dut.clk) cocotb.fork(erroring_coro()) yield clock_gen(dut.clk)
def test_coroutine_error(dut): """Error in a coroutine that we yield""" yield clock_gen(dut.clk) with assert_raises(NameError): yield erroring_coro()
def test_syntax_error(dut): """Syntax error in the test""" yield clock_gen(dut.clk) fail