Skip to content

Commit bb20d3e

Browse files
committed
odb: move Test3DBloxParser to gtest and add to bzl build
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
1 parent 58094b6 commit bb20d3e

2 files changed

Lines changed: 89 additions & 89 deletions

File tree

src/odb/test/cpp/BUILD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,22 @@ cc_test(
217217
],
218218
)
219219

220+
cc_test(
221+
name = "Test3DBloxParser",
222+
srcs = [
223+
"Test3DBloxParser.cpp",
224+
"nangate45_test_fixture.h",
225+
],
226+
data = [
227+
"//src/odb/test:regression_resources",
228+
],
229+
deps = [
230+
"//src/odb",
231+
"//src/tst",
232+
"//src/utl",
233+
"@googletest//:gtest",
234+
"@googletest//:gtest_main",
235+
],
236+
)
237+
220238
# TODO: more to come.
Lines changed: 71 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,114 @@
1-
#define BOOST_TEST_MODULE Test3DBloxParser
21
#include <iostream>
32
#include <string>
43

5-
#include "boost/test/included/unit_test.hpp"
6-
#include "env.h"
74
#include "odb/3dblox.h"
85
#include "odb/db.h"
96
#include "odb/geom.h"
7+
#include "tst/fixture.h"
8+
109
namespace odb {
1110
namespace {
1211

13-
BOOST_AUTO_TEST_SUITE(test_suite)
12+
static const std::string prefix("_main/src/odb/test/");
1413

15-
struct F_DBV_PARSER
14+
class DbvFixture : public tst::Fixture
1615
{
17-
F_DBV_PARSER()
16+
protected:
17+
DbvFixture()
1818
{
19-
db = dbDatabase::create();
20-
dbTech::create(db, "tech");
21-
logger = new utl::Logger();
22-
db->setLogger(logger);
23-
ThreeDBlox parser(logger, db);
24-
std::string path = testTmpPath("data", "example.3dbx");
19+
dbTech::create(db_.get(), "tech");
20+
ThreeDBlox parser(&logger_, db_.get());
21+
std::string path = getFilePath(prefix + "data/example.3dbx");
2522
parser.readDbx(path);
2623
}
27-
28-
~F_DBV_PARSER()
29-
{
30-
dbDatabase::destroy(db);
31-
delete logger;
32-
}
33-
odb::dbDatabase* db;
34-
utl::Logger* logger;
3524
};
3625

37-
BOOST_FIXTURE_TEST_CASE(test_3dbv, F_DBV_PARSER)
26+
TEST_F(DbvFixture, test_3dbv)
3827
{
3928
// Test that database precision was set correctly
40-
BOOST_CHECK_EQUAL(db->getDbuPerMicron(), 100000);
29+
EXPECT_EQ(db_->getDbuPerMicron(), 100000);
4130

42-
auto chips = db->getChips();
43-
BOOST_CHECK_EQUAL(chips.size(), 2);
31+
auto chips = db_->getChips();
32+
EXPECT_EQ(chips.size(), 2);
4433
auto chip = *chips.begin();
45-
BOOST_CHECK_EQUAL(chip->getName(), "SoC");
46-
BOOST_TEST((chip->getChipType() == dbChip::ChipType::DIE));
34+
EXPECT_STREQ(chip->getName(), "SoC");
35+
EXPECT_EQ(chip->getChipType(), dbChip::ChipType::DIE);
4736

4837
// Test chip dimensions (converted to DBU)
49-
int expected_width = 955 * db->getDbuPerMicron();
50-
int expected_height = 1082 * db->getDbuPerMicron();
51-
int expected_thickness = 300 * db->getDbuPerMicron();
38+
int expected_width = 955 * db_->getDbuPerMicron();
39+
int expected_height = 1082 * db_->getDbuPerMicron();
40+
int expected_thickness = 300 * db_->getDbuPerMicron();
5241

53-
BOOST_CHECK_EQUAL(chip->getWidth(), expected_width);
54-
BOOST_CHECK_EQUAL(chip->getHeight(), expected_height);
55-
BOOST_CHECK_EQUAL(chip->getThickness(), expected_thickness);
42+
EXPECT_EQ(chip->getWidth(), expected_width);
43+
EXPECT_EQ(chip->getHeight(), expected_height);
44+
EXPECT_EQ(chip->getThickness(), expected_thickness);
5645

5746
// Test chip properties
58-
BOOST_CHECK_CLOSE(chip->getShrink(), 1.0, 0.001);
59-
BOOST_CHECK_EQUAL(chip->isTsv(), false);
47+
EXPECT_NEAR(chip->getShrink(), 1.0, 0.001);
48+
EXPECT_EQ(chip->isTsv(), false);
6049

6150
// Test chip regions were created
6251
auto regions = chip->getChipRegions();
63-
BOOST_CHECK_EQUAL(regions.size(), 1);
52+
EXPECT_EQ(regions.size(), 1);
6453

6554
auto region = *regions.begin();
66-
BOOST_CHECK_EQUAL(region->getName(), "r1");
67-
BOOST_TEST((region->getSide() == dbChipRegion::Side::FRONT));
55+
EXPECT_EQ(region->getName(), "r1");
56+
EXPECT_EQ(region->getSide(), dbChipRegion::Side::FRONT);
6857

6958
// Test region bounding box
7059
Rect region_box = region->getBox();
71-
int expected_x1 = 0 * db->getDbuPerMicron();
72-
int expected_y1 = 0 * db->getDbuPerMicron();
73-
int expected_x2 = 955 * db->getDbuPerMicron();
74-
int expected_y2 = 1082 * db->getDbuPerMicron();
60+
int expected_x1 = 0 * db_->getDbuPerMicron();
61+
int expected_y1 = 0 * db_->getDbuPerMicron();
62+
int expected_x2 = 955 * db_->getDbuPerMicron();
63+
int expected_y2 = 1082 * db_->getDbuPerMicron();
7564

76-
BOOST_CHECK_EQUAL(region_box.xMin(), expected_x1);
77-
BOOST_CHECK_EQUAL(region_box.yMin(), expected_y1);
78-
BOOST_CHECK_EQUAL(region_box.xMax(), expected_x2);
79-
BOOST_CHECK_EQUAL(region_box.yMax(), expected_y2);
65+
EXPECT_EQ(region_box.xMin(), expected_x1);
66+
EXPECT_EQ(region_box.yMin(), expected_y1);
67+
EXPECT_EQ(region_box.xMax(), expected_x2);
68+
EXPECT_EQ(region_box.yMax(), expected_y2);
8069
}
81-
BOOST_FIXTURE_TEST_CASE(test_3dbx, F_DBV_PARSER)
70+
71+
TEST_F(DbvFixture, test_3dbx)
8272
{
83-
auto chip_insts = db->getChipInsts();
84-
BOOST_CHECK_EQUAL(chip_insts.size(), 2);
85-
auto soc_inst = db->getChip()->findChipInst("soc_inst");
86-
auto soc_inst_duplicate = db->getChip()->findChipInst("soc_inst_duplicate");
87-
BOOST_CHECK_EQUAL(soc_inst->getName(), "soc_inst");
88-
BOOST_CHECK_EQUAL(soc_inst->getMasterChip()->getName(), "SoC");
89-
BOOST_CHECK_EQUAL(soc_inst->getParentChip()->getName(), "TopDesign");
90-
BOOST_CHECK_EQUAL(soc_inst_duplicate->getName(), "soc_inst_duplicate");
91-
BOOST_CHECK_EQUAL(soc_inst_duplicate->getMasterChip()->getName(), "SoC");
92-
BOOST_CHECK_EQUAL(soc_inst_duplicate->getParentChip()->getName(),
93-
"TopDesign");
94-
BOOST_CHECK_EQUAL(soc_inst->getLoc().x(), 100.0 * db->getDbuPerMicron());
95-
BOOST_CHECK_EQUAL(soc_inst->getLoc().y(), 200.0 * db->getDbuPerMicron());
96-
BOOST_CHECK_EQUAL(soc_inst->getLoc().z(), 0.0);
97-
BOOST_CHECK_EQUAL(soc_inst->getOrient().getString(), "R0");
98-
BOOST_CHECK_EQUAL(soc_inst_duplicate->getLoc().x(),
99-
100.0 * db->getDbuPerMicron());
100-
BOOST_CHECK_EQUAL(soc_inst_duplicate->getLoc().y(),
101-
200.0 * db->getDbuPerMicron());
102-
BOOST_CHECK_EQUAL(soc_inst_duplicate->getLoc().z(),
103-
300.0 * db->getDbuPerMicron());
104-
BOOST_CHECK_EQUAL(soc_inst_duplicate->getOrient().getString(), "MZ");
105-
auto connections = db->getChipConns();
106-
BOOST_CHECK_EQUAL(connections.size(), 2);
73+
auto chip_insts = db_->getChipInsts();
74+
EXPECT_EQ(chip_insts.size(), 2);
75+
auto soc_inst = db_->getChip()->findChipInst("soc_inst");
76+
auto soc_inst_duplicate = db_->getChip()->findChipInst("soc_inst_duplicate");
77+
EXPECT_EQ(soc_inst->getName(), "soc_inst");
78+
EXPECT_STREQ(soc_inst->getMasterChip()->getName(), "SoC");
79+
EXPECT_STREQ(soc_inst->getParentChip()->getName(), "TopDesign");
80+
EXPECT_EQ(soc_inst_duplicate->getName(), "soc_inst_duplicate");
81+
EXPECT_STREQ(soc_inst_duplicate->getMasterChip()->getName(), "SoC");
82+
EXPECT_STREQ(soc_inst_duplicate->getParentChip()->getName(), "TopDesign");
83+
EXPECT_EQ(soc_inst->getLoc().x(), 100.0 * db_->getDbuPerMicron());
84+
EXPECT_EQ(soc_inst->getLoc().y(), 200.0 * db_->getDbuPerMicron());
85+
EXPECT_EQ(soc_inst->getLoc().z(), 0.0);
86+
EXPECT_EQ(soc_inst->getOrient().getString(), "R0");
87+
EXPECT_EQ(soc_inst_duplicate->getLoc().x(), 100.0 * db_->getDbuPerMicron());
88+
EXPECT_EQ(soc_inst_duplicate->getLoc().y(), 200.0 * db_->getDbuPerMicron());
89+
EXPECT_EQ(soc_inst_duplicate->getLoc().z(), 300.0 * db_->getDbuPerMicron());
90+
EXPECT_EQ(soc_inst_duplicate->getOrient().getString(), "MZ");
91+
auto connections = db_->getChipConns();
92+
EXPECT_EQ(connections.size(), 2);
10793
auto itr = connections.begin();
10894
auto connection = *itr++;
109-
BOOST_CHECK_EQUAL(connection->getName(), "soc_to_soc");
110-
BOOST_CHECK_EQUAL(connection->getTopRegion()->getChipInst()->getName(),
111-
"soc_inst_duplicate");
112-
BOOST_CHECK_EQUAL(connection->getBottomRegion()->getChipInst()->getName(),
113-
"soc_inst");
114-
BOOST_CHECK_EQUAL(connection->getThickness(), 2.0 * db->getDbuPerMicron());
95+
EXPECT_EQ(connection->getName(), "soc_to_soc");
96+
EXPECT_EQ(connection->getTopRegion()->getChipInst()->getName(),
97+
"soc_inst_duplicate");
98+
EXPECT_EQ(connection->getBottomRegion()->getChipInst()->getName(),
99+
"soc_inst");
100+
EXPECT_EQ(connection->getThickness(), 2.0 * db_->getDbuPerMicron());
115101
connection = *itr;
116-
BOOST_CHECK_EQUAL(connection->getName(), "soc_to_virtual");
117-
BOOST_CHECK_EQUAL(connection->getTopRegion()->getChipInst()->getName(),
118-
"soc_inst_duplicate");
119-
BOOST_CHECK_EQUAL(connection->getTopRegionPath().size(), 1);
120-
BOOST_CHECK_EQUAL(connection->getTopRegionPath()[0]->getName(),
121-
"soc_inst_duplicate");
122-
BOOST_CHECK_EQUAL(connection->getTopRegion()->getChipRegion()->getName(),
123-
"r1");
124-
BOOST_CHECK_EQUAL(connection->getBottomRegionPath().size(), 0);
125-
BOOST_CHECK_EQUAL(connection->getBottomRegion(), nullptr);
126-
BOOST_CHECK_EQUAL(connection->getThickness(), 0.0);
102+
EXPECT_EQ(connection->getName(), "soc_to_virtual");
103+
EXPECT_EQ(connection->getTopRegion()->getChipInst()->getName(),
104+
"soc_inst_duplicate");
105+
EXPECT_EQ(connection->getTopRegionPath().size(), 1);
106+
EXPECT_EQ(connection->getTopRegionPath()[0]->getName(), "soc_inst_duplicate");
107+
EXPECT_EQ(connection->getTopRegion()->getChipRegion()->getName(), "r1");
108+
EXPECT_EQ(connection->getBottomRegionPath().size(), 0);
109+
EXPECT_EQ(connection->getBottomRegion(), nullptr);
110+
EXPECT_EQ(connection->getThickness(), 0.0);
127111
}
128112

129-
BOOST_AUTO_TEST_SUITE_END()
130-
131113
} // namespace
132114
} // namespace odb

0 commit comments

Comments
 (0)