Skip to content

Commit

Permalink
odb: clang-tidy and clang-format tests
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Garay <fgaray@google.com>
  • Loading branch information
fgaray committed Dec 29, 2023
1 parent 160e834 commit ac77ef3
Show file tree
Hide file tree
Showing 17 changed files with 241 additions and 112 deletions.
173 changes: 111 additions & 62 deletions src/odb/test/cpp/CallBack.h

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions src/odb/test/cpp/TestAccessPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include <fstream>

#include "db.h"
#include "env.h"
#include "helper.h"

using namespace odb;
namespace odb {
namespace {

BOOST_AUTO_TEST_SUITE(test_suite)

Expand All @@ -27,8 +29,7 @@ BOOST_AUTO_TEST_CASE(test_default)
ap->setHighType(dbAccessType::HalfGrid);
ap->setAccess(true, dbDirection::DOWN);
iterm->setAccessPoint(pin, ap);
std::string path
= std::string(std::getenv("BASE_DIR")) + "/results/TestAccessPointDbRW";
std::string path = testTmpPath("/results/TestAccessPointDbRW");
std::ofstream write;
write.exceptions(std::ifstream::failbit | std::ifstream::badbit
| std::ios::eofbit);
Expand Down Expand Up @@ -76,3 +77,6 @@ BOOST_AUTO_TEST_CASE(test_default)
}

BOOST_AUTO_TEST_SUITE_END()

} // namespace
} // namespace odb
16 changes: 11 additions & 5 deletions src/odb/test/cpp/TestCallBacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
#include "CallBack.h"
#include "db.h"
#include "helper.h"
using namespace odb;

namespace odb {
namespace {

BOOST_AUTO_TEST_SUITE(test_suite)
dbDatabase* db;
dbLib* lib;
dbBlock* block;
CallBack* cb;
void setup()
Expand All @@ -19,7 +20,7 @@ void setup()
}
void tearDown()
{
db->destroy(db);
dbDatabase::destroy(db);
delete cb;
}
BOOST_AUTO_TEST_CASE(test_inst_and_iterm)
Expand Down Expand Up @@ -73,7 +74,8 @@ BOOST_AUTO_TEST_CASE(test_inst_and_iterm)
i1->findITerm("a")->disconnect();
BOOST_TEST(cb->events.size() == 0);

i1->destroy(i1);
dbInst::destroy(i1);

BOOST_TEST(cb->events.size() == 4);
BOOST_TEST(cb->events[0] == "Destroy iterm a of inst i1");
BOOST_TEST(cb->events[1] == "Destroy iterm b of inst i1");
Expand Down Expand Up @@ -115,7 +117,8 @@ BOOST_AUTO_TEST_CASE(test_bterm)
BOOST_TEST(cb->events[0] == "Predisconnect IN1");
BOOST_TEST(cb->events[1] == "Postdisconnect IN1 from n1");
cb->clearEvents();
IN1->destroy(IN1);
dbBTerm::destroy(IN1);

BOOST_TEST(cb->events.size() == 1);
BOOST_TEST(cb->events[0] == "Destroy IN1");
tearDown();
Expand Down Expand Up @@ -260,3 +263,6 @@ BOOST_AUTO_TEST_CASE(test_swire)
BOOST_TEST(cb->events[2] == "Destroy swire");
}
BOOST_AUTO_TEST_SUITE_END()

} // namespace
} // namespace odb
6 changes: 5 additions & 1 deletion src/odb/test/cpp/TestGCellGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include "db.h"
#include "helper.h"

using namespace odb;
namespace odb {
namespace {

BOOST_AUTO_TEST_SUITE(test_suite)

Expand All @@ -31,3 +32,6 @@ BOOST_AUTO_TEST_CASE(test_default)
}

BOOST_AUTO_TEST_SUITE_END()

} // namespace
} // namespace odb
6 changes: 5 additions & 1 deletion src/odb/test/cpp/TestGeom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

#include "db.h"
#include "helper.h"
using namespace odb;
namespace odb {
namespace {

BOOST_AUTO_TEST_SUITE(test_suite)

Expand Down Expand Up @@ -136,3 +137,6 @@ BOOST_AUTO_TEST_CASE(test_isotropy)
BOOST_CHECK_EQUAL(test[high], 2);
}
BOOST_AUTO_TEST_SUITE_END()

} // namespace
} // namespace odb
36 changes: 25 additions & 11 deletions src/odb/test/cpp/TestGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "db.h"
#include "helper.h"

using namespace odb;
namespace odb {
namespace {

struct F_DETAILED
{
Expand Down Expand Up @@ -169,13 +170,15 @@ BOOST_AUTO_TEST_CASE(test_group_modinst_iterator)
int i;
BOOST_TEST(modinsts.reversible());
for (int j = 0; j < 2; j++) {
if (j == 1)
if (j == 1) {
modinsts.reverse();
}
for (modinst_itr = modinsts.begin(), i = j ? 1 : 3;
modinst_itr != modinsts.end();
++modinst_itr, i = i + (j ? 1 : -1))
++modinst_itr, i = i + (j ? 1 : -1)) {
BOOST_TEST(std::string(((dbModInst*) *modinst_itr)->getName())
== "i" + std::to_string(i));
}
}
}
BOOST_AUTO_TEST_CASE(test_group_inst_iterator)
Expand All @@ -185,12 +188,14 @@ BOOST_AUTO_TEST_CASE(test_group_inst_iterator)
int i;
BOOST_TEST(insts.reversible());
for (int j = 0; j < 2; j++) {
if (j == 1)
if (j == 1) {
insts.reverse();
}
for (inst_itr = insts.begin(), i = j ? 1 : 3; inst_itr != insts.end();
++inst_itr, i = i + (j ? 1 : -1))
++inst_itr, i = i + (j ? 1 : -1)) {
BOOST_TEST(std::string(((dbInst*) *inst_itr)->getName())
== "i" + std::to_string(i));
}
}
}
BOOST_AUTO_TEST_CASE(test_group_net_iterators)
Expand All @@ -200,12 +205,14 @@ BOOST_AUTO_TEST_CASE(test_group_net_iterators)
int i;
BOOST_TEST(nets.reversible());
for (int j = 0; j < 2; j++) {
if (j == 1)
if (j == 1) {
nets.reverse();
}
for (net_itr = nets.begin(), i = j ? 3 : 1; net_itr != nets.end();
++net_itr, i = i + (j ? -1 : 1))
++net_itr, i = i + (j ? -1 : 1)) {
BOOST_TEST(std::string(((dbNet*) *net_itr)->getName())
== "n" + std::to_string(i));
}
}
group->addGroundNet(n1);
group->addGroundNet(n2);
Expand All @@ -214,12 +221,14 @@ BOOST_AUTO_TEST_CASE(test_group_net_iterators)
nets = group->getGroundNets();
BOOST_TEST(nets.reversible());
for (int j = 0; j < 2; j++) {
if (j == 1)
if (j == 1) {
nets.reverse();
}
for (net_itr = nets.begin(), i = j ? 3 : 1; net_itr != nets.end();
++net_itr, i = i + (j ? -1 : 1))
++net_itr, i = i + (j ? -1 : 1)) {
BOOST_TEST(std::string(((dbNet*) *net_itr)->getName())
== "n" + std::to_string(i));
}
}
}
BOOST_AUTO_TEST_CASE(test_group_group_iterator)
Expand All @@ -229,13 +238,18 @@ BOOST_AUTO_TEST_CASE(test_group_group_iterator)
int i;
BOOST_TEST(children.reversible());
for (int j = 0; j < 2; j++) {
if (j == 1)
if (j == 1) {
children.reverse();
}
for (group_itr = children.begin(), i = j ? 1 : 3;
group_itr != children.end();
++group_itr, i = i + (j ? 1 : -1))
++group_itr, i = i + (j ? 1 : -1)) {
BOOST_TEST(std::string(((dbGroup*) *group_itr)->getName())
== "child" + std::to_string(i));
}
}
}
BOOST_AUTO_TEST_SUITE_END()

} // namespace
} // namespace odb
6 changes: 5 additions & 1 deletion src/odb/test/cpp/TestGuide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include "db.h"
#include "helper.h"

using namespace odb;
namespace odb {
namespace {

BOOST_AUTO_TEST_SUITE(test_suite)

Expand Down Expand Up @@ -45,3 +46,6 @@ BOOST_AUTO_TEST_CASE(test_clear_guides)
}

BOOST_AUTO_TEST_SUITE_END()

} // namespace
} // namespace odb
22 changes: 13 additions & 9 deletions src/odb/test/cpp/TestJournal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
#include <string>

#include "db.h"
#include "env.h"
#include "helper.h"

using namespace odb;
namespace odb {
namespace {

BOOST_AUTO_TEST_SUITE(test_suite)

Expand All @@ -22,12 +24,11 @@ struct F_DEFAULT
dbDatabase* db;
dbLib* lib;
dbBlock* block;
std::string journal_path
= std::string(std::getenv("BASE_DIR")) + "/results/db_jounal.eco";
std::string journal_path = testTmpPath("/results/db_jounal.eco");
};
BOOST_FIXTURE_TEST_CASE(test_write, F_DEFAULT)
{
db->beginEco(block);
dbDatabase::beginEco(block);
auto i1 = odb::dbInst::create(block, lib->findMaster("and2"), "i1");
auto i2 = odb::dbInst::create(block, lib->findMaster("and2"), "i2");
auto n1 = odb::dbNet::create(block, "n1");
Expand All @@ -42,14 +43,14 @@ BOOST_FIXTURE_TEST_CASE(test_write, F_DEFAULT)
odb::dbBTerm::destroy(b3);
odb::dbInst::destroy(i2);
odb::dbNet::destroy(n2);
db->endEco(block);
db->writeEco(block, journal_path.c_str());
dbDatabase::endEco(block);
dbDatabase::writeEco(block, journal_path.c_str());
}
BOOST_FIXTURE_TEST_CASE(test_read, F_DEFAULT)
{
db->beginEco(block);
db->readEco(block, journal_path.c_str());
db->commitEco(block);
dbDatabase::beginEco(block);
dbDatabase::readEco(block, journal_path.c_str());
dbDatabase::commitEco(block);
auto i1 = block->findInst("i1");
auto n1 = block->findNet("n1");
auto b1 = block->findBTerm("b1");
Expand All @@ -74,3 +75,6 @@ BOOST_FIXTURE_TEST_CASE(test_read, F_DEFAULT)
BOOST_TEST(b2->getNet() == nullptr);
}
BOOST_AUTO_TEST_SUITE_END()

} // namespace
} // namespace odb
18 changes: 10 additions & 8 deletions src/odb/test/cpp/TestLef58Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
#include "db.h"
#include "defin.h"
#include "defout.h"
#include "env.h"
#include "lefin.h"
#include "lefout.h"
#include "utl/Logger.h"
using namespace odb;

namespace odb {

BOOST_AUTO_TEST_SUITE(test_suite)

Expand All @@ -23,13 +25,12 @@ BOOST_AUTO_TEST_CASE(lef58_class)
lefin lefParser(db1, logger, false);

const char* libname = "gscl45nm.lef";
std::string path
= std::string(std::getenv("BASE_DIR")) + "/data/gscl45nm.lef";
std::string path = testTmpPath("/data/gscl45nm.lef");
lefParser.createTechAndLib("tech", libname, path.c_str());

odb::dbLib* dbLib = db1->findLib(libname);

path = std::string(std::getenv("BASE_DIR")) + "/data/lef58class_gscl45nm.lef";
path = testTmpPath("/data/lef58class_gscl45nm.lef");
lefParser.updateLib(dbLib, path.c_str());

odb::dbMaster* endcap = db1->findMaster("ENDCAP_BOTTOMEDGE_NOT_A_REAL_CELL");
Expand All @@ -48,13 +49,12 @@ BOOST_AUTO_TEST_CASE(test_default)
lefin lefParser(db1, logger, false);
const char* libname = "gscl45nm.lef";

std::string path
= std::string(std::getenv("BASE_DIR")) + "/data/gscl45nm.lef";
std::string path = testTmpPath("/data/gscl45nm.lef");

lefParser.createTechAndLib("tech", libname, path.c_str());

path = std::string(std::getenv("BASE_DIR"))
+ "/results/TestLef58PropertiesDbRW";
path = testTmpPath("/results/TestLef58PropertiesDbRW");

std::ofstream write;
write.exceptions(std::ifstream::failbit | std::ifstream::badbit
| std::ios::eofbit);
Expand Down Expand Up @@ -482,3 +482,5 @@ BOOST_AUTO_TEST_CASE(test_default)
}

BOOST_AUTO_TEST_SUITE_END()

} // namespace odb
7 changes: 6 additions & 1 deletion src/odb/test/cpp/TestMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include "db.h"
#include "helper.h"

using namespace odb;
namespace odb {
namespace {

BOOST_AUTO_TEST_SUITE(test_suite)

struct F_DEFAULT
Expand Down Expand Up @@ -44,3 +46,6 @@ BOOST_FIXTURE_TEST_CASE(test_delete_module, F_DEFAULT)
}
}
BOOST_AUTO_TEST_SUITE_END()

} // namespace
} // namespace odb
Loading

0 comments on commit ac77ef3

Please sign in to comment.