Salome HOME
Merge branch 'omu/launcher_evol'
[modules/kernel.git] / src / Utils / Test / UtilsTest.cxx
index aa6f9e302d706389c8ab3c19b4b8e28010707132..385b25c4903dc4a16bf49457c03be47a6f3918ec 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  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"
 
 #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()
 {
   LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
@@ -52,14 +58,14 @@ UtilsTest::setUp()
   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 +79,7 @@ UtilsTest::setUp()
  */
 // ============================================================================
 
-void 
+void
 UtilsTest::tearDown()
 {
   LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
@@ -88,7 +94,7 @@ int genExcept()
 
 // ============================================================================
 /*!
- * Check basic SALOME_exception mecanism
+ * Check basic SALOME_exception mechanism
  */
 // ============================================================================