added test cases and bug fixes

This commit is contained in:
osamahammad21
2020-10-04 03:09:53 +02:00
parent 42832c6002
commit 20247d6afd
7 changed files with 7290 additions and 1 deletions

View File

@@ -10,4 +10,4 @@ link_libraries(opendb
tcl
)
include_directories(${PROJECT_SOURCE_DIR}/include/opendb)
add_executable( test1 ${PROJECT_SOURCE_DIR}/tests/cpp/test.cpp )
add_executable( TestGeom ${PROJECT_SOURCE_DIR}/tests/cpp/TestGeom.cpp )

85
tests/cpp/TestGeom.cpp Normal file
View File

@@ -0,0 +1,85 @@
#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
#include "db.h"
#include <iostream>
using namespace odb;
BOOST_AUTO_TEST_SUITE( test_suite )
BOOST_AUTO_TEST_CASE( test_oct )
{
Oct* oct = new Oct;
oct->init(Point(0,0),Point(400,400),40);
BOOST_ASSERT(oct->getCenterHigh()==Point(400,400));
BOOST_ASSERT(oct->getCenterLow()==Point(0,0));
BOOST_ASSERT(oct->getWidth()==40);
BOOST_ASSERT(oct->xMin()==-20);
BOOST_ASSERT(oct->xMax()==420);
BOOST_ASSERT(oct->yMin()==-20);
BOOST_ASSERT(oct->yMax()==420);
BOOST_ASSERT(oct->dx()==440);
BOOST_ASSERT(oct->dy()==440);
BOOST_ASSERT(oct->getDir()==Oct::OCT_DIR::RIGHT);
oct->init(Point(0,0),Point(-400,400),40);
BOOST_ASSERT(oct->getDir()==Oct::OCT_DIR::LEFT);
oct->init(Point(0,0),Point(-400,-400),40);
BOOST_ASSERT(oct->getDir()==Oct::OCT_DIR::RIGHT);
oct->init(Point(0,0),Point(400,-400),40);
BOOST_ASSERT(oct->getDir()==Oct::OCT_DIR::LEFT);
}
BOOST_AUTO_TEST_CASE( test_geom_shape )
{
Oct oct(Point(0,0),Point(400,400),40);
GeomShape* shape = &oct;
BOOST_ASSERT(shape->xMin()==-20);
BOOST_ASSERT(shape->xMax()==420);
BOOST_ASSERT(shape->yMin()==-20);
BOOST_ASSERT(shape->yMax()==420);
BOOST_ASSERT(shape->dx()==440);
BOOST_ASSERT(shape->dy()==440);
//OCT POINTS
std::vector<Point> points = shape->getPoints();
BOOST_ASSERT(points.size()==9);
BOOST_ASSERT(points[0]==Point(-9,-20));
BOOST_ASSERT(points[1]==Point(9,-20));
BOOST_ASSERT(points[2]==Point(420,391));
BOOST_ASSERT(points[3]==Point(420,409));
BOOST_ASSERT(points[4]==Point(409,420));
BOOST_ASSERT(points[5]==Point(391,420));
BOOST_ASSERT(points[6]==Point(-20,9));
BOOST_ASSERT(points[7]==Point(-20,-9));
BOOST_ASSERT(points[8]==Point(-9,-20));
//RECT
Rect rect(Point(0,0),Point(400,400));
shape = &rect;
BOOST_ASSERT(shape->xMin()==0);
BOOST_ASSERT(shape->xMax()==400);
BOOST_ASSERT(shape->yMin()==0);
BOOST_ASSERT(shape->yMax()==400);
BOOST_ASSERT(shape->dx()==400);
BOOST_ASSERT(shape->dy()==400);
//RECT POINTS
points = shape->getPoints();
BOOST_ASSERT(points.size()==5);
BOOST_ASSERT(points[0]==Point(0,0));
BOOST_ASSERT(points[1]==Point(400,0));
BOOST_ASSERT(points[2]==Point(400,400));
BOOST_ASSERT(points[3]==Point(0,400));
BOOST_ASSERT(points[4]==Point(0,0));
}
BOOST_AUTO_TEST_CASE( test_rect_merge )
{
Rect rect(Point(0,0),Point(100,50));
Oct oct(Point(100,50),Point(200,200),80);
rect.merge((GeomShape*)&oct);
BOOST_ASSERT(rect.xMin()==0);
BOOST_ASSERT(rect.xMax()==240);
BOOST_ASSERT(rect.yMin()==0);
BOOST_ASSERT(rect.yMax()==240);
BOOST_ASSERT(rect.dx()==240);
BOOST_ASSERT(rect.dy()==240);
}
BOOST_AUTO_TEST_SUITE_END()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
import opendbpy as odb
import os
current_dir = os.path.dirname(os.path.realpath(__file__))
tests_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
opendb_dir = os.path.abspath(os.path.join(tests_dir, os.pardir))
data_dir = os.path.join(tests_dir, "data")
db = odb.dbDatabase.create()
odb.read_lef(db, os.path.join(data_dir, "Nangate45","NangateOpenCellLibrary.mod.lef"))
odb.read_lef(db, os.path.join(data_dir, "ICEWall","dummy_pads.lef"))
odb.read_def(db, os.path.join(data_dir, "ICEWall","octilinear.def"))
chip = db.getChip()
if chip == None:
exit("Read DEF Failed")
result = odb.write_def(chip.getBlock(), os.path.join(opendb_dir, "build","generated_octilinear.def"))
assert result==1, "DEF not written"
db_file = os.path.join(opendb_dir, "build","export_oct.db")
export_result = odb.write_db(db, db_file)
if export_result!=1:
exit("Export DB Failed")
new_db = odb.dbDatabase.create()
new_db = odb.read_db(new_db, db_file)
if odb.db_diff(db, new_db):
exit("Error: Difference found between exported and imported DB")

6
tests/regression-cpp.sh Normal file
View File

@@ -0,0 +1,6 @@
set -e
BASE_DIR=$(dirname $0)
$BASE_DIR/../build/tests/cpp/TestGeom

View File

@@ -78,6 +78,11 @@ python3 $BASE_DIR/python/15-row_settings_test.py
echo "SUCCESS!"
echo ""
echo "[16] Database def octilinear read write test"
python3 $BASE_DIR/python/16-db-read-write-octilinear-def_test.py
echo "SUCCESS!"
echo ""
echo "[17] Database read/write test"
python3 $BASE_DIR/python/17-db_read-write_test.py
echo "SUCCESS!"