Added a first test for Magic reader/writer

This commit is contained in:
Matthias Koefferlein 2019-11-29 01:14:41 +01:00
parent 3f9dd59593
commit 0796b20c2d
6 changed files with 18 additions and 64 deletions

View File

@ -332,6 +332,10 @@ MAGReader::do_read_part (db::Layout &layout, db::cell_index_type cell_index, tl:
valid_layer = false;
} else if (lname == "labels") {
in_labels = true;
} else if (lname == "checkpaint") {
// ignore "checkpaint" internal layer
in_labels = false;
valid_layer = false;
} else {
in_labels = false;
std::pair<bool, unsigned int> ll = open_layer (layout, lname);

View File

@ -29,7 +29,7 @@
#include <stdlib.h>
static void run_test (tl::TestBase *_this, const std::string &base, const char *file, const char *file_au, const char *map = 0, double dbu = 0.001)
static void run_test (tl::TestBase *_this, const std::string &base, const char *file, const char *file_au, const char *map = 0, double lambda = 0.1, double dbu = 0.001)
{
db::MAGReaderOptions *opt = new db::MAGReaderOptions();
opt->dbu = dbu;
@ -59,7 +59,7 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
{
std::string fn (base);
fn += "/testdata/mag/";
fn += "/testdata/magic/";
fn += file;
tl::InputStream stream (fn);
db::Reader reader (stream);
@ -74,19 +74,19 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
// normalize the layout by writing to GDS and reading from ..
std::string tmp_gds_file = _this->tmp_file (tl::sprintf ("tmp_%x.gds", hash));
std::string tmp_cif_file = _this->tmp_file (tl::sprintf ("tmp_%x.cif", hash));
std::string tmp_mag_file = _this->tmp_file (tl::sprintf ("tmp_%x.mag", hash));
{
tl::OutputStream stream (tmp_gds_file);
tl::OutputStream stream (tmp_cif_file);
db::SaveLayoutOptions options;
options.set_format ("GDS2");
options.set_format ("CIF");
db::Writer writer (options);
writer.write (layout, stream);
}
{
tl::InputStream stream (tmp_gds_file);
tl::InputStream stream (tmp_cif_file);
db::Reader reader (stream);
reader.read (layout2);
}
@ -97,7 +97,7 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
tl::OutputStream stream (tmp_mag_file);
db::MAGWriterOptions *opt = new db::MAGWriterOptions();
opt->lambda = 0.5;
opt->lambda = lambda;
db::MAGWriter writer;
db::SaveLayoutOptions options;
@ -110,16 +110,19 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
db::MAGReaderOptions *opt = new db::MAGReaderOptions();
opt->dbu = dbu;
opt->lambda = lambda;
db::LoadLayoutOptions reread_options;
reread_options.set_options (opt);
db::Reader reader (stream);
reader.read (layout2_mag, reread_options);
layout2_mag.rename_cell (*layout2_mag.begin_top_down (), layout.cell_name (*layout.begin_top_down ()));
}
{
std::string fn (base);
fn += "/testdata/mag/";
fn += "/testdata/magic/";
fn += file_au;
tl::InputStream stream (fn);
db::Reader reader (stream);
@ -128,7 +131,7 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
bool equal = db::compare_layouts (layout2, layout_au, db::layout_diff::f_boxes_as_polygons | db::layout_diff::f_verbose | db::layout_diff::f_flatten_array_insts, 1);
if (! equal) {
_this->raise (tl::sprintf ("Compare failed after reading - see %s vs %s\n", tmp_gds_file, file_au));
_this->raise (tl::sprintf ("Compare failed after reading - see %s vs %s\n", tmp_cif_file, file_au));
}
equal = db::compare_layouts (layout, layout2_mag, db::layout_diff::f_boxes_as_polygons | db::layout_diff::f_verbose | db::layout_diff::f_flatten_array_insts, 1);
@ -137,61 +140,8 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
}
}
#if 0 // @@@
TEST(1a)
TEST(1)
{
run_test (_this, tl::testsrc_private (), "t1.mag.gz", "t1a_au.gds.gz");
run_test (_this, tl::testsrc (), "mag_test.mag.gz", "mag_test_au.cif.gz");
}
TEST(1b)
{
run_test (_this, tl::testsrc_private (), "t1.mag.gz", "t1b_au.gds.gz", 0, 0.01);
}
TEST(1c)
{
run_test (_this, tl::testsrc_private (), "t1.mag.gz", "t1b_au.gds.gz", 0, 0.01, true);
}
TEST(1d)
{
run_test (_this, tl::testsrc_private (), "t1.mag.gz", "t1b_au.gds.gz", 0, 0.01, false, true);
}
TEST(2)
{
run_test (_this, tl::testsrc_private (), "t2.mag.gz", "t2_au.gds.gz");
}
TEST(3a)
{
run_test (_this, tl::testsrc_private (), "t3.mag.gz", "t3a_au.gds.gz", "CAA:43,CCA:48,CCP:47,CMF:49,CMS:51,CPG:46,CSN:45,CSP:44,CVA:50,CWN:42,XP:26");
}
TEST(3b)
{
run_test (_this, tl::testsrc_private (), "t3.mag.gz", "t3b_au.gds.gz", "CAA:43,CCA:48,CCP:47,CMF:49,CMS:51,CPG:46,CSN:45,CSP:44,CVA:50,CWN:42,XP:26", 0.00012);
}
TEST(4)
{
run_test (_this, tl::testsrc_private (), "t4.mag.gz", "t4_au.gds.gz");
}
TEST(5)
{
run_test (_this, tl::testsrc_private (), "t5.mag.gz", "t5_au.gds.gz");
}
// Issue #28
TEST(lasi)
{
run_test (_this, tl::testsrc (), "lasi.mag.gz", "lasi_au.gds.gz");
}
// Issue #305
TEST(rot_boxes)
{
run_test (_this, tl::testsrc (), "issue_305.mag", "issue_305_au.gds");
}
#endif // @@@

BIN
testdata/magic/CHILD.mag.gz vendored Normal file

Binary file not shown.

BIN
testdata/magic/mag_test.mag.gz vendored Normal file

Binary file not shown.

BIN
testdata/magic/mag_test.oas vendored Normal file

Binary file not shown.

BIN
testdata/magic/mag_test_au.cif.gz vendored Normal file

Binary file not shown.