mirror of https://github.com/m-labs/artiq.git
sinara_tester: add device_db and test selection CLI options
Signed-off-by: Etienne Wodey <etienne.wodey@aqt.eu>
This commit is contained in:
parent
7a7e17f7e3
commit
a8333053c9
|
@ -1,8 +1,10 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys
|
import argparse
|
||||||
|
import inspect
|
||||||
import os
|
import os
|
||||||
import select
|
import select
|
||||||
|
import sys
|
||||||
|
|
||||||
from artiq.experiment import *
|
from artiq.experiment import *
|
||||||
from artiq.coredevice.ad9910 import AD9910, SyncDataEeprom
|
from artiq.coredevice.ad9910 import AD9910, SyncDataEeprom
|
||||||
|
@ -651,40 +653,63 @@ class SinaraTester(EnvExperiment):
|
||||||
print("Press ENTER when done.")
|
print("Press ENTER when done.")
|
||||||
input()
|
input()
|
||||||
|
|
||||||
def run(self):
|
def run(self, tests):
|
||||||
print("****** Sinara system tester ******")
|
print("****** Sinara system tester ******")
|
||||||
print("")
|
print("")
|
||||||
self.core.reset()
|
self.core.reset()
|
||||||
if self.leds:
|
|
||||||
self.test_leds()
|
for name in tests:
|
||||||
if self.ttl_outs:
|
if getattr(self, name):
|
||||||
self.test_ttl_outs()
|
getattr(self, f"test_{name}")()
|
||||||
if self.ttl_ins:
|
|
||||||
self.test_ttl_ins()
|
@classmethod
|
||||||
if self.urukuls:
|
def available_tests(cls):
|
||||||
self.test_urukuls()
|
# listed in definition order
|
||||||
if self.mirnies:
|
return [
|
||||||
self.test_mirnies()
|
name.split("_", maxsplit=1)[1]
|
||||||
if self.samplers:
|
for name, obj in vars(cls).items()
|
||||||
self.test_samplers()
|
if is_hw_test(obj)
|
||||||
if self.zotinos:
|
]
|
||||||
self.test_zotinos()
|
|
||||||
if self.fastinos:
|
|
||||||
self.test_fastinos()
|
def is_hw_test(obj):
|
||||||
if self.phasers:
|
return (
|
||||||
self.test_phasers()
|
inspect.isfunction(obj) and
|
||||||
if self.grabbers:
|
obj.__name__.startswith("test_") and
|
||||||
self.test_grabbers()
|
len(inspect.signature(obj).parameters) == 1
|
||||||
if self.suservos:
|
)
|
||||||
self.test_suservos()
|
|
||||||
|
|
||||||
|
def get_argparser(available_tests):
|
||||||
|
parser = argparse.ArgumentParser(description="Sinara crate testing tool")
|
||||||
|
|
||||||
|
parser.add_argument("--device-db", default="device_db.py",
|
||||||
|
help="device database file (default: '%(default)s')")
|
||||||
|
group = parser.add_mutually_exclusive_group()
|
||||||
|
group.add_argument("-x", "--exclude", nargs="*", choices=available_tests,
|
||||||
|
help="do not run the listed tests")
|
||||||
|
group.add_argument("-o", "--only", nargs="*", choices=available_tests,
|
||||||
|
help="run only the listed tests")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
device_mgr = DeviceManager(DeviceDB("device_db.py"))
|
available_tests = SinaraTester.available_tests()
|
||||||
|
args = get_argparser(available_tests).parse_args()
|
||||||
|
|
||||||
|
if args.exclude is not None:
|
||||||
|
# don't use set in order to keep the order
|
||||||
|
tests = [test for test in available_tests if test not in args.exclude]
|
||||||
|
elif args.only is not None:
|
||||||
|
tests = args.only
|
||||||
|
else:
|
||||||
|
tests = available_tests
|
||||||
|
|
||||||
|
device_mgr = DeviceManager(DeviceDB(args.device_db))
|
||||||
try:
|
try:
|
||||||
experiment = SinaraTester((device_mgr, None, None, None))
|
experiment = SinaraTester((device_mgr, None, None, None))
|
||||||
experiment.prepare()
|
experiment.prepare()
|
||||||
experiment.run()
|
experiment.run(tests)
|
||||||
experiment.analyze()
|
experiment.analyze()
|
||||||
finally:
|
finally:
|
||||||
device_mgr.close_devices()
|
device_mgr.close_devices()
|
||||||
|
|
Loading…
Reference in New Issue