Salome HOME
Fix bug in test on 24 cores CPU test
[modules/kernel.git] / src / LifeCycleCORBA / Test / LifeCycleCORBATest.cxx
index 6381ab2ab62ac3985309a81dc200f7bfb3ead6f1..e6c0c6af4ace9c6bc1879d188b0ab1c0ca2eec48 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -26,6 +26,7 @@
 #include "Utils_ORB_INIT.hxx"
 #include "Utils_SINGLETON.hxx"
 #include "Basics_Utils.hxx"
+#include "Basics_DirUtils.hxx"
 #include "utilities.h"
 
 #include <iostream>
 #endif
 #ifdef WIN32
 #define setenv Kernel_Utils::setenv
-#endif 
+#endif
 
-#define TRACEFILE "/tmp/traceUnitTest.log"
+std::string
+LifeCycleCORBATest::_getTraceFileName()
+{
+  std::string dir = Kernel_Utils::GetTmpDir();
+  return dir + "traceUnitTest-LifeCycleCORBATest.log";
+}
 
 // ============================================================================
 /*!
- * Set Trace mecanism
+ * Set Trace mechanism
  * - delete preexisting trace classes if any
  * - set trace on file
  * Get or initialize the orb
@@ -61,7 +67,7 @@
  */
 // ============================================================================
 
-void 
+void
 LifeCycleCORBATest::setUp()
 {
   LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
@@ -69,7 +75,7 @@ LifeCycleCORBATest::setUp()
   bp1->deleteInstance(bp1);
 
   // --- trace on file
-  const char *theFileName = TRACEFILE;
+  std::string theFileName = _getTraceFileName();
 
   std::string s = "file:";
   s += theFileName;
@@ -79,7 +85,7 @@ LifeCycleCORBATest::setUp()
 
   std::ofstream traceFile;
   //  traceFile.open(theFileName, std::ios::out | std::ios::trunc);
-  traceFile.open(theFileName, std::ios::out | std::ios::app);
+  traceFile.open(theFileName.c_str(), std::ios::out | std::ios::app);
   CPPUNIT_ASSERT(traceFile); // file created empty, then closed
   traceFile.close();
 
@@ -105,7 +111,7 @@ LifeCycleCORBATest::setUp()
  */
 // ============================================================================
 
-void 
+void
 LifeCycleCORBATest::tearDown()
 {
 
@@ -262,7 +268,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_PythonSameInstance()
 /*!
  * Check FindOrLoad_Component with a component name not in catalog.
  * See list of catalog given to module catalog server.
- * Here, we work with KERNEL_SRC/resources/KERNELCatalog.xml that contains 
+ * Here, we work with KERNEL_SRC/resources/KERNELCatalog.xml that contains
  * only KERNEL, SalomeTestComponent and SALOME_TestComponentPy
  */
 // ============================================================================
@@ -435,7 +441,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsEmpty()
 
 // ============================================================================
 /*!
- * Check FindOrLoad_Component params = local container 
+ * Check FindOrLoad_Component params = local container
  */
 // ============================================================================
 
@@ -541,7 +547,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_RemoteComputer()
 // ============================================================================
 /*!
  * Check FindOrLoad_Component with params on remote computer
- * params empty except hostname 
+ * params empty except hostname
  */
 // ============================================================================
 
@@ -553,7 +559,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer()
   std::string remoteHost = GetRemoteHost();
 
   Engines::ContainerParameters params;
-  _LCC.preSet(params); 
+  _LCC.preSet(params);
   params.resource_params.hostname = remoteHost.c_str();
 
   Engines::EngineComponent_var mycompo1 =
@@ -591,7 +597,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsRemoteComputer2()
   std::string remoteHost = GetRemoteHost();
 
   Engines::ContainerParameters params;
-  _LCC.preSet(params); 
+  _LCC.preSet(params);
   params.resource_params.hostname = remoteHost.c_str();
   params.container_name = "anotherContainer";
 
@@ -625,7 +631,11 @@ void  LifeCycleCORBATest::testgetLocalFile_localComputer()
 {
   SALOME_LifeCycleCORBA _LCC(&_NS);
   std::string origFileName = getenv("KERNEL_ROOT_DIR");
+#ifdef __APPLE__
+  origFileName += "/lib/salome/libSalomeLifeCycleCORBA.dylib";
+#else
   origFileName += "/lib/salome/libSalomeLifeCycleCORBA.so.0.0.0";
+#endif
   SALOME_FileTransferCORBA transfer( Kernel_Utils::GetHostname(),
                                      origFileName);
   std::string local = transfer.getLocalFile();
@@ -643,7 +653,11 @@ void  LifeCycleCORBATest::testgetLocalFile_remoteComputer()
 {
   SALOME_LifeCycleCORBA _LCC(&_NS);
   std::string origFileName = getenv("KERNEL_ROOT_DIR");
+#ifdef __APPLE__
+  origFileName += "/lib/salome/libSalomeContainer.dylib";
+#else
   origFileName += "/lib/salome/libSalomeContainer.so.0.0.0";
+#endif
   SALOME_FileTransferCORBA transfer( GetRemoteHost(),
                                      origFileName);
   std::string local = transfer.getLocalFile();