]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Fix make distcheck step problems
authorvsr <vsr@opencascade.com>
Wed, 3 Jun 2009 07:01:35 +0000 (07:01 +0000)
committervsr <vsr@opencascade.com>
Wed, 3 Jun 2009 07:01:35 +0000 (07:01 +0000)
src/ParaMEDMEM/Test/ParaMEDMEMTest.cxx
src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx
src/ParaMEDMEM/Test/ParaMEDMEMTest_IntersectionDEC.cxx
src/ParaMEDMEM/Test/ParaMEDMEMTest_MEDLoader.cxx
src/ParaMEDMEM/Test/ParaMEDMEMTest_NonCoincidentDEC.cxx
src/ParaMEDMEM/Test/ParaMEDMEMTest_StructuredCoincidentDEC.cxx

index f5c43bebdbce2e7f04ed0ceab3d8d871d0241881..0be7872afeb34f7031a3cd88d0b0a8e2f5b0d9c4 100644 (file)
 
 #include <sstream>
 #include <cmath>
+#include <list>
+#include <stdexcept>
 
-using namespace std;
+//================================================================================
+/*!
+ * \brief Get path to the resources file.
+ *
+ * When running 'make test' source file is taken from MED_SRC/resources folder.
+ * Otherwise, file is searched in ${MED_ROOT_DIR}/share/salome/resources/med folder.
+ * 
+ * \param filename name of the resource file (should not include a path)
+ * \return full path to the resource file
+ */
+//================================================================================
+
+std::string ParaMEDMEMTest::getResourceFile( const std::string& filename )
+{
+  std::string resourceFile = "";
 
+  if ( getenv("top_srcdir") ) {
+    // we are in 'make check' step
+    resourceFile = getenv("top_srcdir");
+    resourceFile += "/resources/";
+  }
+  else if ( getenv("MED_ROOT_DIR") ) {
+    // use MED_ROOT_DIR env.var
+    resourceFile = getenv("MED_ROOT_DIR");
+    resourceFile += "/share/salome/resources/med/";
+  }
+  resourceFile += filename;
+  return resourceFile;
+}
+
+
+//================================================================================
+/*!
+ * \brief Returns writable temporary directory
+ * \return full path to the temporary directory
+ */
+//================================================================================
+
+std::string ParaMEDMEMTest::getTmpDirectory()
+{
+  std::string path;
+
+  std::list<std::string> dirs;
+  if ( getenv("TMP") )    dirs.push_back( getenv("TMP" ));
+  if ( getenv("TMPDIR") ) dirs.push_back( getenv("TMPDIR" ));
+  dirs.push_back( "/tmp" );
+
+  std::string tmpd = "";
+  for ( std::list<std::string>::iterator dir = dirs.begin(); dir != dirs.end() && tmpd == "" ; ++dir ) {
+    if ( access( dir->data(), W_OK ) == 0 ) {
+      tmpd = dir->data();
+    }
+  }
+
+  if ( tmpd == "" )
+    throw std::runtime_error("Can't find writable temporary directory. Set TMP environment variable");
+
+  return tmpd;
+}
+
+//================================================================================
+/*!
+ * \brief Creates a copy of source file (if source file is specified) 
+ * in the temporary directory and returns a path to the tmp file
+ *
+ * \param tmpfile name of the temporary file (without path)
+ * \param srcfile source file
+ * \return path to the temporary file
+ */
+//================================================================================
+std::string ParaMEDMEMTest::makeTmpFile( const std::string& tmpfile, const std::string& srcfile )
+{
+  std::string tmpf = getTmpDirectory() + "/" + tmpfile;
+  if ( srcfile != "" ) {
+    std::string cmd  = "cp " + srcfile + " " + tmpf + " ; chmod +w " + tmpf;
+    system( cmd.c_str() );
+  }
+  return tmpf;
+}
 
 
 /*!
@@ -32,7 +111,7 @@ using namespace std;
  */
 ParaMEDMEMTest_TmpFilesRemover::~ParaMEDMEMTest_TmpFilesRemover()
 {
-  set<string>::iterator it = myTmpFiles.begin();
+  std::set<std::string>::iterator it = myTmpFiles.begin();
   for (; it != myTmpFiles.end(); it++) {
     if (access((*it).data(), F_OK) == 0)
       remove((*it).data());
@@ -41,7 +120,7 @@ ParaMEDMEMTest_TmpFilesRemover::~ParaMEDMEMTest_TmpFilesRemover()
   //cout << "~ParaMEDMEMTest_TmpFilesRemover()" << endl;
 }
 
-bool ParaMEDMEMTest_TmpFilesRemover::Register(const string theTmpFile)
+bool ParaMEDMEMTest_TmpFilesRemover::Register(const std::string theTmpFile)
 {
   return (myTmpFiles.insert(theTmpFile)).second;
 }
index 77d95ecfc06cf390b6128816813868d8c4aba215..4d94f7f861d5acd8ec7372091cf30076f41f1eb9 100644 (file)
@@ -111,6 +111,11 @@ public:
   void testMEDLoaderPolyhedronRead();
   void testMEDLoaderWrite1();
   void testMEDLoaderPolygonWrite();
+
+  std::string getResourceFile( const std::string& );
+  std::string getTmpDirectory();
+  std::string makeTmpFile( const std::string&, const std::string& = "" );
+
 private:
   void testNonCoincidentDEC(const std::string& filename1, 
                             const std::string& meshname1, 
index ffc0183938e6e2fdda7cf44931d922f57ebf0381..40b1c05187f4689ed966b1a33ad692960d96ccc3 100644 (file)
@@ -108,14 +108,10 @@ void ParaMEDMEMTest::testIntersectionDEC_2D_(const char *srcMeth, const char *ta
   ParaMEDMEM::ParaFIELD* parafield;
   ICoCo::Field* icocofield ;
   
-  string data_dir                   = getenv("MED_ROOT_DIR");
-  string tmp_dir                    = getenv("TMP");
-  if (tmp_dir == "")
-    tmp_dir = "/tmp";
-  string filename_xml1              = data_dir + "/share/salome/resources/med/square1_split";
-  string filename_xml2              = data_dir + "/share/salome/resources/med/square2_split"; 
-  string filename_seq_wr            = tmp_dir + "/";
-  string filename_seq_med           = tmp_dir + "/myWrField_seq_pointe221.med";
+  string filename_xml1              = getResourceFile("square1_split");
+  string filename_xml2              = getResourceFile("square2_split");
+  //string filename_seq_wr            = makeTmpFile("");
+  //string filename_seq_med           = makeTmpFile("myWrField_seq_pointe221.med");
   
   // To remove tmp files from disk
   ParaMEDMEMTest_TmpFilesRemover aRemover;
@@ -318,14 +314,13 @@ void ParaMEDMEMTest::testIntersectionDEC_3D_(const char *srcMeth, const char *ta
   ParaMEDMEM::ParaFIELD* parafield;
   ICoCo::Field* icocofield ;
   
-  string data_dir                   = getenv("MED_ROOT_DIR");
   string tmp_dir                    = getenv("TMP");
   if (tmp_dir == "")
     tmp_dir = "/tmp";
-  string filename_xml1              = data_dir + "/share/salome/resources/med/Mesh3D_10_2d";
-  string filename_xml2              = data_dir + "/share/salome/resources/med/Mesh3D_11"; 
-  string filename_seq_wr            = tmp_dir + "/";
-  string filename_seq_med           = tmp_dir + "/myWrField_seq_pointe221.med";
+  string filename_xml1              = getResourceFile("Mesh3D_10_2d");
+  string filename_xml2              = getResourceFile("Mesh3D_11");
+  //string filename_seq_wr            = makeTmpFile("");
+  //string filename_seq_med           = makeTmpFile("myWrField_seq_pointe221.med");
   
   // To remove tmp files from disk
   ParaMEDMEMTest_TmpFilesRemover aRemover;
@@ -994,14 +989,13 @@ void ParaMEDMEMTest::testAsynchronousIntersectionDEC_2D(double dtA, double tmaxA
   double * value ;
   ICoCo::Field* icocofield ;
 
-  string data_dir                   = getenv("MED_ROOT_DIR");
   string tmp_dir                    = getenv("TMP");
   if (tmp_dir == "")
     tmp_dir = "/tmp";
-  string filename_xml1              = data_dir + "/share/salome/resources/med/square1_split";
-  string filename_xml2              = data_dir + "/share/salome/resources/med/square2_split"
-  string filename_seq_wr            = tmp_dir + "/";
-  string filename_seq_med           = tmp_dir + "/myWrField_seq_pointe221.med";
+  string filename_xml1              = getResourceFile("square1_split");
+  string filename_xml2              = getResourceFile("square2_split")
+  //string filename_seq_wr            = makeTmpFile("");
+  //string filename_seq_med           = makeTmpFile("myWrField_seq_pointe221.med");
   
   // To remove tmp files from disk
   ParaMEDMEMTest_TmpFilesRemover aRemover;
index 12afe8f4f21618627a5f502a3da8719b8389fbd2..fd27f03648d627c90bb0472a9d4c783cf5e09839 100644 (file)
@@ -15,12 +15,10 @@ using namespace ParaMEDMEM;
 
 void ParaMEDMEMTest::testMEDLoaderRead1()
 {
-  string medRootDir=getenv("MED_ROOT_DIR");
-  medRootDir+="/share/salome/resources/med/pointe_import22.med";
-  const char *fileName=medRootDir.c_str();
-  vector<string> meshNames=MEDLoader::GetMeshNames(fileName);
+  string fileName=getResourceFile("pointe_import22.med");
+  vector<string> meshNames=MEDLoader::GetMeshNames(fileName.c_str());
   CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
-  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),0);
+  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0);
   CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
   CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
   CPPUNIT_ASSERT_EQUAL(16,mesh->getNumberOfCells());
@@ -38,13 +36,13 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
   mesh->decrRef();
   //
-  vector<string> families=MEDLoader::GetMeshFamilyNames(fileName,meshNames[0].c_str());
+  vector<string> families=MEDLoader::GetMeshFamilyNames(fileName.c_str(),meshNames[0].c_str());
   CPPUNIT_ASSERT_EQUAL(8,(int)families.size());
   CPPUNIT_ASSERT(families[2]=="FAMILLE_ELEMENT_3");
   //
   vector<string> families2;
   families2.push_back(families[2]);
-  mesh=MEDLoader::ReadUMeshFromFamilies(fileName,meshNames[0].c_str(),0,families2);
+  mesh=MEDLoader::ReadUMeshFromFamilies(fileName.c_str(),meshNames[0].c_str(),0,families2);
   CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
   CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
   CPPUNIT_ASSERT_EQUAL(2,mesh->getNumberOfCells());
@@ -58,7 +56,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
   mesh->decrRef();
   //
-  vector<string> groups=MEDLoader::GetMeshGroupsNames(fileName,meshNames[0].c_str());
+  vector<string> groups=MEDLoader::GetMeshGroupsNames(fileName.c_str(),meshNames[0].c_str());
   CPPUNIT_ASSERT_EQUAL(5,(int)groups.size());
   CPPUNIT_ASSERT(groups[0]=="groupe1");
   CPPUNIT_ASSERT(groups[1]=="groupe2");
@@ -67,7 +65,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT(groups[4]=="groupe5");
   vector<string> groups2;
   groups2.push_back(groups[0]);
-  mesh=MEDLoader::ReadUMeshFromGroups(fileName,meshNames[0].c_str(),0,groups2);
+  mesh=MEDLoader::ReadUMeshFromGroups(fileName.c_str(),meshNames[0].c_str(),0,groups2);
   CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
   CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
   CPPUNIT_ASSERT_EQUAL(7,mesh->getNumberOfCells());
@@ -82,20 +80,20 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
   mesh->decrRef();
   //
-  std::vector<std::string> fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName,meshNames[0].c_str());
+  std::vector<std::string> fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName.c_str(),meshNames[0].c_str());
   CPPUNIT_ASSERT_EQUAL(2,(int)fieldsName.size());
   CPPUNIT_ASSERT(fieldsName[0]=="fieldcelldoublescalar");
   CPPUNIT_ASSERT(fieldsName[1]=="fieldcelldoublevector");
-  std::vector<std::pair<int,int> > its0=MEDLoader::GetCellFieldIterations(fileName,fieldsName[0].c_str());
+  std::vector<std::pair<int,int> > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),fieldsName[0].c_str());
   CPPUNIT_ASSERT_EQUAL(1,(int)its0.size());
   CPPUNIT_ASSERT_EQUAL(-1,its0[0].first);
   CPPUNIT_ASSERT_EQUAL(-1,its0[0].second);
-  std::vector<std::pair<int,int> > its1=MEDLoader::GetCellFieldIterations(fileName,fieldsName[1].c_str());
+  std::vector<std::pair<int,int> > its1=MEDLoader::GetCellFieldIterations(fileName.c_str(),fieldsName[1].c_str());
   CPPUNIT_ASSERT_EQUAL(1,(int)its1.size());
   CPPUNIT_ASSERT_EQUAL(-1,its1[0].first);
   CPPUNIT_ASSERT_EQUAL(-1,its1[0].second);
   //
-  MEDCouplingFieldDouble *field0=MEDLoader::ReadFieldDoubleCell(fileName,meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
+  MEDCouplingFieldDouble *field0=MEDLoader::ReadFieldDoubleCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
   field0->checkCoherency();
   CPPUNIT_ASSERT(field0->getName()==fieldsName[0]);
   CPPUNIT_ASSERT_EQUAL(1,field0->getNumberOfComponents());
@@ -124,7 +122,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
   field0->decrRef();
   //
-  MEDCouplingFieldDouble *field1=MEDLoader::ReadFieldDoubleCell(fileName,meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second);
+  MEDCouplingFieldDouble *field1=MEDLoader::ReadFieldDoubleCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second);
   field1->checkCoherency();
   CPPUNIT_ASSERT(field1->getName()==fieldsName[1]);
   CPPUNIT_ASSERT_EQUAL(3,field1->getNumberOfComponents());
@@ -153,11 +151,11 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
   field1->decrRef();
   //fields on nodes
-  std::vector<std::string> fieldsNameNode=MEDLoader::GetNodeFieldNamesOnMesh(fileName,meshNames[0].c_str());
+  std::vector<std::string> fieldsNameNode=MEDLoader::GetNodeFieldNamesOnMesh(fileName.c_str(),meshNames[0].c_str());
   CPPUNIT_ASSERT_EQUAL(2,(int)fieldsNameNode.size());
   CPPUNIT_ASSERT(fieldsNameNode[0]=="fieldnodedouble");
   CPPUNIT_ASSERT(fieldsNameNode[1]=="fieldnodeint");
-  std::vector<std::pair<int,int> > its0Node=MEDLoader::GetNodeFieldIterations(fileName,fieldsNameNode[0].c_str());
+  std::vector<std::pair<int,int> > its0Node=MEDLoader::GetNodeFieldIterations(fileName.c_str(),fieldsNameNode[0].c_str());
   CPPUNIT_ASSERT_EQUAL(3,(int)its0Node.size());
   CPPUNIT_ASSERT_EQUAL(1,its0Node[0].first);
   CPPUNIT_ASSERT_EQUAL(-1,its0Node[0].second);
@@ -165,7 +163,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_EQUAL(-1,its0Node[1].second);
   CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].first);//strange but like that
   CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].second);
-  MEDCouplingFieldDouble *field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName,meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second);
+  MEDCouplingFieldDouble *field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second);
   field0Nodes->checkCoherency();
   CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
   CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
@@ -179,7 +177,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT(constMesh);
   field0Nodes->decrRef();
   //
-  field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName,meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[1].first,its0Node[1].second);
+  field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[1].first,its0Node[1].second);
   field0Nodes->checkCoherency();
   CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
   CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
@@ -207,7 +205,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
   field0Nodes->decrRef();
   //
-  field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName,meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second);
+  field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second);
   field0Nodes->checkCoherency();
   CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
   CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
@@ -238,13 +236,11 @@ void ParaMEDMEMTest::testMEDLoaderRead1()
 
 void ParaMEDMEMTest::testMEDLoaderPolygonRead()
 {
-  string medRootDir=getenv("MED_ROOT_DIR");
-  medRootDir+="/share/salome/resources/med/polygones.med";
-  const char *fileName=medRootDir.c_str();
-  vector<string> meshNames=MEDLoader::GetMeshNames(fileName);
+  string fileName=getResourceFile("polygones.med");
+  vector<string> meshNames=MEDLoader::GetMeshNames(fileName.c_str());
   CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
   CPPUNIT_ASSERT(meshNames[0]=="Bord");
-  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),0);
+  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0);
   mesh->checkCoherency();
   CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
   CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
@@ -266,14 +262,14 @@ void ParaMEDMEMTest::testMEDLoaderPolygonRead()
   CPPUNIT_ASSERT_EQUAL(725943,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+539,0));
   mesh->decrRef();
   //
-  std::vector<std::string> fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName,meshNames[0].c_str());
+  std::vector<std::string> fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName.c_str(),meshNames[0].c_str());
   CPPUNIT_ASSERT_EQUAL(3,(int)fieldsName.size());
   CPPUNIT_ASSERT(fieldsName[0]=="bord_:_distorsion");
   CPPUNIT_ASSERT(fieldsName[1]=="bord_:_familles");
   CPPUNIT_ASSERT(fieldsName[2]=="bord_:_non-ortho");
-  std::vector<std::pair<int,int> > its0=MEDLoader::GetCellFieldIterations(fileName,fieldsName[0].c_str());
+  std::vector<std::pair<int,int> > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),fieldsName[0].c_str());
   CPPUNIT_ASSERT_EQUAL(1,(int)its0.size());
-  MEDCouplingFieldDouble *field=MEDLoader::ReadFieldDoubleCell(fileName,meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
+  MEDCouplingFieldDouble *field=MEDLoader::ReadFieldDoubleCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
   field->checkCoherency();
   CPPUNIT_ASSERT(field->getName()==fieldsName[0]);
   CPPUNIT_ASSERT_EQUAL(1,field->getNumberOfComponents());
@@ -303,13 +299,11 @@ void ParaMEDMEMTest::testMEDLoaderPolygonRead()
 
 void ParaMEDMEMTest::testMEDLoaderPolyhedronRead()
 {
-  string medRootDir=getenv("MED_ROOT_DIR");
-  medRootDir+="/share/salome/resources/med/poly3D.med";
-  const char *fileName=medRootDir.c_str();
-  vector<string> meshNames=MEDLoader::GetMeshNames(fileName);
+  string fileName=getResourceFile("poly3D.med");
+  vector<string> meshNames=MEDLoader::GetMeshNames(fileName.c_str());
   CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
   CPPUNIT_ASSERT(meshNames[0]=="poly3D");
-  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),0);
+  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0);
   mesh->checkCoherency();
   CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
   CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
@@ -325,7 +319,7 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead()
   CPPUNIT_ASSERT_EQUAL(155,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+4,0));
   mesh->decrRef();
   //
-  mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),-1);
+  mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),-1);
   mesh->checkCoherency();
   CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
   CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
@@ -343,7 +337,7 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead()
   CPPUNIT_ASSERT_EQUAL(619,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+83,0));
   mesh->decrRef();
   //
-  vector<string> families=MEDLoader::GetMeshFamilyNames(fileName,meshNames[0].c_str());
+  vector<string> families=MEDLoader::GetMeshFamilyNames(fileName.c_str(),meshNames[0].c_str());
   CPPUNIT_ASSERT_EQUAL(4,(int)families.size());
   CPPUNIT_ASSERT(families[0]=="FAMILLE_FACE_POLYGONS3");
   CPPUNIT_ASSERT(families[1]=="FAMILLE_FACE_QUAD41");
@@ -351,7 +345,7 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead()
   CPPUNIT_ASSERT(families[3]=="FAMILLE_ZERO");
   vector<string> families2;
   families2.push_back(families[0]);
-  mesh=MEDLoader::ReadUMeshFromFamilies(fileName,meshNames[0].c_str(),-1,families2);
+  mesh=MEDLoader::ReadUMeshFromFamilies(fileName.c_str(),meshNames[0].c_str(),-1,families2);
   mesh->checkCoherency();
   CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
   CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
@@ -364,7 +358,7 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead()
   CPPUNIT_ASSERT_EQUAL(117,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+19,0));
   mesh->decrRef();
   //
-  mesh=MEDLoader::ReadUMeshFromFamilies(fileName,meshNames[0].c_str(),0,families2);
+  mesh=MEDLoader::ReadUMeshFromFamilies(fileName.c_str(),meshNames[0].c_str(),0,families2);
   CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
   CPPUNIT_ASSERT_EQUAL(0,mesh->getNumberOfCells());
   CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
@@ -376,8 +370,7 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead()
 void ParaMEDMEMTest::testMEDLoaderWrite1()
 {
   const char meshName[]="MEDLoaderWrite1";
-  string tmpRootDir=getenv("TMP");
-  string outFileName=tmpRootDir+"/toto22137.med";
+  string outFileName=makeTmpFile("toto22137.med");
   double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
   int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
@@ -429,16 +422,13 @@ void ParaMEDMEMTest::testMEDLoaderWrite1()
 
 void ParaMEDMEMTest::testMEDLoaderPolygonWrite()
 {
-  string medRootDir=getenv("MED_ROOT_DIR");
-  medRootDir+="/share/salome/resources/med/polygones.med";
-  const char *fileName=medRootDir.c_str();
-  vector<string> meshNames=MEDLoader::GetMeshNames(fileName);
+  string fileName=getResourceFile("polygones.med");
+  vector<string> meshNames=MEDLoader::GetMeshNames(fileName.c_str());
   CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
   CPPUNIT_ASSERT(meshNames[0]=="Bord");
-  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),0);
+  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0);
   mesh->checkCoherency();
-  string tmpRootDir=getenv("TMP");
-  string outFileName=tmpRootDir+"/toto22138.med";
+  string outFileName=makeTmpFile("toto22138.med");
   MEDLoader::writeUMesh(outFileName.c_str(),mesh);
   //
   MEDCouplingUMesh *mesh2=MEDLoader::ReadUMeshFromFile(outFileName.c_str(),meshNames[0].c_str(),0);
index 743d91b49785fea03d0ffe29612e0cdf469e2663..9f2ffe73561ead71afe2816aec7b70082b40a78e 100644 (file)
@@ -129,14 +129,10 @@ void ParaMEDMEMTest::testNonCoincidentDEC(const string& filename1,
   ParaMEDMEM::ParaMESH* paramesh;
   ParaMEDMEM::ParaFIELD* parafield;
   
-  string data_dir                   = getenv("MED_ROOT_DIR") + "/share/salome/resources/med/";
-  string tmp_dir                    = getenv("TMP");
-  if (tmp_dir == "")
-    tmp_dir = "/tmp";
-  string filename_xml1              = data_dir + filename1;
-  string filename_xml2              = data_dir + filename2; 
-  string filename_seq_wr            = tmp_dir + "/";
-  string filename_seq_med           = tmp_dir + "/myWrField_seq_pointe221.med";
+  string filename_xml1              = getResourceFile(filename1);
+  string filename_xml2              = getResourceFile(filename2); 
+  //string filename_seq_wr            = makeTmpFile("");
+  //string filename_seq_med           = makeTmpFile("myWrField_seq_pointe221.med");
   
   // To remove tmp files from disk
   ParaMEDMEMTest_TmpFilesRemover aRemover;
index 69a8a307ef1ed3ddbb537991f627ca410f84f095..8305eb9db14108e4f712c1318581cd8d9e21239d 100644 (file)
@@ -74,15 +74,10 @@ void ParaMEDMEMTest::testStructuredCoincidentDEC() {
   ParaMEDMEM::ParaMESH* paramesh;
   ParaMEDMEM::ParaFIELD* parafield;
 
-  string data_dir = getenv("MED_ROOT_DIR");
-  string tmp_dir = getenv("TMP");
-  if (tmp_dir == "")
-    tmp_dir = "/tmp";
-  string filename_xml1 = data_dir
-    + "/share/salome/resources/med/square1_split";
-  string filename_2 = data_dir + "/share/salome/resources/med/square1.med";
-  string filename_seq_wr = tmp_dir + "/";
-  string filename_seq_med = tmp_dir + "/myWrField_seq_pointe221.med";
+  string filename_xml1 = getResourceFile("square1_split");
+  string filename_2    = getResourceFile("square1.med");
+  //string filename_seq_wr  = makeTmpFile("");
+  //string filename_seq_med = makeTmpFile("myWrField_seq_pointe221.med");
 
   // To remove tmp files from disk
   ParaMEDMEMTest_TmpFilesRemover aRemover;