ATLAS Offline Software
InitGaudiGoogleTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "GaudiKernel/Bootstrap.h"
8 #include "GaudiKernel/IAppMgrUI.h"
9 
10 #include <iostream>
11 #include <fstream>
12 
13 namespace Athena_test {
14 
15  InitGaudiGoogleTest::InitGaudiGoogleTest( const std::string& jobOptsPath, MSG::Level level ) :
16  // create a new ApplicationMgr w/o singleton behaviour
17  theApp( Gaudi::createApplicationMgrEx( "GaudiCoreSvc", "ApplicationMgr" ) ),
18  propMgr( theApp ),
19  svcLoc( theApp ),
20  svcMgr( theApp ),
21  toolSvc( svcLoc->service("ToolSvc") )
22  {
23  EXPECT_TRUE( theApp != nullptr );
24  EXPECT_TRUE( propMgr.isValid() );
25  EXPECT_TRUE( svcLoc.isValid() );
26  EXPECT_TRUE( svcMgr.isValid() );
27  EXPECT_TRUE( toolSvc.isValid() );
28  // set the new ApplicationMgr as instance in Gaudi
29  Gaudi::setInstance( theApp );
30 
31  EXPECT_TRUE( propMgr->setProperty( "OutputLevel", std::to_string( level ) ).isSuccess() );
32  if (jobOptsPath.empty()) {
33  EXPECT_TRUE( propMgr->setProperty( "JobOptionsType", "NONE" ).isSuccess() );
34  }
35  else {
36  EXPECT_TRUE( propMgr->setProperty( "JobOptionsType", "FILE" ).isSuccess() );
37  EXPECT_TRUE( propMgr->setProperty( "JobOptionsPath", jobOptsPath ).isSuccess() );
38  }
39  EXPECT_TRUE( theApp->configure().isSuccess() );
40  EXPECT_TRUE( theApp->initialize().isSuccess() );
41  }
42 
43  // Finalize and terminate Gaudi, more to make sure that things
44  // went clean than anything else because we are throwing away the
45  // ApplicationMgr anyway
47  EXPECT_TRUE( theApp->finalize().isSuccess() );
48  EXPECT_TRUE( theApp->terminate().isSuccess() );
49  }
50 
51  InitGaudiGoogleTest::InitGaudiGoogleTest( const std::string& jobOptsPath ) :
52  InitGaudiGoogleTest(jobOptsPath, MSG::INFO) {}
53 
56 
57 }
58 
Athena_test::InitGaudiGoogleTest::~InitGaudiGoogleTest
virtual ~InitGaudiGoogleTest()
dtor
Definition: InitGaudiGoogleTest.cxx:46
Athena_test::InitGaudiGoogleTest::theApp
IAppMgrUI * theApp
public members are visible in tests
Definition: InitGaudiGoogleTest.h:53
StdJOSetup.svcMgr
svcMgr
Definition: StdJOSetup.py:33
Athena_test::InitGaudiGoogleTest::svcMgr
SmartIF< ISvcManager > svcMgr
Definition: InitGaudiGoogleTest.h:56
Athena_test::InitGaudiGoogleTest::InitGaudiGoogleTest
InitGaudiGoogleTest(MSG::Level level=MSG::INFO)
Create GoogleTest fixture.
Definition: InitGaudiGoogleTest.cxx:54
Athena_test::InitGaudiGoogleTest::propMgr
SmartIF< IProperty > propMgr
Definition: InitGaudiGoogleTest.h:54
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
MSG
Definition: MsgLevel.h:28
Athena_test
functions & macros to test the difference between floats
Definition: InitGaudiGoogleTest.h:31
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
InitGaudiGoogleTest.h
Gaudi initialisation fixture base class for googletest based unit tests. Test fixture classes for tes...
Athena_test::InitGaudiGoogleTest::toolSvc
SmartIF< IToolSvc > toolSvc
Definition: InitGaudiGoogleTest.h:57
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
python.AppMgr.theApp
theApp
Definition: AppMgr.py:771
Athena_test::InitGaudiGoogleTest
Definition: InitGaudiGoogleTest.h:33
Athena_test::InitGaudiGoogleTest::svcLoc
SmartIF< ISvcLocator > svcLoc
Definition: InitGaudiGoogleTest.h:55