00001
00008 #include <cassert>
00009 #include <cmath>
00010 #include <iostream>
00011 #include "TestTools/initGaudi.h"
00012 #include "GaudiKernel/ISvcLocator.h"
00013 #include "AthenaKernel/ITimeKeeper.h"
00014 #include "BesServices/SimplePOSIXTimeKeeperSvc.h"
00015
00016 using std::cerr;
00017 using std::cout;
00018 using std::endl;
00019 using namespace Athena_test;
00020
00021 int main() {
00022 cout << "*** SimplePOSIXTimeKeeperSvc_test starts ***" <<endl;
00023 ISvcLocator* pSvcLoc(0);
00024 if (!initGaudi("SimplePOSIXTimeKeeperSvc_test.txt", pSvcLoc)) {
00025 cerr << "This test can not be run" << endl;
00026 return 0;
00027 }
00028 assert(pSvcLoc);
00029
00030
00031 const bool CREATEIF(true);
00032 ITimeKeeper* pITK(0);
00033 assert( (pSvcLoc->service("SimplePOSIXTimeKeeperSvc", pITK, CREATEIF)).isSuccess() );
00034 assert( pITK );
00035
00036
00037 SimplePOSIXTimeKeeperSvc& tk(dynamic_cast<SimplePOSIXTimeKeeperSvc&>(*pITK));
00038 assert(tk.timeX() + tk.timeL() == tk.allocTime());
00039
00040 while (pITK->nextIter()) {
00041 for (int i=0; i<20000000; ++i) atan(i);
00042 }
00043
00044 assert(tk.timeX() + tk.timeL() == tk.allocTime());
00045
00046 tk.finalize();
00047
00048
00049 cout << "*** SimplePOSIXTimeKeeperSvc_test OK ***" <<endl;
00050 return 0;
00051 }