Salome HOME
Management of :
[modules/kernel.git] / src / Utils / Test / UtilsTest.cxx
index aa6f9e302d706389c8ab3c19b4b8e28010707132..8a3d1dab2eb1ec78b1223fd1b0d6d493efa982ae 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  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
 #include <cstdlib>
 #include "Utils_SALOME_Exception.hxx"
 #include "Basics_Utils.hxx"
+#include "Basics_DirUtils.hxx"
 #include "utilities.h"
+#include "KernelBasis.hxx"
 
 #ifdef WIN32
 #define setenv Kernel_Utils::setenv
-#endif 
-
-#define TRACEFILE "/tmp/traceUnitTest.log"
+#endif
 
 // ============================================================================
 /*!
- * Set Trace mecanism
+ * Set Trace mechanism
  * - delete preexisting trace classes if any
  * - set trace on file
  */
 // ============================================================================
 
-void 
+std::string
+UtilsTest::_getTraceFileName()
+{
+  std::string dir = Kernel_Utils::GetTmpDir();
+  return dir + "traceUnitTest-UtilsTest.log";
+}
+
+void
 UtilsTest::setUp()
 {
+  setSSLMode(false);
   LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
   CPPUNIT_ASSERT(bp1);
   bp1->deleteInstance(bp1);
 
   // --- trace on file
-  const char *theFileName = TRACEFILE;
+  std::string theFileName = _getTraceFileName();
 
   std::string s = "file:";
   s += theFileName;
   CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
 
   std::ofstream traceFile;
-  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();
 
@@ -73,7 +81,7 @@ UtilsTest::setUp()
  */
 // ============================================================================
 
-void 
+void
 UtilsTest::tearDown()
 {
   LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
@@ -84,11 +92,11 @@ UtilsTest::tearDown()
 int genExcept()
 {
   throw SALOME_Exception("a message");
-};
+}
 
 // ============================================================================
 /*!
- * Check basic SALOME_exception mecanism
+ * Check basic SALOME_exception mechanism
  */
 // ============================================================================