1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "SALOMETraceCollectorTest.hxx"
27 #include "LocalTraceBufferPool.hxx"
28 #include "utilities.h"
32 // ============================================================================
36 // ============================================================================
39 SALOMETraceCollectorTest::setUp()
43 // ============================================================================
47 // ============================================================================
50 SALOMETraceCollectorTest::tearDown()
54 #define NUM_THREADS 20
55 #define NUM_MESSAGES 20
56 void *PrintHello(void *threadid);
58 // ============================================================================
60 * open a trace on a CORBA, multithread writing on file, close
62 // ============================================================================
65 SALOMETraceCollectorTest::testLoadBufferPoolCORBA()
67 string s = "with_logger";
68 CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
70 // --- NUM_THREADS thread creation for trace generation.
72 pthread_t threads[NUM_THREADS];
74 for(t=0;t<NUM_THREADS;t++)
76 MESSAGE("Creating thread " << t);
77 rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t) ;
81 // --- wait for end of each thread producing trace.
83 for(t=0;t<NUM_THREADS;t++)
85 int ret = pthread_join(threads[t], NULL);
86 MESSAGE("--------------------- end of PrintHello thread " << t);
88 MESSAGE(" ---- end of PrintHello threads ---- ");
90 LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
92 bp1->deleteInstance(bp1);
95 // ============================================================================
97 * NUM_THREAD are created with function PrintHello,
98 * which produces NUM_MESSAGES traces.
100 // ============================================================================
102 void *PrintHello(void *threadid)
104 long id_thread = (long)threadid;
105 for (int i=0; i<NUM_MESSAGES;i++)
106 MESSAGE("Hello World! This is a trace test : " << id_thread