|
1 | | -#define BOOST_TEST_MODULE Test3DBloxParser |
2 | 1 | #include <iostream> |
3 | 2 | #include <string> |
4 | 3 |
|
5 | | -#include "boost/test/included/unit_test.hpp" |
6 | | -#include "env.h" |
7 | 4 | #include "odb/3dblox.h" |
8 | 5 | #include "odb/db.h" |
9 | 6 | #include "odb/geom.h" |
| 7 | +#include "tst/fixture.h" |
| 8 | + |
10 | 9 | namespace odb { |
11 | 10 | namespace { |
12 | 11 |
|
13 | | -BOOST_AUTO_TEST_SUITE(test_suite) |
| 12 | +static const std::string prefix("_main/src/odb/test/"); |
14 | 13 |
|
15 | | -struct F_DBV_PARSER |
| 14 | +class DbvFixture : public tst::Fixture |
16 | 15 | { |
17 | | - F_DBV_PARSER() |
| 16 | + protected: |
| 17 | + DbvFixture() |
18 | 18 | { |
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"); |
25 | 22 | parser.readDbx(path); |
26 | 23 | } |
27 | | - |
28 | | - ~F_DBV_PARSER() |
29 | | - { |
30 | | - dbDatabase::destroy(db); |
31 | | - delete logger; |
32 | | - } |
33 | | - odb::dbDatabase* db; |
34 | | - utl::Logger* logger; |
35 | 24 | }; |
36 | 25 |
|
37 | | -BOOST_FIXTURE_TEST_CASE(test_3dbv, F_DBV_PARSER) |
| 26 | +TEST_F(DbvFixture, test_3dbv) |
38 | 27 | { |
39 | 28 | // Test that database precision was set correctly |
40 | | - BOOST_CHECK_EQUAL(db->getDbuPerMicron(), 100000); |
| 29 | + EXPECT_EQ(db_->getDbuPerMicron(), 100000); |
41 | 30 |
|
42 | | - auto chips = db->getChips(); |
43 | | - BOOST_CHECK_EQUAL(chips.size(), 2); |
| 31 | + auto chips = db_->getChips(); |
| 32 | + EXPECT_EQ(chips.size(), 2); |
44 | 33 | 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); |
47 | 36 |
|
48 | 37 | // 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(); |
52 | 41 |
|
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); |
56 | 45 |
|
57 | 46 | // 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); |
60 | 49 |
|
61 | 50 | // Test chip regions were created |
62 | 51 | auto regions = chip->getChipRegions(); |
63 | | - BOOST_CHECK_EQUAL(regions.size(), 1); |
| 52 | + EXPECT_EQ(regions.size(), 1); |
64 | 53 |
|
65 | 54 | 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); |
68 | 57 |
|
69 | 58 | // Test region bounding box |
70 | 59 | 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(); |
75 | 64 |
|
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); |
80 | 69 | } |
81 | | -BOOST_FIXTURE_TEST_CASE(test_3dbx, F_DBV_PARSER) |
| 70 | + |
| 71 | +TEST_F(DbvFixture, test_3dbx) |
82 | 72 | { |
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); |
107 | 93 | auto itr = connections.begin(); |
108 | 94 | 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()); |
115 | 101 | 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); |
127 | 111 | } |
128 | 112 |
|
129 | | -BOOST_AUTO_TEST_SUITE_END() |
130 | | - |
131 | 113 | } // namespace |
132 | 114 | } // namespace odb |
0 commit comments