diff --git a/src/pya/unit_tests/pyaTests.cc b/src/pya/unit_tests/pyaTests.cc index b661c56dc..8adf4dd2f 100644 --- a/src/pya/unit_tests/pyaTests.cc +++ b/src/pya/unit_tests/pyaTests.cc @@ -102,6 +102,7 @@ PYTHONTEST (dbLayoutTest, "dbLayoutTest.py") PYTHONTEST (dbRegionTest, "dbRegionTest.py") PYTHONTEST (dbShapesTest, "dbShapesTest.py") PYTHONTEST (dbReaders, "dbReaders.py") +PYTHONTEST (dbStreams, "dbStreams.py") PYTHONTEST (dbPCellsTest, "dbPCells.py") PYTHONTEST (dbPolygonTest, "dbPolygonTest.py") PYTHONTEST (dbTransTest, "dbTransTest.py") diff --git a/testdata/pcb/simple/import.pcb b/testdata/pcb/simple/import.pcb new file mode 100644 index 000000000..1f87a7788 --- /dev/null +++ b/testdata/pcb/simple/import.pcb @@ -0,0 +1,39 @@ + + + false + 5000 + true + + 1/0 + 2/0 + + top + 0 + 0 + + + + + + + test1.gbr + + 0 + + + + test2.gbr + + 1 + + + + + + r0 *1 0,0 + + -1 + false + 0.001 + PCB + diff --git a/testdata/pcb/simple/test1.gbr b/testdata/pcb/simple/test1.gbr new file mode 100644 index 000000000..4147a2d98 --- /dev/null +++ b/testdata/pcb/simple/test1.gbr @@ -0,0 +1,17 @@ +%FSLAX46Y46*% +%MOMM*% +%LPD*% +G01* +%ADD10C,0.050000*% +D10* +%LPD*% +G36* +X0070000000Y0050000000D02* +X0020000000Y0050000000D01* +X0020000000Y0080000000D01* +X0070000000Y0080000000D01* +X0170000000Y0050000000D02* +X0120000000Y0080000000D01* +X0170000000Y0080000000D01* +G37* +M02* diff --git a/testdata/pcb/simple/test2.gbr b/testdata/pcb/simple/test2.gbr new file mode 100644 index 000000000..eb7f187e7 --- /dev/null +++ b/testdata/pcb/simple/test2.gbr @@ -0,0 +1,15 @@ +%FSLAX46Y46*% +%MOMM*% +%LPD*% +G01* +%ADD10C,0.050000*% +D10* +%LPD*% +G36* +X0070000000Y0050000000D02* +X0070000000Y0050000000D01* +X0020000000Y0050000000D01* +X0020000000Y0080000000D01* +X0070000000Y0080000000D01* +G37* +M02* diff --git a/testdata/pymod/pya_tests.py b/testdata/pymod/pya_tests.py index a3b5496e2..fb2642cf3 100644 --- a/testdata/pymod/pya_tests.py +++ b/testdata/pymod/pya_tests.py @@ -16,6 +16,7 @@ import dbPCells import dbLayoutTest import dbPolygonTest import dbReaders +import dbStreams import dbRegionTest import dbTransTest import dbLayoutToNetlist @@ -32,6 +33,7 @@ if __name__ == '__main__': unittest.TestLoader().loadTestsFromTestCase(dbLayoutTest.DBLayoutTest), unittest.TestLoader().loadTestsFromTestCase(dbPolygonTest.DBPolygonTests), unittest.TestLoader().loadTestsFromTestCase(dbReaders.DBReadersTests), + unittest.TestLoader().loadTestsFromTestCase(dbStreams.DBStreamsTests), unittest.TestLoader().loadTestsFromTestCase(dbRegionTest.DBRegionTest), unittest.TestLoader().loadTestsFromTestCase(dbTransTest.DBTransTests), # aborts on Azure/MSVC pipeline with "src\tl\tl\tlThreadedWorkers.cc,259,! m_running", needs debugging: diff --git a/testdata/python/dbStreams.py b/testdata/python/dbStreams.py new file mode 100644 index 000000000..918868c5d --- /dev/null +++ b/testdata/python/dbStreams.py @@ -0,0 +1,96 @@ +# encoding: UTF-8 + +# KLayout Layout Viewer +# Copyright (C) 2006-2025 Matthias Koefferlein +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import pya +import unittest +import sys +import os + +class DBStreamsTests(unittest.TestCase): + + # Full-spin read-write tests + # This test is rather a smoke test + def rw_test(self, format): + + ly = pya.Layout() + cell = ly.create_cell("TOP") + l1 = ly.layer(1, 0) + cell.shapes(l1).insert(pya.Box(0, 0, 1000, 2000)) + cell.shapes(l1).insert(pya.Box(-100, -200, 2000, 1000)) + bbox = cell.bbox() + + opt = pya.SaveLayoutOptions() + opt.format = format + + b = ly.write_bytes(opt) + + ly2 = pya.Layout() + ly2.read_bytes(b) + + tc = ly.top_cell() + self.assertEqual(tc.name, "TOP") + self.assertEqual(str(tc.bbox()), str(bbox)) + + def test_gds2(self): + self.rw_test("GDS2") + + def test_oasis(self): + self.rw_test("OASIS") + + def test_dxf(self): + self.rw_test("DXF") + + def test_cif(self): + self.rw_test("CIF") + + def test_lstream(self): + self.rw_test("LStream") + + def test_magic(self): + # Smoke test + ut_testsrc = os.getenv("TESTSRC") + ly = pya.Layout() + ly.read(os.path.join(ut_testsrc, "testdata", "magic", "ringo", "RINGO.mag")) + + def test_maly(self): + # Smoke test + ut_testsrc = os.getenv("TESTSRC") + ly = pya.Layout() + ly.read(os.path.join(ut_testsrc, "testdata", "maly", "MALY_test10.maly")) + + def test_pcb(self): + # Smoke test + ut_testsrc = os.getenv("TESTSRC") + ly = pya.Layout() + ly.read(os.path.join(ut_testsrc, "testdata", "pcb", "simple", "import.pcb")) + + def test_lefdef(self): + # Smoke test + ut_testsrc = os.getenv("TESTSRC") + ly = pya.Layout() + ly.read(os.path.join(ut_testsrc, "testdata", "lefdef", "scanchain", "test.def")) + +# run unit tests +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(DBStreamsTests) + + if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): + sys.exit(1) + +