ATLAS Offline Software
Loading...
Searching...
No Matches
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
13namespace 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
55 InitGaudiGoogleTest({}, level) {}
56
57}
58
Gaudi initialisation fixture base class for googletest based unit tests. Test fixture classes for tes...
IAppMgrUI * theApp
public members are visible in tests
InitGaudiGoogleTest(MSG::Level level=MSG::INFO)
Create GoogleTest fixture.
functions & macros to test the difference between floats
=============================================================================
Definition MsgLevel.h:28