Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar::ServicePackTest Class Reference

Test module for ServicePack.h utilities depending on art farmework. More...

Inheritance diagram for lar::ServicePackTest:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 ServicePackTest (fhicl::ParameterSet const &)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void beginJob () override
 Run event-independent tests. More...
 
void analyze (const art::Event &) override
 Run event-dependent tests (none so far) More...
 
void endJob () override
 Throws if errors have been accumulated. More...
 
Test functions
void extractProviders_test_plain ()
 Tests lar::extractProviders() More...
 
void extractProviders_test_permuted ()
 Tests lar::extractProviders() and permuted constructor. More...
 
void extractProviders_test_reduced ()
 Tests lar::extractProviders() and assignment to reduced pack. More...
 
void extractProviders_tests ()
 All tests on lar::extractProviders() More...
 

Private Attributes

std::vector< std::stringerrors
 list of collected errors More...
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Test module for ServicePack.h utilities depending on art farmework.

Currently exercises:

Throws an exception on failure.

Service requirements

This module requires the following services to be configured:

Configuration parameters

Currently none.

Definition at line 75 of file ServicePackTest_module.cc.

Constructor & Destructor Documentation

lar::ServicePackTest::ServicePackTest ( fhicl::ParameterSet const &  )
explicit

Definition at line 122 of file ServicePackTest_module.cc.

122 : EDAnalyzer(pset) {}
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25

Member Function Documentation

void lar::ServicePackTest::analyze ( const art::Event )
inlineoverrideprivate

Run event-dependent tests (none so far)

Definition at line 85 of file ServicePackTest_module.cc.

86  {}
void lar::ServicePackTest::beginJob ( )
overrideprivatevirtual

Run event-independent tests.

Reimplemented from art::EDAnalyzer.

Definition at line 126 of file ServicePackTest_module.cc.

127  {
129  } // ServicePackTest::beginJob()
void extractProviders_tests()
All tests on lar::extractProviders()
void lar::ServicePackTest::endJob ( )
overrideprivatevirtual

Throws if errors have been accumulated.

Reimplemented from art::EDAnalyzer.

Definition at line 133 of file ServicePackTest_module.cc.

134  {
135  if (errors.empty()) {
136  mf::LogInfo("ServicePackTest") << "All tests were successful.";
137  return;
138  }
139 
140  mf::LogError log("ServicePackTest");
141  log << errors.size() << " errors detected:";
142 
143  for (std::string const& error : errors)
144  log << "\n - " << error;
145 
146  throw art::Exception(art::errors::LogicError) << errors.size() << " errors detected";
147  }
std::vector< std::string > errors
list of collected errors
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
error
Definition: include.cc:26
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void lar::ServicePackTest::extractProviders_test_permuted ( )
private

Tests lar::extractProviders() and permuted constructor.

Definition at line 191 of file ServicePackTest_module.cc.

192  {
193  /*
194  * The test creates a ProviderPack and checks that its element as as
195  * expected.
196  *
197  * The expected value is extracted from the framework in the "traditional"
198  * way.
199  *
200  * The order of the providers is different from the order of the services;
201  * in this way a "wrong" ProviderPack will be (deliberately) created,
202  * and the code will have to convert it to the right pack.
203  */
204 
205  // these are the "solutions":
206  geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
207  detinfo::LArProperties const* larprop = lar::providerFrom<detinfo::LArPropertiesService>();
208 
209  auto providers = lar::extractProviders<geo::Geometry, detinfo::LArPropertiesService>();
210 
211  // check time
212  if (providers.get<geo::GeometryCore>() != geom) {
213  errors.push_back("wrong geometry provider (got " +
214  ::to_string(providers.get<geo::GeometryCore>()) + ", expected " +
215  ::to_string(geom) + ") [permuted]");
216  }
217  if (providers.get<detinfo::LArProperties>() != larprop) {
218  errors.push_back("wrong LAr properties provider (got " +
219  ::to_string(providers.get<detinfo::LArProperties>()) + ", expected " +
220  ::to_string(larprop) + ") [permuted]");
221  }
222  }
std::vector< std::string > errors
list of collected errors
Description of geometry of one entire detector.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void lar::ServicePackTest::extractProviders_test_plain ( )
private

Tests lar::extractProviders()

Definition at line 160 of file ServicePackTest_module.cc.

161  {
162  /*
163  * The test creates a ProviderPack and checks that its element as as
164  * expected.
165  *
166  * The expected value is extracted from the framework in the "traditional"
167  * way.
168  */
169 
170  // these are the "solutions":
171  geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
172  detinfo::LArProperties const* larprop = lar::providerFrom<detinfo::LArPropertiesService>();
173 
174  auto providers = lar::extractProviders<geo::Geometry, detinfo::LArPropertiesService>();
175 
176  // check time
177  if (providers.get<geo::GeometryCore>() != geom) {
178  errors.push_back("wrong geometry provider (got " +
179  ::to_string(providers.get<geo::GeometryCore>()) + ", expected " +
180  ::to_string(geom) + ")");
181  }
182  if (providers.get<detinfo::LArProperties>() != larprop) {
183  errors.push_back("wrong LAr properties provider (got " +
184  ::to_string(providers.get<detinfo::LArProperties>()) + ", expected " +
185  ::to_string(larprop) + ")");
186  }
187  } // ServicePackTest::extractProviders_test_plain()
std::vector< std::string > errors
list of collected errors
Description of geometry of one entire detector.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void lar::ServicePackTest::extractProviders_test_reduced ( )
private

Tests lar::extractProviders() and assignment to reduced pack.

Definition at line 226 of file ServicePackTest_module.cc.

227  {
228  /*
229  * The test creates a ProviderPack and checks that its element as as
230  * expected.
231  *
232  * The expected value is extracted from the framework in the "traditional"
233  * way.
234  *
235  * We use a smaller provider pack to store the providers;
236  * DetectorProperties will be dropped.
237  */
238 
239  // these are the "solutions":
240  geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
241  detinfo::LArProperties const* larprop = lar::providerFrom<detinfo::LArPropertiesService>();
242  auto providers = lar::extractProviders<geo::Geometry, detinfo::LArPropertiesService>();
243 
244  // check time
245  if (providers.get<geo::GeometryCore>() != geom) {
246  errors.push_back("wrong geometry provider (got " +
247  ::to_string(providers.get<geo::GeometryCore>()) + ", expected " +
248  ::to_string(geom) + ") [reduced]");
249  }
250  if (providers.get<detinfo::LArProperties>() != larprop) {
251  errors.push_back("wrong LAr properties provider (got " +
252  ::to_string(providers.get<detinfo::LArProperties>()) + ", expected " +
253  ::to_string(larprop) + ") [reduced]");
254  }
255  }
std::vector< std::string > errors
list of collected errors
Description of geometry of one entire detector.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void lar::ServicePackTest::extractProviders_tests ( )
private

All tests on lar::extractProviders()

Definition at line 151 of file ServicePackTest_module.cc.

152  {
156  }
void extractProviders_test_reduced()
Tests lar::extractProviders() and assignment to reduced pack.
void extractProviders_test_plain()
Tests lar::extractProviders()
void extractProviders_test_permuted()
Tests lar::extractProviders() and permuted constructor.

Member Data Documentation

std::vector<std::string> lar::ServicePackTest::errors
private

list of collected errors

Definition at line 108 of file ServicePackTest_module.cc.


The documentation for this class was generated from the following file: