1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00

added tests

This commit is contained in:
jand 2003-07-20 21:01:27 +00:00
parent 0ef2529d71
commit 57cb110a49
2 changed files with 44 additions and 5 deletions

View File

@ -29,6 +29,8 @@ import random
from random import randrange
random.seed(1) # random, but deterministic
import sys
import os
path = os.path
import unittest
from unittest import TestCase
@ -52,11 +54,18 @@ def dummy():
inst = gen(clk)
return 1
def top():
inst = trace_sigs(fun)
return inst
class TestTraceSigs(TestCase):
def testTopName(self):
top = trace_sigs(fun)
p = "dut.vcd"
if path.exists(p):
os.remove(p)
dut = trace_sigs(fun)
try:
trace_sigs(fun)
except TopLevelNameError:
@ -65,28 +74,58 @@ class TestTraceSigs(TestCase):
self.fail()
def testArgType1(self):
p = "dut.vcd"
if path.exists(p):
os.remove(p)
try:
top = trace_sigs([1, 2])
dut = trace_sigs([1, 2])
except ArgTypeError:
pass
else:
self.fail()
def testArgType2(self):
p = "dut.vcd"
if path.exists(p):
os.remove(p)
try:
top = trace_sigs(gen, Signal(0))
dut = trace_sigs(gen, Signal(0))
except ArgTypeError:
pass
else:
self.fail()
def testReturnVal(self):
p = "dut.vcd"
if path.exists(p):
os.remove(p)
try:
top = trace_sigs(dummy)
dut = trace_sigs(dummy)
except NoInstancesError:
pass
else:
self.fail()
def testHierarchicalTrace1(self):
p = "inst.vcd"
if path.exists(p):
os.remove(p)
top()
self.assert_(path.exists(p))
def testHierarchicalTrace2(self):
pdut = "dut.vcd"
psub = "inst.vcd"
for p in (pdut, psub):
if path.exists(p):
os.remove(p)
dut = trace_sigs(top)
self.assert_(path.exists(pdut))
self.assert_(not path.exists(psub))

View File

@ -68,7 +68,7 @@ def trace_sigs(dut, *args, **kwargs):
if _isgeneratorfunction(dut):
raise ArgTypeError("got generator function")
if _tracing:
return dut(*args, **kwargs) # skip
return dut(*args, **kwargs) # skip
_tracing = 1
try:
o = getouterframes(currentframe())[1]