testRunController.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <list>
4 
5 #include <fwk/CentralConfig.h>
6 #include <fwk/RunController.h>
7 
8 #include <cppunit/extensions/HelperMacros.h>
9 
10 using namespace fwk;
11 using namespace std;
12 
13 
14 class testRunController : public CppUnit::TestFixture {
15 
16  CPPUNIT_TEST_SUITE(testRunController);
17  CPPUNIT_TEST(testSequence);
18  CPPUNIT_TEST(testModuleNames);
19  CPPUNIT_TEST(testModuleVersionInfo);
20  CPPUNIT_TEST_SUITE_END();
21 
22 public:
23  void setUp() { }
24 
25  void tearDown() { }
26 
27  void
29  {
30  cout << "**************************\n"
31  " Test of RunController\n"
32  "**************************" << endl;
33 
34  // Instantiate the central configuration handler, passing the name
35  // of the bootstrap XML file.
36  //
37  CentralConfig::GetInstance(BOOTSTRAPFILE);
38 
39  RunController& theController = RunController::GetInstance();
40 
41  // Initialize the RunController. This loads up the sequence. You set the
42  // pointer to the sequencing file inside bootstrap.xml
43  //
44  cout << "\n"
45  "Initializing modules.\n"
46  "----------------------\n"
47  "(there are " << theController.GetNumberOfRegisteredModules() << " registered modules)\n"
48  "(registered module names " << theController.GetRegisteredModuleNames() << ')' << endl;
49 
50  theController.Init();
51 
52  // Execute the sequence
53  //
54  cout << "\n"
55  "Sequencing the modules\n"
56  "-----------------------" << endl;
57  theController.Run();
58 
59  // Call the Finish() method of all the modules
60  //
61  cout << "\n"
62  "Finishing modules\n"
63  "------------------" << endl;
64  theController.Finish();
65  }
66 
67  void
69  {
70  set<string> knownNames;
71  knownNames.insert("DummyBreakModule");
72  knownNames.insert("DummyContinueModule");
73  knownNames.insert("DummyModule1");
74  knownNames.insert("DummyModule2");
75  knownNames.insert("DummyModule3");
76  knownNames.insert("DummyModule4");
77  knownNames.insert("DummyResetModule");
78  knownNames.insert("ModuleWithSpecialName");
79  knownNames.insert("SetEventDataModule1");
80  knownNames.insert("SetEventDataModule2");
81  knownNames.insert("DummyCounterModule");
82  knownNames.insert("DummyCheckCounterModuleValue5");
83  knownNames.insert("DummyResetCounterModule");
84 
85  const set<string>& names = RunController::GetInstance().GetUsedModuleNames();
86 
87  if (names != knownNames) {
88  cout << "\n"
89  "Lists don't match:\n"
90  " This:";
91  for (set<string>::const_iterator it = names.begin();
92  it != names.end(); ++it)
93  cout << ' ' << *it;
94  cout << "\n"
95  "Should be:";
96  for (set<string>::const_iterator it = knownNames.begin();
97  it != knownNames.end(); ++it)
98  cout << ' ' << *it;
99  cout << endl;
100  }
101 
102  CPPUNIT_ASSERT(names == knownNames);
103  }
104 
105 
106  void
108  {
109  // test printout of version info for module.
110 
111  VModule& mod = RunController::GetInstance().GetModule("DummyModule1");
112  cout << "filename : " << mod.GetVersionInfo(VModule::eFilename) << "\n"
113  "revision : " << mod.GetVersionInfo(VModule::eRevisionNumber) << "\n"
114  "date : " << mod.GetVersionInfo(VModule::eDate) << "\n"
115  "time : " << mod.GetVersionInfo(VModule::eTime) << "\n"
116  "last editor: " << mod.GetVersionInfo(VModule::eLastEditor) << endl;
117  }
118 
119 };
120 
121 
std::string GetRegisteredModuleNames() const
Get list of all module builder names and module versions in the registry.
virtual void Init()
std::string GetVersionInfo(const VersionInfoType v) const
Retrieve different sorts of module version info.
Definition: VModule.cc:26
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
Auger Software Run Control.
Definition: RunController.h:26
Module interface.
Definition: VModule.h:53
int GetNumberOfRegisteredModules() const
Return number of registered modules.
virtual void Finish()
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
double mod(const double d, const double periode)
virtual void Run()

, generated on Tue Sep 26 2023.