Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : //------------------------------------------------------------------------
30 : : // include files
31 : : //------------------------------------------------------------------------
32 : : #include <sal/types.h>
33 : : #include "cppunit/TestAssert.h"
34 : : #include "cppunit/TestFixture.h"
35 : : #include "cppunit/extensions/HelperMacros.h"
36 : : #include "cppunit/plugin/TestPlugIn.h"
37 : : #include <osl_Mutex_Const.h>
38 : :
39 : : using namespace osl;
40 : : using namespace rtl;
41 : :
42 : : //------------------------------------------------------------------------
43 : : // helper functions
44 : : //------------------------------------------------------------------------
45 : :
46 : : /** print a UNI_CODE String.
47 : : */
48 : : inline void printUString( const ::rtl::OUString & str )
49 : : {
50 : : rtl::OString aString;
51 : :
52 : : printf("#printUString_u# " );
53 : : aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
54 : : printf("%s\n", aString.getStr( ) );
55 : : }
56 : :
57 : : /** print Boolean value.
58 : : */
59 : : inline void printBool( sal_Bool bOk )
60 : : {
61 : : printf("#printBool# " );
62 : : ( sal_True == bOk ) ? printf("YES!\n" ): printf("NO!\n" );
63 : : }
64 : :
65 : : /** pause nSec seconds helper function.
66 : : */
67 : : namespace ThreadHelper
68 : : {
69 : 10 : void thread_sleep_tenth_sec(sal_uInt32 _nTenthSec)
70 : : {
71 : : TimeValue nTV;
72 : 10 : nTV.Seconds = _nTenthSec/10;
73 : 10 : nTV.Nanosec = ( (_nTenthSec%10 ) * 100000000 );
74 [ + - ]: 10 : osl_waitThread(&nTV);
75 : 10 : }
76 : 0 : void thread_sleep( sal_uInt32 _nSec )
77 : : {
78 : : /// print statement in thread process must use fflush() to force display.
79 : : // t_print("# wait %d seconds. ", _nSec );
80 : 0 : fflush(stdout);
81 : :
82 : 0 : thread_sleep_tenth_sec( _nSec * 10 );
83 : : // printf("# done\n" );
84 : 0 : }
85 : : }
86 : :
87 : :
88 : : //------------------------------------------------------------------------
89 : : // Beginning of the test cases for osl_Mutex class
90 : : //------------------------------------------------------------------------
91 : :
92 : :
93 : : /** mutually exclusive data
94 : : */
95 : 0 : struct resource {
96 : : sal_Int32 data1;
97 : : sal_Int32 data2;
98 : : Mutex lock;
99 : : };
100 : :
101 : : /** IncreaseThread provide data.
102 : : */
103 : : class IncreaseThread : public Thread
104 : : {
105 : : public:
106 : 0 : IncreaseThread( struct resource *pData ): pResource( pData ) { }
107 : :
108 : 0 : ~IncreaseThread( )
109 : 0 : {
110 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "#IncreaseThread does not shutdown properly.\n", sal_False == this -> isRunning( ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
111 [ # # ]: 0 : }
112 : : protected:
113 : : struct resource *pResource;
114 : :
115 : 0 : void SAL_CALL run( )
116 : : {
117 : 0 : pResource->lock.acquire( );
118 [ # # ]: 0 : for( sal_Int8 i = 0; i < 3; i++ )
119 : : {
120 : 0 : pResource->data1++;
121 : 0 : yield( ); //yield() give CPU time to other thread, other thread if not block, they will change the data;
122 : : }
123 [ # # ]: 0 : if ( pResource->data2 == 0 )
124 : 0 : pResource->data2 = ( pResource->data1 > 0 ? pResource->data1 : 0 - pResource->data1 );
125 : 0 : pResource->lock.release();
126 : 0 : }
127 : : };
128 : :
129 : : /** DecreaseThread consume data.
130 : : */
131 : : class DecreaseThread : public Thread
132 : : {
133 : : public:
134 : 0 : DecreaseThread( struct resource *pData ): pResource( pData ) { }
135 : :
136 : 0 : ~DecreaseThread( )
137 : 0 : {
138 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "#DecreaseThread does not shutdown properly.\n", sal_False == this -> isRunning( ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
139 [ # # ]: 0 : }
140 : : protected:
141 : : struct resource *pResource;
142 : :
143 : 0 : void SAL_CALL run( )
144 : : {
145 : 0 : pResource->lock.acquire( );
146 [ # # ]: 0 : for( sal_Int8 i = 0; i < 3; i++ )
147 : : {
148 : 0 : pResource->data1--;
149 : 0 : yield( ); //yield() give CPU time to other thread, other thread if not block, they will change the data;
150 : : }
151 [ # # ]: 0 : if ( pResource->data2 == 0 )
152 : 0 : pResource->data2 = ( pResource->data1 > 0 ? pResource->data1 : 0 - pResource->data1 );
153 : 0 : pResource->lock.release();
154 : 0 : }
155 : : };
156 : :
157 : :
158 : : /** chain structure used in Threads as critical resource
159 : : */
160 : 0 : struct chain {
161 : : sal_Int32 buffer[ BUFFER_SIZE ];
162 : : Mutex lock;
163 : : sal_Int8 pos;
164 : : };
165 : :
166 : : /** PutThread write to the chain structure in a mutex manner.
167 : : */
168 : : class PutThread : public Thread
169 : : {
170 : : public:
171 : : //get the struct pointer to write data to buffer
172 : 0 : PutThread( struct chain* pData ): pChain( pData ) { }
173 : :
174 : 0 : ~PutThread( )
175 : 0 : {
176 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "#PutThread does not shutdown properly.\n", sal_False == this -> isRunning( ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
177 [ # # ]: 0 : }
178 : : protected:
179 : : struct chain* pChain;
180 : :
181 : 0 : void SAL_CALL run( )
182 : : {
183 : : //block here if the mutex has been acquired
184 : 0 : pChain->lock.acquire( );
185 : :
186 : : //current position in buffer to write
187 : 0 : sal_Int8 nPos = pChain->pos;
188 : 0 : oslThreadIdentifier oId = getIdentifier( );
189 : : //write data
190 : : sal_Int8 i;
191 [ # # ]: 0 : for ( i = 0; i < 5; i++ )
192 : : {
193 : 0 : pChain->buffer[ nPos + i ] = oId;
194 : 0 : yield( );
195 : : }
196 : : //revise the position
197 : 0 : pChain->pos = nPos + i;
198 : :
199 : : //finish writing, release the mutex
200 : 0 : pChain->lock.release();
201 : 0 : }
202 : : };
203 : :
204 : : /** thread for testing Mutex acquire.
205 : : */
206 : : class HoldThread : public Thread
207 : : {
208 : : public:
209 : : //get the Mutex pointer to operate
210 : 0 : HoldThread( Mutex* pMutex ): pMyMutex( pMutex ) { }
211 : :
212 : 0 : ~HoldThread( )
213 : 0 : {
214 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "#HoldThread does not shutdown properly.\n", sal_False == this -> isRunning( ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
215 [ # # ]: 0 : }
216 : : protected:
217 : : Mutex* pMyMutex;
218 : :
219 : 0 : void SAL_CALL run()
220 : : {
221 : : // block here if the mutex has been acquired
222 : 0 : pMyMutex->acquire( );
223 : 0 : printf("# Mutex acquired. \n" );
224 : 0 : pMyMutex->release( );
225 : 0 : }
226 : : };
227 : :
228 : : class WaitThread : public Thread
229 : : {
230 : : public:
231 : : //get the Mutex pointer to operate
232 : 0 : WaitThread( Mutex* pMutex ): pMyMutex( pMutex ) { }
233 : :
234 : 0 : ~WaitThread( )
235 : 0 : {
236 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "#WaitThread does not shutdown properly.\n", sal_False == this -> isRunning( ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
237 [ # # ]: 0 : }
238 : : protected:
239 : : Mutex* pMyMutex;
240 : :
241 : 0 : void SAL_CALL run( )
242 : : {
243 : : // block here if the mutex has been acquired
244 : 0 : pMyMutex->acquire( );
245 : 0 : ThreadHelper::thread_sleep_tenth_sec( 2 );
246 : 0 : pMyMutex->release( );
247 : 0 : }
248 : : };
249 : :
250 : : /** thread for testing getGlobalMutex.
251 : : */
252 : : class GlobalMutexThread : public Thread
253 : : {
254 : : public:
255 : : //get the Mutex pointer to operate
256 : 0 : GlobalMutexThread( ){ }
257 : :
258 : 0 : ~GlobalMutexThread( )
259 : 0 : {
260 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "#GlobalMutexThread does not shutdown properly.\n", sal_False == this -> isRunning( ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
261 [ # # ]: 0 : }
262 : : protected:
263 : 0 : void SAL_CALL run( )
264 : : {
265 : : // block here if the mutex has been acquired
266 : : Mutex* pGlobalMutex;
267 : 0 : pGlobalMutex = Mutex::getGlobalMutex( );
268 : 0 : pGlobalMutex->acquire( );
269 : 0 : printf("# Global Mutex acquired. \n" );
270 : 0 : pGlobalMutex->release( );
271 : 0 : }
272 : : };
273 : :
274 : :
275 : : //--------------------------------------------------------------
276 : : namespace osl_Mutex
277 : : {
278 : :
279 : : /** Test of the osl::Mutex::constructor
280 : : */
281 [ # # ][ # # ]: 0 : class ctor : public CppUnit::TestFixture
[ # # ][ # # ]
[ # # ]
282 : : {
283 : : public:
284 : : // initialise your test code values here.
285 : : struct chain m_Data;
286 : : struct resource m_Res;
287 : :
288 : 0 : void setUp( )
289 : : {
290 [ # # ]: 0 : for ( sal_Int8 i=0; i < BUFFER_SIZE; i++ )
291 : 0 : m_Data.buffer[i] = 0;
292 : 0 : m_Data.pos = 0;
293 : :
294 : 0 : m_Res.data1 = 0;
295 : 0 : m_Res.data2 = 0;
296 : 0 : }
297 : :
298 : 0 : void tearDown()
299 : : {
300 : 0 : }
301 : :
302 : : /** Create two threads to write data to the same buffer, use Mutex to assure
303 : : during one thread write data five times, the other thread should not begin writing.
304 : : the two threads wrote two different datas: their thread ID, so we can check the datas
305 : : in buffer to know the order of the two threads writing
306 : : */
307 : 0 : void ctor_001()
308 : : {
309 [ # # ]: 0 : PutThread myThread1( &m_Data );
310 [ # # ]: 0 : PutThread myThread2( &m_Data );
311 : :
312 [ # # ]: 0 : myThread1.create( );
313 [ # # ]: 0 : myThread2.create( );
314 : :
315 : : //wait until the two threads terminate
316 [ # # ]: 0 : myThread1.join( );
317 [ # # ]: 0 : myThread2.join( );
318 : :
319 : 0 : sal_Bool bRes = sal_False;
320 : :
321 : : // every 5 datas should the same
322 : : // LLA: this is not a good check, it's too fix
323 [ # # ][ # # ]: 0 : if (m_Data.buffer[0] == m_Data.buffer[1] &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
324 : 0 : m_Data.buffer[1] == m_Data.buffer[2] &&
325 : 0 : m_Data.buffer[2] == m_Data.buffer[3] &&
326 : 0 : m_Data.buffer[3] == m_Data.buffer[4] &&
327 : 0 : m_Data.buffer[5] == m_Data.buffer[6] &&
328 : 0 : m_Data.buffer[6] == m_Data.buffer[7] &&
329 : 0 : m_Data.buffer[7] == m_Data.buffer[8] &&
330 : 0 : m_Data.buffer[8] == m_Data.buffer[9])
331 : 0 : bRes = sal_True;
332 : :
333 : : /*for (sal_Int8 i=0; i<BUFFER_SIZE; i++)
334 : : printf("#data in buffer is %d\n", m_Data.buffer[i]);
335 : : */
336 : :
337 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("Mutex ctor", bRes == sal_True);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
338 : :
339 : 0 : }
340 : :
341 : : /** Create two threads to write data to operate on the same number , use Mutex to assure,
342 : : one thread increase data 3 times, the other thread decrease 3 times, store the operate
343 : : result when the first thread complete, if it is interrupt by the other thread, the stored
344 : : number will not be 3.
345 : : */
346 : 0 : void ctor_002()
347 : : {
348 [ # # ]: 0 : IncreaseThread myThread1( &m_Res );
349 [ # # ]: 0 : DecreaseThread myThread2( &m_Res );
350 : :
351 [ # # ]: 0 : myThread1.create( );
352 [ # # ]: 0 : myThread2.create( );
353 : :
354 : : //wait until the two threads terminate
355 [ # # ]: 0 : myThread1.join( );
356 [ # # ]: 0 : myThread2.join( );
357 : :
358 : 0 : sal_Bool bRes = sal_False;
359 : :
360 : : // every 5 datas should the same
361 [ # # ][ # # ]: 0 : if ( ( m_Res.data1 == 0 ) && ( m_Res.data2 == 3 ) )
362 : 0 : bRes = sal_True;
363 : :
364 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "test Mutex ctor function: increase and decrease a number 3 times without interrupt.", bRes == sal_True );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
365 : 0 : }
366 : :
367 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE( ctor );
[ # # ][ # # ]
[ # # ]
368 [ # # ][ # # ]: 0 : CPPUNIT_TEST( ctor_001 );
[ # # ][ # # ]
[ # # ][ # # ]
369 [ # # ][ # # ]: 0 : CPPUNIT_TEST( ctor_002 );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
370 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE_END( );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
371 : : }; // class ctor
372 : :
373 : :
374 : : /** Test of the osl::Mutex::acquire method
375 : : */
376 [ # # ]: 0 : class acquire : public CppUnit::TestFixture
377 : : {
378 : : public:
379 : : // acquire mutex in main thread, and then call acquire again in myThread,
380 : : // the child thread should block, wait 2 secs, it still block.
381 : : // Then release mutex in main thread, the child thread could return from acquire,
382 : : // and go to exec next statement, so could terminate quickly.
383 : 0 : void acquire_001( )
384 : : {
385 [ # # ]: 0 : Mutex aMutex;
386 : : //acquire here
387 [ # # ]: 0 : sal_Bool bRes = aMutex.acquire( );
388 : : // pass the pointer of mutex to child thread
389 [ # # ]: 0 : HoldThread myThread( &aMutex );
390 [ # # ]: 0 : myThread.create( );
391 : :
392 [ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec( 2 );
393 : : // if acquire in myThread does not work, 2 secs is long enough,
394 : : // myThread should terminate now, and bRes1 should be sal_False
395 [ # # ]: 0 : sal_Bool bRes1 = myThread.isRunning( );
396 : :
397 [ # # ]: 0 : aMutex.release( );
398 [ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec( 1 );
399 : : // after release mutex, myThread stops blocking and will terminate immediately
400 [ # # ]: 0 : sal_Bool bRes2 = myThread.isRunning( );
401 [ # # ]: 0 : myThread.join( );
402 : :
403 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "Mutex acquire",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
404 [ # # # # ]: 0 : bRes == sal_True && bRes1 == sal_True && bRes2 == sal_False );
[ # # ]
405 : 0 : }
406 : :
407 : : //in the same thread, acquire twice should success
408 : 0 : void acquire_002()
409 : : {
410 [ # # ]: 0 : Mutex aMutex;
411 : : //acquire here
412 [ # # ]: 0 : sal_Bool bRes = aMutex.acquire();
413 [ # # ]: 0 : sal_Bool bRes1 = aMutex.acquire();
414 : :
415 [ # # ]: 0 : sal_Bool bRes2 = aMutex.tryToAcquire();
416 : :
417 [ # # ]: 0 : aMutex.release();
418 : :
419 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("Mutex acquire",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
420 [ # # # # ]: 0 : bRes == sal_True && bRes1 == sal_True && bRes2 == sal_True);
421 : :
422 : 0 : }
423 : :
424 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE( acquire );
[ # # ][ # # ]
[ # # ]
425 [ # # ][ # # ]: 0 : CPPUNIT_TEST( acquire_001 );
[ # # ][ # # ]
[ # # ][ # # ]
426 [ # # ][ # # ]: 0 : CPPUNIT_TEST( acquire_002 );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
427 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE_END( );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
428 : : }; // class acquire
429 : :
430 : :
431 : : /** Test of the osl::Mutex::tryToAcquire method
432 : : */
433 [ # # ]: 0 : class tryToAcquire : public CppUnit::TestFixture
434 : : {
435 : : public:
436 : : // First let child thread acquire the mutex, and wait 2 secs, during the 2 secs,
437 : : // in main thread, tryToAcquire mutex should return False
438 : : // then after the child thread terminated, tryToAcquire should return True
439 : 0 : void tryToAcquire_001()
440 : : {
441 [ # # ]: 0 : Mutex aMutex;
442 [ # # ]: 0 : WaitThread myThread(&aMutex);
443 [ # # ]: 0 : myThread.create();
444 : :
445 : : // ensure the child thread acquire the mutex
446 [ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec(1);
447 : :
448 [ # # ]: 0 : sal_Bool bRes1 = aMutex.tryToAcquire();
449 : :
450 [ # # ]: 0 : if (bRes1 == sal_True)
451 [ # # ]: 0 : aMutex.release();
452 : : // wait the child thread terminate
453 [ # # ]: 0 : myThread.join();
454 : :
455 [ # # ]: 0 : sal_Bool bRes2 = aMutex.tryToAcquire();
456 : :
457 [ # # ]: 0 : if (bRes2 == sal_True)
458 [ # # ]: 0 : aMutex.release();
459 : :
460 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("Try to acquire Mutex",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
461 [ # # # # ]: 0 : bRes1 == sal_False && bRes2 == sal_True);
[ # # ]
462 : 0 : }
463 : :
464 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE(tryToAcquire);
[ # # ][ # # ]
[ # # ]
465 [ # # ][ # # ]: 0 : CPPUNIT_TEST(tryToAcquire_001);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
466 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE_END();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
467 : : }; // class tryToAcquire
468 : :
469 : : /** Test of the osl::Mutex::release method
470 : : */
471 [ # # ]: 0 : class release : public CppUnit::TestFixture
472 : : {
473 : : public:
474 : : /** acquire/release are not used in pairs: after child thread acquired mutex,
475 : : the main thread release it, then any thread could acquire it.
476 : : */
477 : 0 : void release_001()
478 : : {
479 [ # # ]: 0 : Mutex aMutex;
480 [ # # ]: 0 : WaitThread myThread( &aMutex );
481 [ # # ]: 0 : myThread.create( );
482 : :
483 : : // ensure the child thread acquire the mutex
484 [ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec( 1 );
485 : :
486 [ # # ]: 0 : sal_Bool bRunning = myThread.isRunning( );
487 [ # # ]: 0 : sal_Bool bRes1 = aMutex.tryToAcquire( );
488 : : // wait the child thread terminate
489 [ # # ]: 0 : myThread.join( );
490 : :
491 [ # # ]: 0 : sal_Bool bRes2 = aMutex.tryToAcquire( );
492 : :
493 [ # # ]: 0 : if ( bRes2 == sal_True )
494 [ # # ]: 0 : aMutex.release( );
495 : :
496 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "release Mutex: try to aquire before and after the mutex has been released",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
497 [ # # # # ]: 0 : bRes1 == sal_False && bRes2 == sal_True && bRunning == sal_True );
[ # # ]
498 : :
499 : 0 : }
500 : :
501 : : // how about release twice?
502 : 0 : void release_002()
503 : : {
504 : 0 : }
505 : :
506 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE( release );
[ # # ][ # # ]
[ # # ]
507 [ # # ][ # # ]: 0 : CPPUNIT_TEST( release_001 );
[ # # ][ # # ]
[ # # ][ # # ]
508 [ # # ][ # # ]: 0 : CPPUNIT_TEST( release_002 );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
509 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE_END( );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
510 : : }; // class release
511 : :
512 : :
513 : :
514 : : /** Test of the osl::Mutex::getGlobalMutex method
515 : : */
516 [ # # ]: 0 : class getGlobalMutex : public CppUnit::TestFixture
517 : : {
518 : : public:
519 : : // initialise your test code values here.
520 : 0 : void getGlobalMutex_001()
521 : : {
522 : : Mutex* pGlobalMutex;
523 [ # # ]: 0 : pGlobalMutex = Mutex::getGlobalMutex();
524 [ # # ]: 0 : pGlobalMutex->acquire();
525 : :
526 [ # # ]: 0 : GlobalMutexThread myThread;
527 [ # # ]: 0 : myThread.create();
528 : :
529 [ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec(1);
530 [ # # ]: 0 : sal_Bool bRes1 = myThread.isRunning();
531 : :
532 [ # # ]: 0 : pGlobalMutex->release();
533 [ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec(1);
534 : : // after release mutex, myThread stops blocking and will terminate immediately
535 [ # # ]: 0 : sal_Bool bRes2 = myThread.isRunning();
536 : :
537 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("Global Mutex works",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
538 [ # # # # ]: 0 : bRes1 == sal_True && bRes2 == sal_False);
539 : 0 : }
540 : :
541 : 0 : void getGlobalMutex_002( )
542 : : {
543 : : sal_Bool bRes;
544 : :
545 : : Mutex *pGlobalMutex;
546 : 0 : pGlobalMutex = Mutex::getGlobalMutex( );
547 : 0 : pGlobalMutex->acquire( );
548 : : {
549 : : Mutex *pGlobalMutex1;
550 : 0 : pGlobalMutex1 = Mutex::getGlobalMutex( );
551 : 0 : bRes = pGlobalMutex1->release( );
552 : : }
553 : :
554 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "Global Mutex works: if the code between {} get the different mutex as the former one, it will return false when release.",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
555 [ # # ]: 0 : bRes == sal_True );
556 : 0 : }
557 : :
558 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE(getGlobalMutex);
[ # # ][ # # ]
[ # # ]
559 [ # # ][ # # ]: 0 : CPPUNIT_TEST(getGlobalMutex_001);
[ # # ][ # # ]
[ # # ][ # # ]
560 [ # # ][ # # ]: 0 : CPPUNIT_TEST(getGlobalMutex_002);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
561 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE_END();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
562 : : }; // class getGlobalMutex
563 : :
564 : : // -----------------------------------------------------------------------------
565 [ + - ][ + - ]: 5 : CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Mutex::ctor, "osl_Mutex");
566 [ + - ][ + - ]: 5 : CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Mutex::acquire, "osl_Mutex");
567 [ + - ][ + - ]: 5 : CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Mutex::tryToAcquire, "osl_Mutex");
568 [ + - ][ + - ]: 5 : CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Mutex::release, "osl_Mutex");
569 [ + - ][ + - ]: 5 : CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Mutex::getGlobalMutex, "osl_Mutex");
570 : : } // namespace osl_Mutex
571 : :
572 : :
573 : : //------------------------------------------------------------------------
574 : : // Beginning of the test cases for osl_Guard class
575 : : //------------------------------------------------------------------------
576 : :
577 : : class GuardThread : public Thread
578 : : {
579 : : public:
580 : : //get the Mutex pointer to operate
581 : 0 : GuardThread( Mutex* pMutex ): pMyMutex( pMutex ) { }
582 : :
583 : 0 : ~GuardThread( )
584 : 0 : {
585 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "#GuardThread does not shutdown properly.\n", sal_False == this -> isRunning( ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
586 [ # # ]: 0 : }
587 : : protected:
588 : : Mutex* pMyMutex;
589 : :
590 : 0 : void SAL_CALL run( )
591 : : {
592 : : // block here if the mutex has been acquired
593 [ # # ]: 0 : MutexGuard aGuard( pMyMutex );
594 [ # # ][ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec( 2 );
595 : 0 : }
596 : : };
597 : :
598 : :
599 : : namespace osl_Guard
600 : : {
601 [ # # ]: 0 : class ctor : public CppUnit::TestFixture
602 : : {
603 : : public:
604 : : // insert your test code here.
605 : 0 : void ctor_001()
606 : : {
607 [ # # ]: 0 : Mutex aMutex;
608 [ # # ]: 0 : GuardThread myThread(&aMutex);
609 [ # # ]: 0 : myThread.create();
610 : :
611 [ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec(1);
612 [ # # ]: 0 : sal_Bool bRes = aMutex.tryToAcquire();
613 : : // after 1 second, the mutex has been guarded, and the child thread should be running
614 [ # # ]: 0 : sal_Bool bRes1 = myThread.isRunning();
615 : :
616 [ # # ]: 0 : myThread.join();
617 [ # # ]: 0 : sal_Bool bRes2 = aMutex.tryToAcquire();
618 : :
619 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("GuardThread constructor",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
620 [ # # # # ]: 0 : bRes == sal_False && bRes1 == sal_True && bRes2 == sal_True);
[ # # ]
621 : 0 : }
622 : :
623 : 0 : void ctor_002( )
624 : : {
625 [ # # ]: 0 : Mutex aMutex;
626 : :
627 : : /// use reference constructor here
628 [ # # ]: 0 : MutexGuard myGuard( aMutex );
629 : :
630 : : /// the GuardThread will block here when it is initialised.
631 [ # # ]: 0 : GuardThread myThread( &aMutex );
632 [ # # ]: 0 : myThread.create( );
633 : :
634 : : /// is it still blocking?
635 [ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec( 2 );
636 [ # # ]: 0 : sal_Bool bRes = myThread.isRunning( );
637 : :
638 : : /// oh, release him.
639 [ # # ]: 0 : aMutex.release( );
640 [ # # ]: 0 : myThread.join( );
641 : :
642 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("GuardThread constructor: reference initialization, aquire the mutex before running the thread, then check if it is blocking.",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
643 [ # # # # ]: 0 : bRes == sal_True);
[ # # ][ # # ]
644 : 0 : }
645 : :
646 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE(ctor);
[ # # ][ # # ]
[ # # ]
647 [ # # ][ # # ]: 0 : CPPUNIT_TEST(ctor_001);
[ # # ][ # # ]
[ # # ][ # # ]
648 [ # # ][ # # ]: 0 : CPPUNIT_TEST(ctor_002);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
649 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE_END();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
650 : : }; // class ctor
651 : :
652 : : // -----------------------------------------------------------------------------
653 [ + - ][ + - ]: 5 : CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Guard::ctor, "osl_Guard");
654 : : } // namespace osl_Guard
655 : :
656 : :
657 : : //------------------------------------------------------------------------
658 : : // Beginning of the test cases for osl_ClearableGuard class
659 : : //------------------------------------------------------------------------
660 : :
661 : : /** Thread for test ClearableGuard
662 : : */
663 : : class ClearGuardThread : public Thread
664 : : {
665 : : public:
666 : : //get the Mutex pointer to operate
667 : 0 : ClearGuardThread( Mutex* pMutex ): pMyMutex( pMutex ) {}
668 : :
669 : 0 : ~ClearGuardThread( )
670 : 0 : {
671 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "#ClearGuardThread does not shutdown properly.\n", sal_False == this -> isRunning( ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
672 [ # # ]: 0 : }
673 : : protected:
674 : : Mutex* pMyMutex;
675 : :
676 : 0 : void SAL_CALL run( )
677 : : {
678 : : // acquire the mutex
679 : : // printf("# ClearGuardThread" );
680 [ # # ]: 0 : ClearableMutexGuard aGuard( pMyMutex );
681 [ # # ]: 0 : ThreadHelper::thread_sleep( 5 );
682 : :
683 : : // release the mutex
684 [ # # ]: 0 : aGuard.clear( );
685 [ # # ][ # # ]: 0 : ThreadHelper::thread_sleep( 2 );
686 : 0 : }
687 : : };
688 : :
689 : : // -----------------------------------------------------------------------------
690 : : namespace osl_ClearableGuard
691 : : {
692 : :
693 [ # # ]: 0 : class ctor : public CppUnit::TestFixture
694 : : {
695 : : public:
696 : 0 : void ctor_001()
697 : : {
698 [ # # ]: 0 : Mutex aMutex;
699 : :
700 : : /// now, the aMutex has been guarded.
701 [ # # ]: 0 : ClearableMutexGuard myMutexGuard( &aMutex );
702 : :
703 : : /// it will return sal_False if the aMutex has not been Guarded.
704 [ # # ]: 0 : sal_Bool bRes = aMutex.release( );
705 : :
706 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("ClearableMutexGuard constructor, test the aquire operation when initilized.",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
707 [ # # # # ]: 0 : bRes == sal_True );
[ # # ]
708 : 0 : }
709 : :
710 : 0 : void ctor_002( )
711 : : {
712 [ # # ]: 0 : Mutex aMutex;
713 : :
714 : : /// now, the aMutex has been guarded, this time, we use reference constructor.
715 [ # # ]: 0 : ClearableMutexGuard myMutexGuard( aMutex );
716 : :
717 : : /// it will return sal_False if the aMutex has not been Guarded.
718 [ # # ]: 0 : sal_Bool bRes = aMutex.release( );
719 : :
720 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("ClearableMutexGuard constructor, test the aquire operation when initilized, we use reference constructor this time.",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
721 [ # # # # ]: 0 : bRes == sal_True );
[ # # ]
722 : 0 : }
723 : :
724 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE(ctor);
[ # # ][ # # ]
[ # # ]
725 [ # # ][ # # ]: 0 : CPPUNIT_TEST(ctor_001);
[ # # ][ # # ]
[ # # ][ # # ]
726 [ # # ][ # # ]: 0 : CPPUNIT_TEST(ctor_002);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
727 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE_END();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
728 : : }; // class ctor
729 : :
730 [ # # ]: 0 : class clear : public CppUnit::TestFixture
731 : : {
732 : : public:
733 : 0 : void clear_001()
734 : : {
735 [ # # ]: 0 : Mutex aMutex;
736 [ # # ]: 0 : ClearGuardThread myThread(&aMutex);
737 [ # # ]: 0 : myThread.create();
738 : :
739 : : TimeValue aTimeVal_befor;
740 [ # # ]: 0 : osl_getSystemTime( &aTimeVal_befor );
741 : : // wait 1 second to assure the child thread has begun
742 [ # # ]: 0 : ThreadHelper::thread_sleep(1);
743 : :
744 : 0 : while (1)
745 : : {
746 [ # # ][ # # ]: 0 : if (aMutex.tryToAcquire() == sal_True)
747 : : {
748 : 0 : break;
749 : : }
750 [ # # ]: 0 : ThreadHelper::thread_sleep(1);
751 : : }
752 : : TimeValue aTimeVal_after;
753 [ # # ]: 0 : osl_getSystemTime( &aTimeVal_after );
754 : 0 : sal_Int32 nSec = aTimeVal_after.Seconds - aTimeVal_befor.Seconds;
755 [ # # ]: 0 : printf("nSec is %" SAL_PRIdINT32 "\n", nSec);
756 : :
757 [ # # ]: 0 : myThread.join();
758 : :
759 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE("ClearableGuard method: clear",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
760 [ # # # # ]: 0 : nSec < 7 && nSec > 1);
[ # # ]
761 : 0 : }
762 : :
763 : 0 : void clear_002( )
764 : : {
765 [ # # ]: 0 : Mutex aMutex;
766 : :
767 : : /// now, the aMutex has been guarded.
768 [ # # ]: 0 : ClearableMutexGuard myMutexGuard( &aMutex );
769 : :
770 : : /// launch the HoldThread, it will be blocked here.
771 [ # # ]: 0 : HoldThread myThread( &aMutex );
772 [ # # ]: 0 : myThread.create( );
773 : :
774 : : /// is it blocking?
775 [ # # ]: 0 : ThreadHelper::thread_sleep_tenth_sec( 4 );
776 [ # # ]: 0 : sal_Bool bRes = myThread.isRunning( );
777 : :
778 : : /// use clear to release.
779 [ # # ]: 0 : myMutexGuard.clear( );
780 [ # # ]: 0 : myThread.join( );
781 [ # # ]: 0 : sal_Bool bRes1 = myThread.isRunning( );
782 : :
783 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_MESSAGE( "ClearableGuard method: clear, control the HoldThread's running status!",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
784 [ # # # # ]: 0 : ( sal_True == bRes ) && ( sal_False == bRes1 ) );
[ # # ][ # # ]
785 : 0 : }
786 : :
787 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE( clear );
[ # # ][ # # ]
[ # # ]
788 [ # # ][ # # ]: 0 : CPPUNIT_TEST( clear_001 );
[ # # ][ # # ]
[ # # ][ # # ]
789 [ # # ][ # # ]: 0 : CPPUNIT_TEST( clear_002 );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
790 [ # # ][ # # ]: 0 : CPPUNIT_TEST_SUITE_END( );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
791 : : }; // class clear
792 : :
793 : : // -----------------------------------------------------------------------------
794 [ + - ][ + - ]: 5 : CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_ClearableGuard::ctor, "osl_ClearableGuard" );
795 [ + - ][ + - ]: 5 : CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_ClearableGuard::clear, "osl_ClearableGuard" );
796 : : } // namespace osl_ClearableGuard
797 : :
798 : :
799 : : //------------------------------------------------------------------------
800 : : // Beginning of the test cases for osl_ResettableGuard class
801 : : //------------------------------------------------------------------------
802 : :
803 : : /** Thread for test ResettableGuard
804 : : */
805 : : class ResetGuardThread : public Thread
806 : : {
807 : : public:
808 : : //get the Mutex pointer to operate
809 : 5 : ResetGuardThread( Mutex* pMutex ): pMyMutex( pMutex ) {}
810 : :
811 : 5 : ~ResetGuardThread( )
812 : 5 : {
813 [ + - ][ + - ]: 5 : CPPUNIT_ASSERT_MESSAGE( "#ResetGuardThread does not shutdown properly.\n", sal_False == this -> isRunning( ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
814 [ - + ]: 5 : }
815 : : protected:
816 : : Mutex* pMyMutex;
817 : :
818 : 5 : void SAL_CALL run( )
819 : : {
820 : : // acquire the mutex
821 [ + - ]: 5 : printf("# ResettableGuard\n" );
822 [ + - ]: 5 : ResettableMutexGuard aGuard( pMyMutex );
823 : : // release the mutex
824 [ + - ]: 5 : aGuard.clear( );
825 [ + - ][ + - ]: 5 : ThreadHelper::thread_sleep_tenth_sec( 2 );
826 : 5 : }
827 : : };
828 : :
829 : : // -----------------------------------------------------------------------------
830 : : namespace osl_ResettableGuard
831 : : {
832 [ - + ]: 30 : class ctor : public CppUnit::TestFixture
833 : : {
834 : : public:
835 : 5 : void ctor_001()
836 : : {
837 [ + - ]: 5 : Mutex aMutex;
838 : :
839 : : /// now, the aMutex has been guarded.
840 [ + - ]: 5 : ResettableMutexGuard myMutexGuard( &aMutex );
841 : :
842 : : /// it will return sal_False if the aMutex has not been Guarded.
843 [ + - ]: 5 : sal_Bool bRes = aMutex.release( );
844 : :
845 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE("ResettableMutexGuard constructor, test the aquire operation when initilized.",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
846 [ + - + - ]: 10 : bRes == sal_True );
[ + - ]
847 : 5 : }
848 : :
849 : 5 : void ctor_002( )
850 : : {
851 [ + - ]: 5 : Mutex aMutex;
852 : :
853 : : /// now, the aMutex has been guarded, this time, we use reference constructor.
854 [ + - ]: 5 : ResettableMutexGuard myMutexGuard( aMutex );
855 : :
856 : : /// it will return sal_False if the aMutex has not been Guarded.
857 [ + - ]: 5 : sal_Bool bRes = aMutex.release( );
858 : :
859 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE( "ResettableMutexGuard constructor, test the aquire operation when initilized, we use reference constructor this time.",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
860 [ + - + - ]: 10 : bRes == sal_True );
[ + - ]
861 : 5 : }
862 : :
863 : :
864 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(ctor);
[ + - ][ + - ]
[ # # ]
865 [ + - ][ + - ]: 5 : CPPUNIT_TEST(ctor_001);
[ + - ][ + - ]
[ + - ][ + - ]
866 [ + - ][ + - ]: 5 : CPPUNIT_TEST(ctor_002);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
867 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
868 : : }; // class ctor
869 : :
870 [ - + ]: 30 : class reset : public CppUnit::TestFixture
871 : : {
872 : : public:
873 : 5 : void reset_001( )
874 : : {
875 [ + - ]: 5 : Mutex aMutex;
876 [ + - ]: 5 : ResetGuardThread myThread( &aMutex );
877 [ + - ]: 5 : ResettableMutexGuard myMutexGuard( aMutex );
878 [ + - ]: 5 : myThread.create( );
879 : :
880 : : /// is it running? and clear done?
881 [ + - ]: 5 : sal_Bool bRes = myThread.isRunning( );
882 [ + - ]: 5 : myMutexGuard.clear( );
883 [ + - ]: 5 : ThreadHelper::thread_sleep_tenth_sec( 1 );
884 : :
885 : : /// if reset is not success, the release will return sal_False
886 [ + - ]: 5 : myMutexGuard.reset( );
887 [ + - ]: 5 : sal_Bool bRes1 = aMutex.release( );
888 [ + - ]: 5 : myThread.join( );
889 : :
890 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE( "ResettableMutexGuard method: reset",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
891 [ + - + - ]: 10 : ( sal_True == bRes ) && ( sal_True == bRes1 ) );
[ + - ][ + - ]
892 : 5 : }
893 : :
894 : 5 : void reset_002( )
895 : : {
896 [ + - ]: 5 : Mutex aMutex;
897 [ + - ]: 5 : ResettableMutexGuard myMutexGuard( &aMutex );
898 : :
899 : : /// shouldn't release after clear;
900 [ + - ]: 5 : myMutexGuard.clear( );
901 [ + - ]: 5 : sal_Bool bRes = aMutex.release( );
902 : :
903 : : /// can release after reset.
904 [ + - ]: 5 : myMutexGuard.reset( );
905 [ + - ]: 5 : sal_Bool bRes1 = aMutex.release( );
906 : :
907 [ + - ][ + - ]: 10 : CPPUNIT_ASSERT_MESSAGE( "ResettableMutexGuard method: reset, release after clear and reset, on Solaris, the mutex can be release without aquire, so it can not passed on (SOLARIS), but not the reason for reset_002",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
908 [ + - + - ]: 10 : ( sal_False == bRes ) && ( sal_True == bRes1 ) );
[ + - ]
909 : 5 : }
910 : :
911 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(reset);
[ + - ][ + - ]
[ # # ]
912 [ + - ][ + - ]: 5 : CPPUNIT_TEST(reset_001);
[ + - ][ + - ]
[ + - ][ + - ]
913 : : #ifdef LINUX
914 [ + - ][ + - ]: 5 : CPPUNIT_TEST(reset_002);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
915 : : #endif
916 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
917 : : }; // class reset
918 : :
919 : : // -----------------------------------------------------------------------------
920 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(osl_ResettableGuard::ctor);
921 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(osl_ResettableGuard::reset);
922 : : } // namespace osl_ResettableGuard
923 : :
924 [ + - ][ + - ]: 20 : CPPUNIT_PLUGIN_IMPLEMENT();
[ + - ][ + - ]
[ + - ][ # # ]
925 : :
926 : : // The following sets variables for GNU EMACS
927 : : // Local Variables:
928 : : // tab-width:4
929 : : // End:
930 : :
931 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|