BOSS 7.1.1
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 <cassert>
9#include <cmath> /* sqrt */
10#include <iostream>
11#include "TestTools/initGaudi.h"
12#include "GaudiKernel/ISvcLocator.h"
13#include "AthenaKernel/ITimeKeeper.h"
14#include "BesServices/SimplePOSIXTimeKeeperSvc.h"
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 cerr << "This test can not be run" << endl;
26 return 0;
27 }
28 assert(pSvcLoc);
29
30 //locate time keeper
31 const bool CREATEIF(true);
32 ITimeKeeper* pITK(0);
33 assert( (pSvcLoc->service("SimplePOSIXTimeKeeperSvc", pITK, CREATEIF)).isSuccess() );
34 assert( pITK );
35 // cout << *pITK <<endl;
36
37 SimplePOSIXTimeKeeperSvc& tk(dynamic_cast<SimplePOSIXTimeKeeperSvc&>(*pITK));
38 assert(tk.timeX() + tk.timeL() == tk.allocTime());
39
40 while (pITK->nextIter()) {
41 for (int i=0; i<20000000; ++i) atan(i); //waste some time
42 }
43
44 assert(tk.timeX() + tk.timeL() == tk.allocTime());
45
46 tk.finalize();
47
48 //all done
49 cout << "*** SimplePOSIXTimeKeeperSvc_test OK ***" <<endl;
50 return 0;
51}