Download chips/openroad_flow_scripts/flow/test/test_klayout_sh.py from STAR-future/Trinity-SciData: direct link, hf CLI and curl.
- Browser
- Download file 2.25 kB
-
https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/openroad_flow_scripts/flow/test/test_klayout_sh.py
- Command line
-
hf download hf://datasets/STAR-future/Trinity-SciData/chips/openroad_flow_scripts/flow/test/test_klayout_sh.py
-
curl -L -o test_klayout_sh.py https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/openroad_flow_scripts/flow/test/test_klayout_sh.py
2.25 kB
| #!/usr/bin/env python3 | |
| """klayout.sh runs a KLayout executable: a deck still in Ruby, the | |
| gallery and the viewers. Without KLayout it stops with an error. With KLayout, the call | |
| goes to it unchanged. | |
| """ | |
| import os | |
| import subprocess | |
| import tempfile | |
| import unittest | |
| SCRIPTS_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "scripts") | |
| KLAYOUT_SH = os.path.join(SCRIPTS_DIR, "klayout.sh") | |
| class TestKlayoutSh(unittest.TestCase): | |
| def setUp(self): | |
| self.tmp_dir = tempfile.TemporaryDirectory() | |
| self.out_file = os.path.join(self.tmp_dir.name, "6_1_merged.gds") | |
| def tearDown(self): | |
| self.tmp_dir.cleanup() | |
| def run_klayout(self, klayout_cmd, *args): | |
| return subprocess.run( | |
| ["bash", KLAYOUT_SH, *args], | |
| env=dict(os.environ, KLAYOUT_CMD=klayout_cmd), | |
| capture_output=True, | |
| text=True, | |
| ) | |
| def stream_args(self): | |
| return [ | |
| "-zz", | |
| "-rd", | |
| "design_name=gcd", | |
| "-rd", | |
| f"out_file={self.out_file}", | |
| "-r", | |
| "/flow/util/def2stream.py", | |
| ] | |
| def test_ruby_deck_still_needs_klayout(self): | |
| result = self.run_klayout( | |
| "", | |
| "-zz", | |
| "-rd", | |
| "in_gds=6_final.gds", | |
| "-rd", | |
| "report_file=6_drc.lyrdb", | |
| "-r", | |
| "deck.lydrc", | |
| ) | |
| self.assertEqual(result.returncode, 1) | |
| self.assertIn("Error: KLayout not found", result.stdout) | |
| def test_viewer_still_needs_klayout(self): | |
| result = self.run_klayout("", "-nn", "klayout.lyt", "6_final.odb") | |
| self.assertEqual(result.returncode, 1) | |
| self.assertIn("Error: KLayout not found", result.stdout) | |
| self.assertFalse(os.path.exists(self.out_file)) | |
| def test_installed_klayout_gets_the_call(self): | |
| result = self.run_klayout("echo", *self.stream_args()) | |
| self.assertEqual(result.returncode, 0, result.stdout + result.stderr) | |
| self.assertNotIn("WARNING", result.stdout) | |
| self.assertIn(f"out_file={self.out_file}", result.stdout) | |
| self.assertFalse(os.path.exists(self.out_file)) | |
| if __name__ == "__main__": | |
| unittest.main() | |