File indexing completed on 2024-04-06 12:12:24
0001
0002
0003
0004
0005
0006 #include <exception>
0007 #include <iostream>
0008 #include <string>
0009 #include <stdexcept>
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/Framework/interface/EventProcessor.h"
0012 #include "FWCore/Utilities/interface/Exception.h"
0013 #include "cppunit/extensions/HelperMacros.h"
0014 #include "FWCore/PluginManager/interface/PluginManager.h"
0015 #include "FWCore/PluginManager/interface/standard.h"
0016 #include "FWCore/ParameterSetReader/interface/ParameterSetReader.h"
0017
0018 #include "oneapi/tbb/global_control.h"
0019
0020
0021 void doInit() {
0022 static bool firstTime = true;
0023 if (firstTime) {
0024
0025 if (not edmplugin::PluginManager::isAvailable()) {
0026 edmplugin::PluginManager::configure(edmplugin::standard::config());
0027 }
0028 firstTime = false;
0029 }
0030 }
0031
0032 class testeventprocessor2 : public CppUnit::TestFixture {
0033 CPPUNIT_TEST_SUITE(testeventprocessor2);
0034 CPPUNIT_TEST(eventprocessor2Test);
0035 CPPUNIT_TEST_SUITE_END();
0036
0037 edm::propagate_const<std::unique_ptr<oneapi::tbb::global_control>> m_control;
0038
0039 public:
0040 void setUp() {
0041 if (not m_control) {
0042 m_control =
0043 std::make_unique<oneapi::tbb::global_control>(oneapi::tbb::global_control::max_allowed_parallelism, 1);
0044 }
0045
0046 doInit();
0047 }
0048 void tearDown() {}
0049 void eventprocessor2Test();
0050 };
0051
0052
0053 CPPUNIT_TEST_SUITE_REGISTRATION(testeventprocessor2);
0054
0055 void work() {
0056
0057 std::string configuration(
0058 "import FWCore.ParameterSet.Config as cms\n"
0059 "process = cms.Process('PROD')\n"
0060 "process.maxEvents = cms.untracked.PSet(\n"
0061 " input = cms.untracked.int32(5))\n"
0062 "process.source = cms.Source('EmptySource')\n"
0063 "process.m1 = cms.EDProducer('IntProducer',\n"
0064 " ivalue = cms.int32(10))\n"
0065 "process.m2 = cms.EDProducer('ToyDoubleProducer',\n"
0066 " dvalue = cms.double(3.3))\n"
0067 "process.out = cms.OutputModule('AsciiOutputModule')\n"
0068 "process.p1 = cms.Path(process.m1*process.m2)\n"
0069 "process.ep1 = cms.EndPath(process.out)");
0070 std::unique_ptr<edm::ParameterSet> pset = edm::getPSetFromConfig(configuration);
0071 edm::EventProcessor proc(std::move(pset));
0072 proc.beginJob();
0073 proc.run();
0074 proc.endJob();
0075 }
0076
0077 void testeventprocessor2::eventprocessor2Test() {
0078 try {
0079 work();
0080 } catch (cms::Exception& e) {
0081 std::cerr << "CMS exception caught: " << e.explainSelf() << std::endl;
0082 CPPUNIT_ASSERT("cms Exception caught in testeventprocessor2::eventprocessor2Test" == 0);
0083 } catch (std::runtime_error& e) {
0084 std::cerr << "Standard library exception caught: " << e.what() << std::endl;
0085 CPPUNIT_ASSERT("std Exception caught in testeventprocessor2::eventprocessor2Test" == 0);
0086 } catch (...) {
0087 std::cerr << "Unknown exception caught" << std::endl;
0088 CPPUNIT_ASSERT("unkown Exception caught in testeventprocessor2::eventprocessor2Test" == 0);
0089 }
0090 }