1 // Copyright (C) 2007-2012 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.
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"
33 // ============================================================================
37 // ============================================================================
40 SALOMETraceCollectorTest::setUp()
44 // ============================================================================
48 // ============================================================================
51 SALOMETraceCollectorTest::tearDown()
55 #define NUM_THREADS 20
56 #define NUM_MESSAGES 20
57 void *PrintHello(void *threadid);
59 // ============================================================================
61 * open a trace on a CORBA, multithread writing on file, close
63 // ============================================================================
66 SALOMETraceCollectorTest::testLoadBufferPoolCORBA()
68 std::string s = "with_logger";
69 CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
71 // --- NUM_THREADS thread creation for trace generation.
73 pthread_t threads[NUM_THREADS];
75 for(t=0;t<NUM_THREADS;t++)
77 MESSAGE("Creating thread " << t);
78 rc = pthread_create(&threads[t], NULL, PrintHello, &t) ;
82 // --- wait for end of each thread producing trace.
84 for(t=0;t<NUM_THREADS;t++)
86 pthread_join(threads[t], NULL);
87 MESSAGE("--------------------- end of PrintHello thread " << t);
89 MESSAGE(" ---- end of PrintHello threads ---- ");
91 LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
93 bp1->deleteInstance(bp1);
96 // ============================================================================
98 * NUM_THREAD are created with function PrintHello,
99 * which produces NUM_MESSAGES traces.
101 // ============================================================================
103 void *PrintHello(void *threadid)
105 #if defined(_DEBUG_) || defined(_DEBUG)
106 long id_thread = (long)threadid;
107 for (int i=0; i<NUM_MESSAGES;i++)
108 MESSAGE("Hello World! This is a trace test : " << id_thread