BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
SimplePOSIXTimeKeeperSvc_test.cxx
Go to the documentation of this file.
1/** @file SimplePOSIXTimeKeeperSvc_test.cxx
2 * @brief unit test for ITimeKeeper simplest implementation
3 *
4 * Based on ATLAS software
5 *
6 **/
7
8#include "AthenaKernel/ITimeKeeper.h"
9#include "BesServices/SimplePOSIXTimeKeeperSvc.h"
10#include "GaudiKernel/ISvcLocator.h"
11#include "TestTools/initGaudi.h"
12#include <cassert>
13#include <cmath> /* sqrt */
14#include <iostream>
15
16using std::cerr;
17using std::cout;
18using std::endl;
19using namespace Athena_test;
20
21int main() {
22 cout << "*** SimplePOSIXTimeKeeperSvc_test starts ***" << endl;
23 ISvcLocator* pSvcLoc( 0 );
24 if ( !initGaudi( "SimplePOSIXTimeKeeperSvc_test.txt", pSvcLoc ) )
25 {
26 cerr << "This test can not be run" << endl;
27 return 0;
28 }
29 assert( pSvcLoc );
30
31 // locate time keeper
32 const bool CREATEIF( true );
33 ITimeKeeper* pITK( 0 );
34 assert( ( pSvcLoc->service( "SimplePOSIXTimeKeeperSvc", pITK, CREATEIF ) ).isSuccess() );
35 assert( pITK );
36 // cout << *pITK <<endl;
37
38 SimplePOSIXTimeKeeperSvc& tk( dynamic_cast<SimplePOSIXTimeKeeperSvc&>( *pITK ) );
39 assert( tk.timeX() + tk.timeL() == tk.allocTime() );
40
41 while ( pITK->nextIter() )
42 {
43 for ( int i = 0; i < 20000000; ++i ) atan( i ); // waste some time
44 }
45
46 assert( tk.timeX() + tk.timeL() == tk.allocTime() );
47
48 tk.finalize();
49
50 // all done
51 cout << "*** SimplePOSIXTimeKeeperSvc_test OK ***" << endl;
52 return 0;
53}