Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:32

0001 /*----------------------------------------------------------------------
0002 
0003 Test of a non cmsRun executable
0004 
0005 Note that the commented out lines are what is necessary to
0006 setup the MessageLogger in this test. Note that tests like
0007 this will hang after 1000 messages are sent to the MessageLogger
0008 if the MessageLogger is not runnning.
0009 
0010 ----------------------------------------------------------------------*/
0011 
0012 #include "FWCore/PluginManager/interface/ProblemTracker.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/Framework/interface/EventProcessor.h"
0015 #include "FWCore/ParameterSetReader/interface/ParameterSetReader.h"
0016 #include "FWCore/Utilities/interface/propagate_const.h"
0017 #include "FWCore/Concurrency/interface/ThreadsController.h"
0018 // #include "FWCore/Utilities/interface/Presence.h"
0019 // #include "FWCore/PluginManager/interface/PresenceFactory.h"
0020 
0021 #include <cppunit/extensions/HelperMacros.h>
0022 
0023 #include <memory>
0024 #include <string>
0025 
0026 class testStandalone : public CppUnit::TestFixture {
0027   CPPUNIT_TEST_SUITE(testStandalone);
0028   CPPUNIT_TEST(writeAndReadFile);
0029   CPPUNIT_TEST_SUITE_END();
0030 
0031 public:
0032   void setUp() {
0033     m_handler = std::make_unique<edm::AssertHandler>();
0034     m_scheduler = std::make_unique<edm::ThreadsController>(1);
0035   }
0036 
0037   void tearDown() {
0038     m_handler = nullptr;  // propagate_const<T> has no reset() function
0039   }
0040 
0041   void writeAndReadFile();
0042 
0043 private:
0044   edm::propagate_const<std::unique_ptr<edm::AssertHandler>> m_handler;
0045   edm::propagate_const<std::unique_ptr<edm::ThreadsController>> m_scheduler;
0046 };
0047 
0048 ///registration of the test so that the runner can find it
0049 CPPUNIT_TEST_SUITE_REGISTRATION(testStandalone);
0050 
0051 void testStandalone::writeAndReadFile() {
0052   {
0053     std::string configuration(
0054         "import FWCore.ParameterSet.Config as cms\n"
0055         "process = cms.Process('TEST')\n"
0056         "process.maxEvents = cms.untracked.PSet(\n"
0057         "    input = cms.untracked.int32(5)\n"
0058         ")\n"
0059         "process.source = cms.Source('EmptySource')\n"
0060         "process.JobReportService = cms.Service('JobReportService')\n"
0061         "process.InitRootHandlers = cms.Service('InitRootHandlers')\n"
0062         "process.m1 = cms.EDProducer('IntProducer',\n"
0063         "    ivalue = cms.int32(11)\n"
0064         ")\n"
0065         "process.out = cms.OutputModule('PoolOutputModule',\n"
0066         "    fileName = cms.untracked.string('testStandalone.root')\n"
0067         ")\n"
0068         "process.p = cms.Path(process.m1)\n"
0069         "process.e = cms.EndPath(process.out)\n");
0070 
0071     edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0072     proc.beginJob();
0073     proc.run();
0074     proc.endJob();
0075   }
0076 
0077   {
0078     std::string configuration(
0079         "import FWCore.ParameterSet.Config as cms\n"
0080         "process = cms.Process('TEST1')\n"
0081         "process.source = cms.Source('PoolSource',\n"
0082         "    fileNames = cms.untracked.vstring('file:testStandalone.root')\n"
0083         ")\n"
0084         "process.InitRootHandlers = cms.Service('InitRootHandlers')\n"
0085         "process.JobReportService = cms.Service('JobReportService')\n"
0086         "process.add_(cms.Service('SiteLocalConfigService'))\n");
0087 
0088     edm::EventProcessor proc(edm::getPSetFromConfig(configuration));
0089     proc.beginJob();
0090     proc.run();
0091     proc.endJob();
0092   }
0093 }