DetectorClocksStandard_test.cc
Go to the documentation of this file.
1 /**
2  * @file DetectorClocksStandard_test.cc
3  * @brief Simple instantiation-only test for DetectorClocksStandard
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date May 6th, 2016
6  */
7 
8 // LArSoft libraries
12 
13 //------------------------------------------------------------------------------
14 //--- The test environment
15 //---
16 
17 /*
18  * TesterEnvironment, configured with a "standard" configuration object, is used
19  * in a non-Boost-unit-test context.
20  * It provides:
21  *
22  */
24 
25 //------------------------------------------------------------------------------
26 //--- The tests
27 //---
28 
29 /** ****************************************************************************
30  * @brief Runs the test
31  * @param argc number of arguments in argv
32  * @param argv arguments to the function
33  * @return number of detected errors (0 on success)
34  * @throw cet::exception most of error situations throw
35  *
36  * The arguments in argv are:
37  * 0. name of the executable ("DetectorClocksStandard_test")
38  * 1. (mandatory) path to the FHiCL configuration file
39  * 2. FHiCL path to the configuration of the test
40  * (default: physics.analyzers.larptest)
41  * 3. FHiCL path to the configuration of DetectorClocks service
42  * (default: services.DetectorClocksService)
43  *
44  */
45 //------------------------------------------------------------------------------
46 int
47 main(int argc, char const** argv)
48 {
49 
51 
52  //
53  // parameter parsing
54  //
55  int iParam = 0;
56 
57  // first argument: configuration file (mandatory)
58  if (++iParam < argc)
59  config.SetConfigurationPath(argv[iParam]);
60  else {
61  std::cerr << "FHiCL configuration file path required as first argument!" << std::endl;
62  return 1;
63  }
64 
65  // second argument: path of the parameter set for geometry test configuration
66  // (optional; default does not have any tester)
67  if (++iParam < argc) config.SetMainTesterParameterSetPath(argv[iParam]);
68 
69  // third argument: path of the parameter set for DetectorClocks configuration
70  // (optional; default: "services.DetectorClocks" from the inherited object)
71  if (++iParam < argc) config.SetServiceParameterSetPath("DetectorClocksService", argv[iParam]);
72 
73  unsigned int nErrors = 0 /* Tester.Run() */;
74 
75  //
76  // testing environment setup
77  //
78  TestEnvironment TestEnv(config);
79 
80  // DetectorClocksStandard supports the simple set up; so we invoke it
81  TestEnv.SimpleProviderSetup<detinfo::DetectorClocksStandard>();
82 
83  // Note that here we are querying the abstract DetectorClocks interface;
84  // this is the right way to go.
85  auto const* detClocks = TestEnv.Provider<detinfo::DetectorClocks>();
86  auto const& detClocksData = detClocks->DataForJob();
87  mf::LogVerbatim("clocks_test")
88  << "TPC clock frame: " << detClocksData.TPCClock().FramePeriod() << " us";
89 
90  detClocksData.debugReport(std::cout);
91 
92  // 4. And finally we cross fingers.
93  if (nErrors > 0) { mf::LogError("clocks_test") << nErrors << " errors detected!"; }
94 
95  return nErrors;
96 } // main()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
DetectorClocksData DataForJob() const override
Returns a complete detinfo::DetectorClocksData object.
int main(int argc, char const **argv)
Runs the test.
Class holding a configuration for a test environment.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Helper functions for support of DetectorClocksService in LArSoft tests.
static Config * config
Definition: config.cpp:1054
Class used for the conversion of times between different formats and references.
A test environment with some support for service providers.
void SetConfigurationPath(std::string path)
Sets the path to the configuration file.
testing::TesterEnvironment< testing::BasicEnvironmentConfiguration > TestEnvironment
Implementation of detinfo::DetectorClocks interface with fixed settings from configuration.
void SetServiceParameterSetPath(std::string service_name, std::string path)
Sets the FHiCL path for the configuration of a test algorithm.
void SetMainTesterParameterSetPath(std::string path)
Sets the FHiCL path for the configuration of the main test algorithm.
QTextStream & endl(QTextStream &s)