diff --git a/crlcore/src/ccore/openaccess/OpenAccessCommon.h b/crlcore/src/ccore/openaccess/OpenAccessCommon.h index a4d03a65..7aa4a9c0 100644 --- a/crlcore/src/ccore/openaccess/OpenAccessCommon.h +++ b/crlcore/src/ccore/openaccess/OpenAccessCommon.h @@ -1,5 +1,5 @@ // -*-compile-command:"cd ../../../../.. && make"-*- -// Time-stamp: "2010-07-30 16:48:54" - OpenAccessCommon.h +// Time-stamp: "2010-08-02 17:50:42" - OpenAccessCommon.h // x-----------------------------------------------------------------x // | This file is part of the hurricaneAMS Software. | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | @@ -251,6 +251,17 @@ namespace { } } + /** + handling realpath with string intead of char* + */ + inline string realPath(const string& path){ + char* buffer = (char*) calloc(PATH_MAX+1,sizeof(char)); + realpath(path.c_str(), buffer); + string res(buffer); + free(buffer); + return res; + } + /** generate info from library name */ @@ -283,23 +294,28 @@ namespace { return lib; } - inline void createCDS(const pair& infos,const string& path){ - try{ - cerr << "Overwriting cds.lib file begin " << endl; - string cdsPath = path + "/cds.lib"; - oaLibDefList* ldl = oaLibDefList::get( cdsPath.c_str(), 'a'); - assert(ldl); - assert(ldl->isValid()); - if(!oaLibDef::find(ldl, infos.first)) - oaLibDef::create(ldl, infos.first, infos.second.c_str()); - ldl->save(); - ldl->destroy();//claim memory - ldl = NULL; - cerr << "Overwrited cds.lib file end" << endl; - }catch(oaException& e){ - cerr << "ERROR cds: " << e.getMsg() << endl; - exit(-2); - } + inline void createCDS(const pair& infos,const string& path){ + try{ + cerr << "Overwriting cds.lib file begin " << endl; + string cdsPath = path + "/cds.lib"; + oaString oaCDSPath = oaString(cdsPath.c_str()); + oaLibDefList* ldl = oaLibDefList::find(oaCDSPath); + if(!ldl) + ldl = oaLibDefList::get(oaCDSPath, 'a'); + assert(ldl); + assert(ldl->isValid()); + oaLibDef* toAdd = oaLibDef::find(ldl, infos.first); + if(!toAdd) + toAdd = oaLibDef::create(ldl, infos.first, infos.second.c_str()); + ldl->save(); + ldl->destroy();//claim memory + ldl = NULL; + cdsPath.clear(); + cerr << "Overwrited cds.lib file end" << endl; + }catch(oaException& e){ + cerr << "ERROR cds: " << e.getMsg() << endl; + exit(-2); + } } inline oaCell* OADesignToOACell(oaDesign* design){ @@ -623,7 +639,7 @@ namespace { oacDrawingPurposeType, oaBox(boxPin, xform)); } - + inline void MakeStub(oaBlock *block, oaPointArray &pa, oaInt4 endPointXoffset, @@ -631,7 +647,7 @@ namespace { pa[1].x() += endPointXoffset; oaLine::create(block, layerPin->getNumber(), oacDrawingPurposeType, pa); } - + oaString MakeLabel(oaBlock* block, oaTransform& xform, const char* label, @@ -659,12 +675,12 @@ namespace { basic symbol shape to represents block's internal Net. */ oaPin* MakePinSymbol(oaBlock* block, - oaPoint location, - const char* strNameTerm, - oaInt4 stubLength, - oaOrient rotation, - oaLayer* layerPin, - oaLayer* layerText){ + oaPoint location, + const char* strNameTerm, + oaInt4 stubLength, + oaOrient rotation, + oaLayer* layerPin, + oaLayer* layerText){ const oaUInt4 lengthPin(3); const oaUInt4 widthPin(2); const oaBox boxPin( 0, -static_cast(widthPin/2), @@ -718,7 +734,7 @@ namespace { // end_skel // Find the term by name (the strNameTerm arg) and set to the term variable - // for reuse later when the Pin is created for that Term. + // for reuse later when the Pin is created for that Term. oaTerm* term = oaTerm::find(block, oaScalarName(oaNativeNS(),strNameTerm)); // Create for the Term: @@ -779,7 +795,7 @@ namespace { default: MakeStub(block, pa, -stubLength,layerPin); pin = oaPin::create(term, oacTop|oacBottom|oacLeft); - MakeRect(block,xform, + MakeRect(block,xform, -stubLength - (rotation == oacR0 ? lengthPin : 0 ), layerPin)->addToPin(pin); diff --git a/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp b/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp index 92eecb8c..20d93519 100644 --- a/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp +++ b/crlcore/src/ccore/openaccess/OpenAccessDriver.cpp @@ -1,5 +1,5 @@ // -*-compile-command:"cd ../../../../.. && make"-*- -// Time-stamp: "2010-08-02 14:58:55" - OpenAccessDriver.cpp +// Time-stamp: "2010-08-02 16:54:01" - OpenAccessDriver.cpp // x-----------------------------------------------------------------x // | This file is part of the hurricaneAMS Software. | // | Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved | @@ -64,7 +64,7 @@ namespace { Technology* _technology; public: OADriver(const string& path) : - _path(path), + _path(realPath(path)), _oaTech(NULL), _library2OALib(), _cell2OADesign4Netlist(), @@ -96,15 +96,20 @@ namespace { _oaTech->save(); _oaTech->close(); saveDesignsInMap(_cell2OADesign4Netlist); + _cell2OADesign4Netlist.clear(); saveDesignsInMap(_cell2OADesign4Schematic); + _cell2OADesign4Schematic.clear(); saveDesignsInMap(_cell2OADesign4Symbolic); + _cell2OADesign4Symbolic.clear(); saveDesignsInMap(_cell2OADesign4Layout); + _cell2OADesign4Layout.clear(); for (Library2OALibMap::iterator it = _library2OALib.begin(); it != _library2OALib.end(); ++it) { oaLib* lib = it->second; lib->close(); } + _path.clear(); cerr << "ALL SAVED" << endl; } @@ -140,6 +145,7 @@ namespace { #endif // 4) create, update library list file createCDS(infos,_path); + infos.second.clear(); return lib; } diff --git a/crlcore/src/ccore/openaccess/test/Makefile b/crlcore/src/ccore/openaccess/test/Makefile index ab394b35..00a1f886 100644 --- a/crlcore/src/ccore/openaccess/test/Makefile +++ b/crlcore/src/ccore/openaccess/test/Makefile @@ -1,21 +1,30 @@ -all: +TESTDIR= ./testOA +TECHNOFILE= /asim/chams/etc/chams/config.freePDK45.xml + +compile: ./compile.sh -run: - ./x86_64/usr/local/bin/testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml /tmp/testOA 2>&1 | tee err.log +run: compile + ./x86_64/usr/local/bin/testOAWrapper $(TECHNOFILE) $(TESTDIR) 2>&1 | tee $@.log -debug: - gdb -args ./x86_64/usr/local/bin/testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml /tmp/testOA +debug: compile + gdb -args ./x86_64/usr/local/bin/testOAWrapper $(TECHNOFILE) $(TESTDIR) -ddd: - ddd -args ./x86_64/usr/local/bin/testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml /tmp/testOA +ddd: compile + ddd -args ./x86_64/usr/local/bin/testOAWrapper $(TECHNOFILE) $(TESTDIR) -valgrind: - valgrind ./x86_64/usr/local/bin/testOAWrapper /asim/chams/etc/chams/config.freePDK45.xml /tmp/testOA +valgrind_simple: compile + valgrind ./x86_64/usr/local/bin/testOAWrapper $(TECHNOFILE) $(TESTDIR) 2>&1 | tee $@.log -rmtmp: - rm -rf /tmp/* +valgrind_full: compile + valgrind -v --leak-check=full --show-reachable=yes ./x86_64/usr/local/bin/testOAWrapper $(TECHNOFILE) $(TESTDIR) 2>&1 | tee $@.log + +mrproper: clean + rm -rf $(TESTDIR) *.log clean: rm -rf x86_64 + + +.PHONY: clean mrproper valgrind ddd debug run compile diff --git a/crlcore/src/ccore/openaccess/test/src/main.cpp b/crlcore/src/ccore/openaccess/test/src/main.cpp index fbc868e9..87958f00 100755 --- a/crlcore/src/ccore/openaccess/test/src/main.cpp +++ b/crlcore/src/ccore/openaccess/test/src/main.cpp @@ -8,6 +8,7 @@ // x-----------------------------------------------------------------x #include +#include #include using namespace std; @@ -44,7 +45,6 @@ void testCell(Cell* dev,char* pathToTest){ cerr << "Cell not created" << endl; return; } - system((string("mkdir -p ") + string(pathToTest)).c_str()); cerr << "driving GDS" << endl; GdsDriver(dev).save(string(pathToTest) + "/" + getString(dev->getName()) + ".gds"); @@ -57,7 +57,7 @@ void testCell(Cell* dev,char* pathToTest){ } void testAnalog(char* pathToConf,char* pathToTest){ - AnalogEnv::create(pathToConf);//create Database ... + auto_ptr aenv(AnalogEnv::create(pathToConf));//create Database ... cerr << "analog environment loaded and database created" << endl; DataBase* db = DataBase::getDB(); assert(db != NULL); @@ -93,9 +93,8 @@ void testAnalog(char* pathToConf,char* pathToTest){ void testNum(char* pathToConf,char* pathToTest,char* cellName){ cerr << "creating cell from sxlib " << cellName << endl; DataBase* db = DataBase::getDB(); - AllianceFramework* af = AllianceFramework::get(); - Cell* cell = NULL; - cell = af->getCell(cellName, Catalog::State::Views ); + AllianceFramework* af =AllianceFramework::get(); + Cell* cell = af->getCell(cellName, Catalog::State::Views ); cerr << "testing cell from sxlib "<< cellName << endl; testCell(cell,pathToTest); } @@ -202,6 +201,7 @@ int main(int argc,char** argv) { testNum(argv[1],argv[2],"xr2_x4"); testNum(argv[1],argv[2],"zero_x0"); + DataBase::getDB()->destroy(); cerr << "ending normally" << endl; return 0; }