#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TextTestRunner.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TextOutputter.h>
#include <cppunit/XmlOutputter.h>
#include <iostream>
#include <cassert>
#include <stdexcept>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <list>
#include "TestTools/initGaudi.h"
#include "StoreGate/StoreGateSvc.h"
#include "GaudiKernel/ISvcLocator.h"
Go to the source code of this file.
◆ main()
int main |
( |
int |
, |
|
|
char ** |
|
|
) |
| |
Main class for all the CppUnit test classes
Load the StoreGateSvc
Get the top level suite from the registry
Adds the test to the list of test to run
Run the tests.
Definition at line 141 of file CppUnit_SGtestdriver.cxx.
145 std::string
error =
"Could not setup StoreGateSvc !!";
146 throw std::runtime_error(
error);
150 CppUnit::Test *
suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
153 CppUnit::TextTestRunner
runner;
170 bool wasSuccessful =
runner.run(
"",
false,
true,
false);
173 if (!wasSuccessful)
return 1;
◆ setupStoreGate()
Simple function to instantiate and initialize the StoreGateSvc.
Get StoreGateSvc
Definition at line 41 of file CppUnit_SGtestdriver.cxx.
43 ISvcLocator * m_svcLoc;
50 std::string filename_in[SZ] = {
"../cmt/CppUnit_jobOptions.txt",
"../test/CppUnit_jobOptions.txt",
"../share/CppUnit_jobOptions.txt"};
53 for (
int i=0;
i<SZ;
i++)
78 FileName =
"../run/CppUnit_jobOptions_generated.txt";
79 std::system(
"touch ../run/CppUnit_jobOptions_generated.txt; rm ../run/CppUnit_jobOptions_generated.txt");
80 std::ofstream jobopt(
"../run/CppUnit_jobOptions_generated.txt");
83 std::list<std::string>
opts;
84 opts.push_back(
"#pragma print off");
85 opts.push_back(
"ApplicationMgr.Dlls += { \"StoreGate\" };");
87 opts.push_back(
"ApplicationMgr.ExtSvc += { \"ClassIDSvc\" };");
88 opts.push_back(
"ApplicationMgr.ExtSvc += { \"StoreGateSvc\", \"StoreGateSvc/DetectorStore\", \"StoreGateSvc/HistoryStore\" };");
89 opts.push_back(
"ApplicationMgr.ExtSvc += { \"ActiveStoreSvc\" };");
90 opts.push_back(
"AuditorSvc.Auditors += { \"AlgContextAuditor\"};");
91 opts.push_back(
"StoreGateSvc.OutputLevel = 2;");
92 opts.push_back(
"StoreGateSvc.ActivateHistory = false;");
94 opts.push_back(
"MessageSvc.useColors = false;");
95 opts.push_back(
"MessageSvc.OutputLevel = 3;");
97 for ( std::list<std::string>::const_iterator iopt=
opts.begin();
98 iopt!=
opts.end(); ++iopt )
100 jobopt << *iopt << std::endl;
111 std::cerr <<
"This test can not be run" << std::endl;
114 CPPUNIT_ASSERT( 0 != m_svcLoc);
117 static const bool CREATE(
true);
118 bool sc = ( m_svcLoc->service(
"StoreGateSvc",
119 m_storeGate,
CREATE) ).isSuccess();
120 CPPUNIT_ASSERT(
sc );
121 CPPUNIT_ASSERT( 0 != m_storeGate );
123 if (
false ==
sc || 0 == m_storeGate ) {
124 std::string
error =
"No valid pointer to StoreGateSvc !!";
125 std::cerr <<
error << std::endl;
132 std::cerr <<
"Catched : " <<
e.what() << std::endl;