mirror of https://github.com/m-labs/artiq.git
test: convert lda/tcube/409b to hardware_testbench
This commit is contained in:
parent
959ba99f1c
commit
409c66e966
|
@ -14,6 +14,21 @@ artiq_root = os.getenv("ARTIQ_ROOT")
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_from_ddb(*path, default="skip"):
|
||||
if not artiq_root:
|
||||
raise unittest.SkipTest("no ARTIQ_ROOT")
|
||||
v = FlatFileDB(os.path.join(artiq_root, "ddb.pyon")).data
|
||||
try:
|
||||
for p in path:
|
||||
v = v.read[v]
|
||||
return v.read
|
||||
except KeyError:
|
||||
if default == "skip":
|
||||
raise unittest.SkipTest("ddb path {} not found".format(path))
|
||||
else:
|
||||
return default
|
||||
|
||||
|
||||
@unittest.skipUnless(artiq_root, "no ARTIQ_ROOT")
|
||||
class ExperimentCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import unittest
|
||||
import os
|
||||
|
||||
from artiq.devices.lda.driver import Lda, Ldasim
|
||||
from artiq.language.units import dB
|
||||
|
||||
|
||||
lda_serial = os.getenv("ARTIQ_LDA_SERIAL")
|
||||
from artiq.test.hardware_testbench import get_from_ddb
|
||||
|
||||
|
||||
class GenericLdaTest:
|
||||
|
@ -19,16 +16,13 @@ class GenericLdaTest:
|
|||
self.assertEqual(i, self.cont.get_attenuation())
|
||||
|
||||
|
||||
@unittest.skipUnless(lda_serial, "no hardware")
|
||||
class TestLda(GenericLdaTest, unittest.TestCase):
|
||||
def setUp(self):
|
||||
product = os.getenv("ARTIQ_LDA_PRODUCT")
|
||||
self.cont = Lda(serial=lda_serial, product=product)
|
||||
lda_serial = get_from_ddb("lda", "device")
|
||||
lda_product = get_from_ddb("lda", "product")
|
||||
self.cont = Lda(serial=lda_serial, product=lda_product)
|
||||
|
||||
|
||||
class TestLdaSim(GenericLdaTest, unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.cont = Ldasim()
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import unittest
|
||||
import os
|
||||
|
||||
from artiq.devices.novatech409b.driver import Novatech409B
|
||||
|
||||
|
||||
novatech409b_device = os.getenv("NOVATECH409B_DEVICE")
|
||||
from artiq.test.hardware_testbench import get_from_ddb
|
||||
|
||||
|
||||
class GenericNovatech409BTest:
|
||||
|
@ -23,9 +20,9 @@ class GenericNovatech409BTest:
|
|||
self.assertEqual(r[0:23], "00989680 2000 01F5 0000")
|
||||
|
||||
|
||||
@unittest.skipUnless(novatech409b_device, "no hardware")
|
||||
class TestNovatech409B(GenericNovatech409BTest, unittest.TestCase):
|
||||
def setUp(self):
|
||||
novatech409b_device = get_from_ddb("novatech409b", "device")
|
||||
self.driver = Novatech409B(novatech409b_device)
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import unittest
|
||||
import os
|
||||
import time
|
||||
|
||||
from artiq.devices.thorlabs_tcube.driver import Tdc, Tpz, TdcSim, TpzSim
|
||||
from artiq.language.units import V
|
||||
from artiq.test.hardware_testbench import get_from_ddb
|
||||
|
||||
|
||||
class GenericTdcTest:
|
||||
|
@ -131,12 +131,9 @@ class GenericTpzTest:
|
|||
self.assertEqual(test_vector, self.cont.get_tpz_io_settings())
|
||||
|
||||
|
||||
tdc_serial = os.getenv("ARTIQ_TDC_SERIAL")
|
||||
|
||||
|
||||
@unittest.skipUnless(tdc_serial, "no hardware")
|
||||
class TestTdc(unittest.TestCase, GenericTdcTest):
|
||||
def setUp(self):
|
||||
tdc_serial = get_from_ddb("tdc", "device")
|
||||
self.cont = Tdc(serial_dev=tdc_serial)
|
||||
|
||||
|
||||
|
@ -145,12 +142,9 @@ class TestTdcSim(unittest.TestCase, GenericTdcTest):
|
|||
self.cont = TdcSim()
|
||||
|
||||
|
||||
tpz_serial = os.getenv("ARTIQ_TPZ_SERIAL")
|
||||
|
||||
|
||||
@unittest.skipUnless(tpz_serial, "no hardware")
|
||||
class TestTpz(unittest.TestCase, GenericTpzTest):
|
||||
def setUp(self):
|
||||
tpz_serial = get_from_ddb("tpz", "device")
|
||||
self.cont = Tpz(serial_dev=tpz_serial)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue