File indexing completed on 2024-04-06 12:12:25
0001
0002
0003
0004
0005
0006
0007 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/Framework/interface/EventProcessor.h"
0010 #include "FWCore/Framework/test/stubs/TestBeginEndJobAnalyzer.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/ParameterSet/interface/ProcessDesc.h"
0013 #include "FWCore/ParameterSet/interface/Registry.h"
0014 #include "FWCore/PluginManager/interface/PresenceFactory.h"
0015 #include "FWCore/PluginManager/interface/ProblemTracker.h"
0016 #include "FWCore/ParameterSetReader/interface/ProcessDescImpl.h"
0017 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
0018 #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
0019 #include "FWCore/Utilities/interface/Exception.h"
0020 #include "FWCore/Utilities/interface/Presence.h"
0021 #include "FWCore/Utilities/interface/propagate_const.h"
0022 #include "FWCore/ParameterSetReader/interface/ParameterSetReader.h"
0023
0024 #include "cppunit/extensions/HelperMacros.h"
0025
0026 #include "oneapi/tbb/global_control.h"
0027
0028 #include <regex>
0029
0030 #include <exception>
0031 #include <iostream>
0032 #include <sstream>
0033 #include <string>
0034
0035
0036 void doInit();
0037
0038 class testeventprocessor : public CppUnit::TestFixture {
0039 CPPUNIT_TEST_SUITE(testeventprocessor);
0040 CPPUNIT_TEST(parseTest);
0041 CPPUNIT_TEST(beginEndTest);
0042 CPPUNIT_TEST(cleanupJobTest);
0043 CPPUNIT_TEST(activityRegistryTest);
0044 CPPUNIT_TEST(endpathTest);
0045 CPPUNIT_TEST(serviceConfigSaveTest);
0046 CPPUNIT_TEST(moduleFailureTest);
0047 CPPUNIT_TEST_SUITE_END();
0048
0049 public:
0050 void setUp() {
0051
0052 if (not m_control) {
0053 m_control =
0054 std::make_unique<oneapi::tbb::global_control>(oneapi::tbb::global_control::max_allowed_parallelism, 1);
0055 }
0056 doInit();
0057 m_handler = std::make_unique<edm::AssertHandler>();
0058 sleep_secs_ = 0;
0059 }
0060
0061 void tearDown() { m_handler = nullptr; }
0062 void parseTest();
0063 void beginEndTest();
0064 void cleanupJobTest();
0065 void activityRegistryTest();
0066 void moduleFailureTest();
0067 void endpathTest();
0068 void serviceConfigSaveTest();
0069
0070 private:
0071 edm::propagate_const<std::unique_ptr<edm::AssertHandler>> m_handler;
0072 edm::propagate_const<std::unique_ptr<oneapi::tbb::global_control>> m_control;
0073 void work() {
0074
0075 std::string configuration(
0076 "import FWCore.ParameterSet.Config as cms\n"
0077 "process = cms.Process('p')\n"
0078 "process.maxEvents = cms.untracked.PSet(\n"
0079 " input = cms.untracked.int32(5))\n"
0080 "process.source = cms.Source('EmptySource')\n"
0081 "process.m1 = cms.EDProducer('TestMod',\n"
0082 " ivalue = cms.int32(10))\n"
0083 "process.m2 = cms.EDProducer('TestMod',\n"
0084 " ivalue = cms.int32(-3))\n"
0085 "process.p1 = cms.Path(process.m1*process.m2)\n");
0086 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0087 proc.beginJob();
0088 proc.run();
0089 proc.endJob();
0090 }
0091 int sleep_secs_;
0092 };
0093
0094
0095 CPPUNIT_TEST_SUITE_REGISTRATION(testeventprocessor);
0096
0097 void testeventprocessor::parseTest() {
0098 try {
0099 work();
0100 } catch (cms::Exception& e) {
0101 std::cerr << "cms exception caught: " << e.explainSelf() << std::endl;
0102 CPPUNIT_ASSERT("Caught cms::Exception " == 0);
0103 } catch (std::exception& e) {
0104 std::cerr << "Standard library exception caught: " << e.what() << std::endl;
0105 CPPUNIT_ASSERT("Caught std::exception " == 0);
0106 } catch (...) {
0107 CPPUNIT_ASSERT("Caught unknown exception " == 0);
0108 }
0109 }
0110
0111 void testeventprocessor::beginEndTest() {
0112 std::string configuration(
0113 "import FWCore.ParameterSet.Config as cms\n"
0114 "process = cms.Process('p')\n"
0115 "process.maxEvents = cms.untracked.PSet(\n"
0116 " input = cms.untracked.int32(10))\n"
0117 "process.source = cms.Source('EmptySource')\n"
0118 "process.m1 = cms.EDAnalyzer('TestBeginEndJobAnalyzer')\n"
0119 "process.p1 = cms.Path(process.m1)\n");
0120 {
0121
0122 TestBeginEndJobAnalyzer::control().beginJobCalled = false;
0123 TestBeginEndJobAnalyzer::control().endJobCalled = false;
0124 TestBeginEndJobAnalyzer::control().beginRunCalled = false;
0125 TestBeginEndJobAnalyzer::control().endRunCalled = false;
0126 TestBeginEndJobAnalyzer::control().beginLumiCalled = false;
0127 TestBeginEndJobAnalyzer::control().endLumiCalled = false;
0128
0129 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0130
0131 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginJobCalled);
0132 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endJobCalled);
0133 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginRunCalled);
0134 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endRunCalled);
0135 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginLumiCalled);
0136 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endLumiCalled);
0137 CPPUNIT_ASSERT(0 == proc.totalEvents());
0138
0139 proc.beginJob();
0140
0141
0142
0143 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginJobCalled);
0144 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endJobCalled);
0145 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginRunCalled);
0146 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endRunCalled);
0147 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginLumiCalled);
0148 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endLumiCalled);
0149 CPPUNIT_ASSERT(0 == proc.totalEvents());
0150
0151 proc.endJob();
0152
0153 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginJobCalled);
0154 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endJobCalled);
0155 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginRunCalled);
0156 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endRunCalled);
0157 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginLumiCalled);
0158 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endLumiCalled);
0159 CPPUNIT_ASSERT(0 == proc.totalEvents());
0160
0161 CPPUNIT_ASSERT(not edm::pset::Registry::instance()->empty());
0162 }
0163 CPPUNIT_ASSERT(edm::pset::Registry::instance()->empty());
0164
0165 {
0166
0167
0168 TestBeginEndJobAnalyzer::control().beginJobCalled = false;
0169 TestBeginEndJobAnalyzer::control().endJobCalled = false;
0170 TestBeginEndJobAnalyzer::control().beginRunCalled = false;
0171 TestBeginEndJobAnalyzer::control().endRunCalled = false;
0172 TestBeginEndJobAnalyzer::control().beginLumiCalled = false;
0173 TestBeginEndJobAnalyzer::control().endLumiCalled = false;
0174
0175 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0176 proc.runToCompletion();
0177
0178 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginJobCalled);
0179 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endJobCalled);
0180 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginRunCalled);
0181 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endRunCalled);
0182 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginLumiCalled);
0183 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endLumiCalled);
0184 CPPUNIT_ASSERT(10 == proc.totalEvents());
0185 CPPUNIT_ASSERT(not edm::pset::Registry::instance()->empty());
0186 }
0187 CPPUNIT_ASSERT(edm::pset::Registry::instance()->empty());
0188 {
0189
0190
0191 TestBeginEndJobAnalyzer::control().beginJobCalled = false;
0192 TestBeginEndJobAnalyzer::control().endJobCalled = false;
0193 TestBeginEndJobAnalyzer::control().beginRunCalled = false;
0194 TestBeginEndJobAnalyzer::control().endRunCalled = false;
0195 TestBeginEndJobAnalyzer::control().beginLumiCalled = false;
0196 TestBeginEndJobAnalyzer::control().endLumiCalled = false;
0197
0198 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0199 proc.beginJob();
0200 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginJobCalled);
0201
0202
0203 TestBeginEndJobAnalyzer::control().beginJobCalled = false;
0204
0205 proc.runToCompletion();
0206
0207 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginJobCalled);
0208 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endJobCalled);
0209 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginRunCalled);
0210 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endRunCalled);
0211 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginLumiCalled);
0212 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endLumiCalled);
0213 CPPUNIT_ASSERT(10 == proc.totalEvents());
0214
0215 proc.endJob();
0216
0217 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginJobCalled);
0218 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endJobCalled);
0219 CPPUNIT_ASSERT(10 == proc.totalEvents());
0220 }
0221 {
0222 TestBeginEndJobAnalyzer::control().beginJobCalled = false;
0223 TestBeginEndJobAnalyzer::control().endJobCalled = false;
0224 TestBeginEndJobAnalyzer::control().beginRunCalled = false;
0225 TestBeginEndJobAnalyzer::control().endRunCalled = false;
0226 TestBeginEndJobAnalyzer::control().beginLumiCalled = false;
0227 TestBeginEndJobAnalyzer::control().endLumiCalled = false;
0228
0229 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0230 proc.beginJob();
0231
0232
0233 TestBeginEndJobAnalyzer::control().beginJobCalled = false;
0234
0235 proc.run();
0236
0237 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginJobCalled);
0238 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endJobCalled);
0239 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginRunCalled);
0240 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endRunCalled);
0241 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginLumiCalled);
0242 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endLumiCalled);
0243 CPPUNIT_ASSERT(10 == proc.totalEvents());
0244
0245 proc.endJob();
0246
0247
0248 TestBeginEndJobAnalyzer::control().endRunCalled = false;
0249 TestBeginEndJobAnalyzer::control().endLumiCalled = false;
0250 }
0251 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endRunCalled);
0252 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endLumiCalled);
0253 {
0254 TestBeginEndJobAnalyzer::control().beginJobCalled = false;
0255 TestBeginEndJobAnalyzer::control().endJobCalled = false;
0256 TestBeginEndJobAnalyzer::control().beginRunCalled = false;
0257 TestBeginEndJobAnalyzer::control().endRunCalled = false;
0258 TestBeginEndJobAnalyzer::control().beginLumiCalled = false;
0259 TestBeginEndJobAnalyzer::control().endLumiCalled = false;
0260
0261 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0262 proc.run();
0263
0264 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginJobCalled);
0265 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endJobCalled);
0266 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginRunCalled);
0267 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endRunCalled);
0268 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginLumiCalled);
0269 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endLumiCalled);
0270 CPPUNIT_ASSERT(10 == proc.totalEvents());
0271
0272
0273 TestBeginEndJobAnalyzer::control().beginJobCalled = false;
0274 TestBeginEndJobAnalyzer::control().beginRunCalled = false;
0275 TestBeginEndJobAnalyzer::control().beginLumiCalled = false;
0276 TestBeginEndJobAnalyzer::control().endRunCalled = false;
0277 TestBeginEndJobAnalyzer::control().endLumiCalled = false;
0278
0279 proc.endJob();
0280
0281 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginJobCalled);
0282 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endJobCalled);
0283 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginRunCalled);
0284 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endRunCalled);
0285 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().beginLumiCalled);
0286 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endLumiCalled);
0287 CPPUNIT_ASSERT(10 == proc.totalEvents());
0288
0289
0290 TestBeginEndJobAnalyzer::control().endRunCalled = false;
0291 TestBeginEndJobAnalyzer::control().endLumiCalled = false;
0292 }
0293 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endRunCalled);
0294 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endLumiCalled);
0295
0296 {
0297 TestBeginEndJobAnalyzer::control().beginJobCalled = false;
0298 TestBeginEndJobAnalyzer::control().endJobCalled = false;
0299 TestBeginEndJobAnalyzer::control().beginRunCalled = false;
0300 TestBeginEndJobAnalyzer::control().endRunCalled = false;
0301 TestBeginEndJobAnalyzer::control().beginLumiCalled = false;
0302 TestBeginEndJobAnalyzer::control().endLumiCalled = false;
0303
0304 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0305 proc.run();
0306
0307 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginJobCalled);
0308 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endJobCalled);
0309 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginRunCalled);
0310 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endRunCalled);
0311 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().beginLumiCalled);
0312 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endLumiCalled);
0313 CPPUNIT_ASSERT(10 == proc.totalEvents());
0314 }
0315 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().endJobCalled);
0316 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endRunCalled);
0317 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().endLumiCalled);
0318 }
0319
0320 void testeventprocessor::cleanupJobTest() {
0321
0322 std::string configuration(
0323 "import FWCore.ParameterSet.Config as cms\n"
0324 "process = cms.Process('p')\n"
0325 "process.maxEvents = cms.untracked.PSet(\n"
0326 " input = cms.untracked.int32(2))\n"
0327 "process.source = cms.Source('EmptySource')\n"
0328 "process.m1 = cms.EDAnalyzer('TestBeginEndJobAnalyzer')\n"
0329 "process.p1 = cms.Path(process.m1)\n");
0330 {
0331
0332
0333 TestBeginEndJobAnalyzer::control().destructorCalled = false;
0334 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0335
0336 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().destructorCalled);
0337 proc.beginJob();
0338 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().destructorCalled);
0339 proc.endJob();
0340 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().destructorCalled);
0341 }
0342 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().destructorCalled);
0343 {
0344
0345
0346 TestBeginEndJobAnalyzer::control().destructorCalled = false;
0347 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0348
0349 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().destructorCalled);
0350 proc.run();
0351 CPPUNIT_ASSERT(2 == proc.totalEvents());
0352 CPPUNIT_ASSERT(!TestBeginEndJobAnalyzer::control().destructorCalled);
0353 }
0354 CPPUNIT_ASSERT(TestBeginEndJobAnalyzer::control().destructorCalled);
0355 }
0356
0357 namespace {
0358 struct Listener {
0359 Listener(edm::ActivityRegistry& iAR)
0360 : postBeginJob_(0),
0361 postEndJob_(0),
0362 preEventProcessing_(0),
0363 postEventProcessing_(0),
0364 preModule_(0),
0365 postModule_(0) {
0366 iAR.watchPostBeginJob(this, &Listener::postBeginJob);
0367 iAR.watchPostEndJob(this, &Listener::postEndJob);
0368
0369 iAR.watchPreEvent(this, &Listener::preEventProcessing);
0370 iAR.watchPostEvent(this, &Listener::postEventProcessing);
0371
0372 iAR.watchPreModuleEvent(this, &Listener::preModule);
0373 iAR.watchPostModuleEvent(this, &Listener::postModule);
0374 }
0375
0376 void postBeginJob() { ++postBeginJob_; }
0377 void postEndJob() { ++postEndJob_; }
0378
0379 void preEventProcessing(edm::StreamContext const&) { ++preEventProcessing_; }
0380 void postEventProcessing(edm::StreamContext const&) { ++postEventProcessing_; }
0381
0382 void preModule(edm::StreamContext const&, edm::ModuleCallingContext const&) { ++preModule_; }
0383 void postModule(edm::StreamContext const&, edm::ModuleCallingContext const&) { ++postModule_; }
0384
0385 unsigned int postBeginJob_;
0386 unsigned int postEndJob_;
0387 unsigned int preEventProcessing_;
0388 unsigned int postEventProcessing_;
0389 unsigned int preModule_;
0390 unsigned int postModule_;
0391 };
0392 }
0393
0394 void testeventprocessor::activityRegistryTest() {
0395 std::string configuration(
0396 "import FWCore.ParameterSet.Config as cms\n"
0397 "process = cms.Process('p')\n"
0398 "process.maxEvents = cms.untracked.PSet(\n"
0399 " input = cms.untracked.int32(5))\n"
0400 "process.source = cms.Source('EmptySource')\n"
0401 "process.m1 = cms.EDProducer('TestMod',\n"
0402 " ivalue = cms.int32(-3))\n"
0403 "process.p1 = cms.Path(process.m1)\n");
0404
0405 std::shared_ptr<edm::ParameterSet> parameterSet = ProcessDescImpl(configuration, false).parameterSet();
0406 auto processDesc = std::make_shared<edm::ProcessDesc>(parameterSet);
0407
0408
0409
0410
0411 std::vector<edm::ParameterSet> serviceConfigs;
0412 edm::ServiceToken token = edm::ServiceRegistry::createSet(serviceConfigs);
0413
0414 edm::ActivityRegistry ar;
0415 token.connect(ar);
0416 Listener listener(ar);
0417
0418 edm::EventProcessor proc(processDesc, token, edm::serviceregistry::kOverlapIsError);
0419
0420 proc.beginJob();
0421 proc.run();
0422 proc.endJob();
0423
0424 CPPUNIT_ASSERT(listener.postBeginJob_ == 1);
0425 CPPUNIT_ASSERT(listener.postEndJob_ == 1);
0426 CPPUNIT_ASSERT(listener.preEventProcessing_ == 5);
0427 CPPUNIT_ASSERT(listener.postEventProcessing_ == 5);
0428 CPPUNIT_ASSERT(listener.preModule_ == 15);
0429 CPPUNIT_ASSERT(listener.postModule_ == 15);
0430
0431 typedef std::vector<edm::ModuleDescription const*> ModuleDescs;
0432 ModuleDescs allModules = proc.getAllModuleDescriptions();
0433 CPPUNIT_ASSERT(3 == allModules.size());
0434
0435 for (ModuleDescs::const_iterator i = allModules.begin(), e = allModules.end(); i != e; ++i) {
0436 CPPUNIT_ASSERT(*i != 0);
0437
0438 }
0439
0440
0441 CPPUNIT_ASSERT(5 == proc.totalEvents());
0442 CPPUNIT_ASSERT(5 == proc.totalEventsPassed());
0443 }
0444
0445 static bool findModuleName(std::string const& iMessage) {
0446 static std::regex const expr("TestFailuresAnalyzer");
0447 return regex_search(iMessage, expr);
0448 }
0449
0450 void testeventprocessor::moduleFailureTest() {
0451 try {
0452 std::string const preC(
0453 "import FWCore.ParameterSet.Config as cms\n"
0454 "process = cms.Process('p')\n"
0455 "process.maxEvents = cms.untracked.PSet(\n"
0456 " input = cms.untracked.int32(2))\n"
0457 "process.source = cms.Source('EmptySource')\n"
0458 "process.m1 = cms.EDAnalyzer('TestFailuresAnalyzer',\n"
0459 " whichFailure = cms.int32(");
0460
0461 std::string const postC(
0462 "))\n"
0463 "process.p1 = cms.Path(process.m1)\n");
0464
0465 {
0466 std::string const configuration = preC + "0" + postC;
0467 bool threw = true;
0468 try {
0469 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0470 threw = false;
0471 } catch (cms::Exception const& iException) {
0472 if (!findModuleName(iException.explainSelf())) {
0473 std::cout << iException.explainSelf() << std::endl;
0474 CPPUNIT_ASSERT(0 == "module name not in exception message");
0475 }
0476 }
0477 CPPUNIT_ASSERT(threw && 0 != "exception never thrown");
0478 }
0479 {
0480 std::string const configuration = preC + "1" + postC;
0481 bool threw = true;
0482 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0483
0484 try {
0485 proc.beginJob();
0486 threw = false;
0487 } catch (cms::Exception const& iException) {
0488 if (!findModuleName(iException.explainSelf())) {
0489 std::cout << iException.explainSelf() << std::endl;
0490 CPPUNIT_ASSERT(0 == "module name not in exception message");
0491 }
0492 }
0493 CPPUNIT_ASSERT(threw && 0 != "exception never thrown");
0494 }
0495
0496 {
0497 std::string const configuration = preC + "2" + postC;
0498 bool threw = true;
0499 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0500
0501 proc.beginJob();
0502 try {
0503 proc.run();
0504 threw = false;
0505 } catch (cms::Exception const& iException) {
0506 if (!findModuleName(iException.explainSelf())) {
0507 std::cout << iException.explainSelf() << std::endl;
0508 CPPUNIT_ASSERT(0 == "module name not in exception message");
0509 }
0510 }
0511 CPPUNIT_ASSERT(threw && 0 != "exception never thrown");
0512 proc.endJob();
0513 }
0514 {
0515 std::string const configuration = preC + "3" + postC;
0516 bool threw = true;
0517 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0518
0519 proc.beginJob();
0520 try {
0521 proc.endJob();
0522 threw = false;
0523 } catch (cms::Exception const& iException) {
0524 if (!findModuleName(iException.explainSelf())) {
0525 std::cout << iException.explainSelf() << std::endl;
0526 CPPUNIT_ASSERT(0 == "module name not in exception message");
0527 }
0528 }
0529 CPPUNIT_ASSERT(threw && 0 != "exception never thrown");
0530 }
0531
0532 {
0533 bool threw = true;
0534 try {
0535 std::string configuration(
0536 "import FWCore.ParameterSet.Config as cms\n"
0537 "process = cms.Process('p')\n"
0538 "process.maxEvents = cms.untracked.PSet(\n"
0539 " input = cms.untracked.int32(2))\n"
0540 "process.source = cms.Source('EmptySource')\n"
0541 "process.p1 = cms.Path(process.m1)\n");
0542 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0543
0544 threw = false;
0545 } catch (cms::Exception const& iException) {
0546 static std::regex const expr("m1");
0547 if (!regex_search(iException.explainSelf(), expr)) {
0548 std::cout << iException.explainSelf() << std::endl;
0549 CPPUNIT_ASSERT(0 == "module name not in exception message");
0550 }
0551 }
0552 CPPUNIT_ASSERT(threw && 0 != "exception never thrown");
0553 }
0554 } catch (cms::Exception const& iException) {
0555 std::cout << "Unexpected exception " << iException.explainSelf() << std::endl;
0556 throw;
0557 }
0558 }
0559
0560 void testeventprocessor::serviceConfigSaveTest() {
0561 std::string configuration(
0562 "import FWCore.ParameterSet.Config as cms\n"
0563 "process = cms.Process('p')\n"
0564 "process.add_(cms.Service('DummyStoreConfigService'))\n"
0565 "process.maxEvents = cms.untracked.PSet(\n"
0566 " input = cms.untracked.int32(5))\n"
0567 "process.source = cms.Source('EmptySource')\n"
0568 "process.m1 = cms.EDProducer('TestMod',\n"
0569 " ivalue = cms.int32(-3))\n"
0570 "process.p1 = cms.Path(process.m1)\n");
0571
0572 edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0573 edm::ProcessConfiguration const& processConfiguration = proc.processConfiguration();
0574 edm::ParameterSet const& topPset(edm::getParameterSet(processConfiguration.parameterSetID()));
0575 CPPUNIT_ASSERT(topPset.existsAs<edm::ParameterSet>("DummyStoreConfigService", true));
0576 }
0577
0578 void testeventprocessor::endpathTest() {}