From ea135f9d06024128cf38b8fa6b44b174b87c7b33 Mon Sep 17 00:00:00 2001 From: mntng Date: Tue, 15 Aug 2017 08:12:40 -0600 Subject: [PATCH] add unittest for artiq_compile and ELF artiq_run (#455) --- artiq/test/coredevice/test_compile.py | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 artiq/test/coredevice/test_compile.py diff --git a/artiq/test/coredevice/test_compile.py b/artiq/test/coredevice/test_compile.py new file mode 100644 index 000000000..0efb5eb8b --- /dev/null +++ b/artiq/test/coredevice/test_compile.py @@ -0,0 +1,36 @@ +import os +import sys +import subprocess +import unittest +import tempfile +from artiq.coredevice.comm_mgmt import CommMgmt +from artiq.test.hardware_testbench import ExperimentCase +from artiq.experiment import * + + +artiq_root = os.getenv("ARTIQ_ROOT") + + +class CheckLog(EnvExperiment): + def build(self): + self.setattr_device("core") + + @kernel + def run(self): + core_log("test_artiq_compile") + + +class TestCompile(ExperimentCase): + def test_compile(self): + core_addr = self.device_mgr.get_desc("core")["arguments"]["host"] + mgmt = CommMgmt(core_addr) + mgmt.clear_log() + with tempfile.TemporaryDirectory() as tmp: + db_path = os.path.join(artiq_root, "device_db.py") + subprocess.call([sys.executable, "-m", "artiq.frontend.artiq_compile", "--device-db", db_path, + "-e", "CheckLog", "-o", os.path.join(tmp, "check_log.elf"), __file__]) + subprocess.call([sys.executable, "-m", "artiq.frontend.artiq_run", "--device-db", db_path, + os.path.join(tmp, "check_log.elf")]) + log = mgmt.get_log() + self.assertIn("test_artiq_compile", log) + mgmt.close()