ATLAS Offline Software
Loading...
Searching...
No Matches
setupStoreGate.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
10
11
14#include "TestTools/initGaudi.h"
15#include "GaudiKernel/ISvcLocator.h"
16#include "GaudiKernel/Bootstrap.h"
17#include <fstream>
18#include <iostream>
19#include <print>
20#include <list>
21#include <cassert>
22
23
24namespace Athena_test {
25
26
27bool setupStoreGate (std::string progname,
28 std::string options_file /*= ""*/)
29{
30 // Build job options file if CppUnit_jobOptions.txt is unavailable
31 if (options_file.empty()) {
32 std::string::size_type pos = progname.rfind ("/");
33 if (pos != std::string::npos)
34 progname.erase (0, pos+1);
35 pos = progname.rfind (".");
36 if (pos != std::string::npos)
37 progname.erase (pos, std::string::npos);
38 options_file = "./" + progname + "_generated.txt";
39 (void)remove (options_file.c_str());
40 std::ofstream jobopt(options_file.c_str());
41
42 // Build a default list of options.
43 {
44 std::list<std::string> opts;
45 opts.push_back("#pragma print off");
46 opts.push_back("ApplicationMgr.Dlls += { \"StoreGate\" };");
47 //opts.push_back("ApplicationMgr.Dlls += { \"CLIDSvc\" };");
48 opts.push_back("ApplicationMgr.ExtSvc += { \"ClassIDSvc\" };");
49 opts.push_back("ApplicationMgr.ExtSvc += { \"StoreGateSvc\", \"StoreGateSvc/DetectorStore\", \"StoreGateSvc/ConditionStore\", \"StoreGateSvc/HistoryStore\" };");
50 opts.push_back("ApplicationMgr.ExtSvc += { \"ActiveStoreSvc\" };");
51 opts.push_back("AuditorSvc.Auditors += { \"AlgContextAuditor\"};");
52 opts.push_back("StoreGateSvc.OutputLevel = 2;");
53 opts.push_back("StoreGateSvc.ActivateHistory = false;");
54 //opts.push_back("CLIDSvc.OutputLevel = 2;");
55 opts.push_back("MessageSvc.useColors = false;");
56 opts.push_back("MessageSvc.OutputLevel = 3;");
57 // Build job options file from list.
58 for ( std::list<std::string>::const_iterator iopt=opts.begin();
59 iopt!=opts.end(); ++iopt )
60 {
61 std::println (jobopt, "{}", *iopt);
62 }
63 }
64 jobopt.close();
65 }
66
67 try {
69 ISvcLocator* svcLoc = 0;
70 if (!Athena_test::initGaudi(options_file, svcLoc)) {
71 std::println (std::cerr, "This test can not be run");
72 return false;
73 }
74 assert( 0 != svcLoc);
75
76 SmartIF<StoreGateSvc> storeGate{svcLoc->service( "StoreGateSvc" )};
77 assert( storeGate );
78
79 if ( !storeGate ) {
80 std::string error = "No valid pointer to StoreGateSvc !!";
81 std::println (std::cerr, "{}", error);
82 return false;
83 } else {
84 return true;
85 }
86 } catch ( std::exception& e ) {
87 std::println (std::cerr, "Caught : {}", e.what());
88 return false;
89 }
90}
91
92
93} // namespace Athena_test
minimal gaudi initialization for AthenaServices unit testing
functions & macros to test the difference between floats
bool setupStoreGate(std::string progname, std::string options_file)
Helper for setting up StoreGate for regression tests.
bool initGaudi(ISvcLocator *&pSvcLoc)
Minimal Gaudi initialization for unit testing without job options.
Definition initGaudi.cxx:25
Helper for setting up StoreGate for regression tests.