1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "SALOMETraceCollectorTest.hxx"
29 #include "LocalTraceBufferPool.hxx"
30 #include "utilities.h"
31 #include "Basics_Utils.hxx"
34 #define setenv Kernel_Utils::setenv
37 // ============================================================================
41 // ============================================================================
44 SALOMETraceCollectorTest::setUp()
48 // ============================================================================
52 // ============================================================================
55 SALOMETraceCollectorTest::tearDown()
59 #define NUM_THREADS 20
60 #define NUM_MESSAGES 20
61 void *PrintHello(void *threadid);
63 // ============================================================================
65 * open a trace on a CORBA, multithread writing on file, close
67 // ============================================================================
70 SALOMETraceCollectorTest::testLoadBufferPoolCORBA()
72 std::string s = "with_logger";
73 CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
75 // --- NUM_THREADS thread creation for trace generation.
77 pthread_t threads[NUM_THREADS];
79 for(t=0;t<NUM_THREADS;t++)
81 MESSAGE("Creating thread " << t);
82 rc = pthread_create(&threads[t], NULL, PrintHello, &t) ;
86 // --- wait for end of each thread producing trace.
88 for(t=0;t<NUM_THREADS;t++)
90 pthread_join(threads[t], NULL);
91 MESSAGE("--------------------- end of PrintHello thread " << t);
93 MESSAGE(" ---- end of PrintHello threads ---- ");
95 LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
97 bp1->deleteInstance(bp1);
100 // ============================================================================
102 * NUM_THREAD are created with function PrintHello,
103 * which produces NUM_MESSAGES traces.
105 // ============================================================================
107 void *PrintHello(void *threadid)
109 #if defined(_DEBUG_) || defined(_DEBUG)
110 long id_thread = (long)threadid;
111 for (int i=0; i<NUM_MESSAGES;i++)
112 MESSAGE("Hello World! This is a trace test : " << id_thread