Python Unit Tests
Running tests
For running the python unit tests you will need to install first testtools and unittest-parallel which enables concurrent unit testing
pip3 install testtools
pip3 install unittest-parallel
Then, you can run the unit tests in sequence by running
../unitTests.sh
or in parallel by running
../unitTests.sh parallel
Note: The test cases within each Unit Test run in parallel in both situations
Tests Structure
The directory unitTestsPython includes unit tests for OpenDB Python APIs. Any test file starts with 'Test' followed by the test target.
odbUnitTest.py:
This includes TestCase class which inherits from unittest.TestCase with additional functionalities:
changeAndTest(self,obj,SetterName,GetterName,expectedVal,*args)which is a function for changing a value and testing for the effect of that change where:objis the object to be testedSetterNameis the name of the function to be called for changing a valueGetterNameis the name of the function to be called for testing the effectexpectedValis the expected value for the testing*argsare the arguments passed to theSetterNamefunction
So, in the end, the expected behavior is:
obj.SetterName(*args)
assert(obj.GetterName()==expectedVal)
check(self,obj,GetterName,expectedVal,*args)which tests against expected valuechange(self,obj,SetterName,*args)which changes a value in the objectmain()runs theTestCasein sequential ordermainParallel(Test)runs the passedTestclass in parallel
helper.py:
A set of functions for creating simple db instances to be used for testing. You can find the description of each function in the comments
TestNet.py:
Unit test class for testing dbNet. It inherits from odbUnitTest.TestCase . it consists of
setUp(self)function to be called before each test case. Here, we create the database with the desired chip, block, masters, instances and nets.tearDown(self)function to be called after each test case. Here, we destroy our db.test_*(self)the test cases functions. Their names should start withtestfor the unittest suite to recognize.
TestDestroy.py:
Integration test class for testing the destroy(*args) function on OpenDB.
test_destroy_netdestroying net and testing for the effect on the block,inst, iterms and btermstest_destroy_instdestroying instance and testing for the effect on block, iterms, net, btermstest_destroy_btermdestroying bterm and testing for the effect on block and nettest_destroy_blockdestroying block and testing for the effect on block(parent and child relation), and chiptest_destroy_bpindestroying bpin and testing for the effect on btermtest_create_destroy_wiredestroying wire and test for the effect on nettest_destroy_capnodedestroying capnode and test for the effect on net(node and connected ccsegs)test_destroy_ccsegdestroying ccseg and test for the effect on node,block and nettest_destroy_libdestroying lib and test for the effect on dbtest_destroy_obstructiondestroying obstruction and test for the effect on blocktest_create_regionscreating regions and test for the effect on block and region(parent and child relation)test_destroy_region_childdestroying _ and test for the effect on block and region(parent)test_destroy_region_parentdestroying _ and test for the effect on block
TestBlock.py:
Unit Test for dbBlock
test_findtesting the find function with BTerm, Child, Inst, Net, ITerm, ExtCornerBlock, nonDefaultRule, RegionTesting the ComputeBBox() function through the first call of getBBox:
test_bbox0testing empty block boxtest_bbox1testing block box with Inst placedtest_bbox2testing block box with Inst and BPin placedtest_bbox3testing block box with Inst, BPin and Obstruction placedtest_bbox3testing block box with Inst, BPin, Obstruction and SWire placed
TestBTerm.py:
Unit Test for dbBTerm
test_idletesting for idle disconnectedBTermbehaviortest_connecttesting connect function ofBTermonBTermandNettest_disconnecttesting disconnect function ofBTermonBTermandNet
TestInst.py:
Unit Test for dbInst
test_swap_mastertesting swap master function
TestITerm.py:
Unit Test for dbITerm
test_idletesting for disconnected ITerm without a nettest_connection_from_itermtesting the connect(ITerm,...) and disconnect functions of ITerm and their effect on ITerm and Nettest_connection_from_insttesting the connect(Inst,...) and disconnect functions of ITerm and their effect on ITerm and Net- Testing for getAvgXY() function
test_avgxy_R0testing with default orientation R0test_avgxy_R90testing with different orientation R90 for transformation
Problems Found In Testing
- multiple core dumps that leads to aborting the process:
- dbNet.get1st*() (when nothing on top of the list)
- childRegion.getParent() (after destroying the parent region)
- Implementation of ComputeBBox() is flawed and needs to be reconsidered