Salome HOME
Fix bug in test on 24 cores CPU test
[modules/kernel.git] / src / LifeCycleCORBA / Test / LifeCycleCORBATest.cxx
index 4f0bd1650411239d99ede9b94ee5e799d7811bd8..e6c0c6af4ace9c6bc1879d188b0ab1c0ca2eec48 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  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
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -26,6 +26,8 @@
 #include "Utils_ORB_INIT.hxx"
 #include "Utils_SINGLETON.hxx"
 #include "Basics_Utils.hxx"
+#include "Basics_DirUtils.hxx"
+#include "utilities.h"
 
 #include <iostream>
 #include <fstream>
 #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
@@ -60,7 +67,7 @@
  */
 // ============================================================================
 
-void 
+void
 LifeCycleCORBATest::setUp()
 {
   LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
@@ -68,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;
@@ -78,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();
 
@@ -104,7 +111,7 @@ LifeCycleCORBATest::setUp()
  */
 // ============================================================================
 
-void 
+void
 LifeCycleCORBATest::tearDown()
 {
 
@@ -261,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
  */
 // ============================================================================
@@ -434,7 +441,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsEmpty()
 
 // ============================================================================
 /*!
- * Check FindOrLoad_Component params = local container 
+ * Check FindOrLoad_Component params = local container
  */
 // ============================================================================
 
@@ -540,7 +547,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_RemoteComputer()
 // ============================================================================
 /*!
  * Check FindOrLoad_Component with params on remote computer
- * params empty except hostname 
+ * params empty except hostname
  */
 // ============================================================================
 
@@ -552,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 =
@@ -590,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";
 
@@ -624,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();
@@ -642,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();