Skip to content

Commit

Permalink
odb: fixing unit 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 Feb 21, 2024
1 parent 4ff8648 commit 4233e07
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/odb/test/cpp/TestAccessPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(test_default)
ap->setHighType(dbAccessType::HalfGrid);
ap->setAccess(true, dbDirection::DOWN);
iterm->setAccessPoint(pin, ap);
std::string path = testTmpPath("/results/TestAccessPointDbRW");
std::string path = testTmpPath("results", "TestAccessPointDbRW");
std::ofstream write;
write.exceptions(std::ifstream::failbit | std::ifstream::badbit
| std::ios::eofbit);
Expand Down
2 changes: 1 addition & 1 deletion src/odb/test/cpp/TestJournal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct F_DEFAULT
dbDatabase* db;
dbLib* lib;
dbBlock* block;
std::string journal_path = testTmpPath("/results/db_jounal.eco");
std::string journal_path = testTmpPath("results", "db_jounal.eco");
};
BOOST_FIXTURE_TEST_CASE(test_write, F_DEFAULT)
{
Expand Down
8 changes: 4 additions & 4 deletions src/odb/test/cpp/TestLef58Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ BOOST_AUTO_TEST_CASE(lef58_class)
lefin lefParser(db1, logger, false);

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

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

path = testTmpPath("/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 @@ -49,11 +49,11 @@ BOOST_AUTO_TEST_CASE(test_default)
lefin lefParser(db1, logger, false);
const char* libname = "gscl45nm.lef";

std::string path = testTmpPath("/data/gscl45nm.lef");
std::string path = testTmpPath("data", "gscl45nm.lef");

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

path = testTmpPath("/results/TestLef58PropertiesDbRW");
path = testTmpPath("results", "TestLef58PropertiesDbRW");

std::ofstream write;
write.exceptions(std::ifstream::failbit | std::ifstream::badbit
Expand Down
7 changes: 4 additions & 3 deletions src/odb/test/cpp/helper/env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@
#include "env.h"

#include <stdexcept>
#include <iostream>

namespace odb {

std::string testTmpPath(const std::string& file)
std::string testTmpPath(const std::string& path, const std::string& file)
{
const char* base_dir = std::getenv("BASE_DIR");
if (!base_dir) {
throw std::runtime_error("BASE_DIR environment variable not set");
return std::string(std::getenv("PWD")) + file;
}
return std::string(base_dir) + file;
return std::string(base_dir) + "/" + path + "/" + file;
}

} // namespace odb
2 changes: 1 addition & 1 deletion src/odb/test/cpp/helper/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
#pragma once

namespace odb {
std::string testTmpPath(const std::string& file);
std::string testTmpPath(const std::string& path, const std::string& file);
} // namespace odb
4 changes: 1 addition & 3 deletions src/odb/test/cpp/scan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ set(TEST_LIBS
add_executable(TestScanChain TestScanChain.cpp)
target_link_libraries(TestScanChain ${TEST_LIBS})

gtest_discover_tests(TestScanChain
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
gtest_discover_tests(TestScanChain WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

add_dependencies(build_and_test TestScanChain)
2 changes: 1 addition & 1 deletion src/odb/test/cpp/scan/TestScanChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TestScanChain : public testing::Test
{
db_ = create2LevetDbWithBTerms();
block_ = db_->getChip()->getBlock();
tmp_path_ = testTmpPath("/results/TestScanChain");
tmp_path_ = testTmpPath("results", "TestScanChain");
dft_ = block_->createDft();

std::vector<std::string> instances_names = {"i1", "i2", "i3"};
Expand Down

0 comments on commit 4233e07

Please sign in to comment.