test/test_dump: cleanup
This commit is contained in:
parent
687d09f331
commit
a80d890fb9
|
@ -1,28 +1,39 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
import os
|
||||||
|
from math import cos, sin
|
||||||
|
|
||||||
from litescope.software.dump import *
|
from litescope.software.dump import *
|
||||||
|
|
||||||
|
#TODO:
|
||||||
|
# - find a way to check if files are generated corectly
|
||||||
|
|
||||||
|
dump = Dump()
|
||||||
|
for i in range(4):
|
||||||
|
dump.add(DumpVariable("ramp"+str(i), 2**i, [j for j in range(256)]))
|
||||||
|
pi = 3.1415
|
||||||
|
dump.add(DumpVariable("sin", 8, [128+128*sin(j/(2*pi*16)) for j in range(1024)]))
|
||||||
|
dump.add(DumpVariable("cos", 8, [128+128*cos(j/(2*pi*16)) for j in range(1024)]))
|
||||||
|
|
||||||
|
|
||||||
class TestDump(unittest.TestCase):
|
class TestDump(unittest.TestCase):
|
||||||
def test(self):
|
def test_csv(self):
|
||||||
print("creating dump...")
|
filename = "dump.csv"
|
||||||
dump = Dump()
|
CSVDump(dump).write(filename)
|
||||||
for i in range(4):
|
os.remove(filename)
|
||||||
dump.add(DumpVariable("foo"+str(i), 2**i, [j for j in range(256)]))
|
|
||||||
pi = 3.1415
|
|
||||||
from math import cos, sin
|
|
||||||
dump.add(DumpVariable("sinus", 8, [128+128*sin(j/(2*pi*16)) for j in range(1024)]))
|
|
||||||
dump.add(DumpVariable("cosinus", 8, [128+128*cos(j/(2*pi*16)) for j in range(1024)]))
|
|
||||||
|
|
||||||
print("csv export test")
|
def test_py(self):
|
||||||
CSVDump(dump).write("dump.csv")
|
filename = "dump.py"
|
||||||
|
PythonDump(dump).write(filename)
|
||||||
|
os.remove(filename)
|
||||||
|
|
||||||
print("python export test...")
|
def test_sigrok(self):
|
||||||
PythonDump(dump).write("dump.py")
|
filename = "dump.sr"
|
||||||
|
SigrokDump(dump).write(filename)
|
||||||
|
SigrokDump(dump).read(filename)
|
||||||
|
SigrokDump(dump).write(filename)
|
||||||
|
os.remove(filename)
|
||||||
|
|
||||||
print("sigrok export/import test...")
|
def test_vcd(self):
|
||||||
SigrokDump(dump).write("dump.sr")
|
filename = "dump.vcd"
|
||||||
SigrokDump(dump).read("dump.sr")
|
VCDDump(dump).write(filename)
|
||||||
SigrokDump(dump).write("dump.sr")
|
os.remove(filename)
|
||||||
|
|
||||||
print("vcd export test...")
|
|
||||||
VCDDump(dump).write("dump.vcd")
|
|
||||||
|
|
Loading…
Reference in New Issue