Skip to content

Commit

Permalink
Move code shared by executable and plugin to an existing library
Browse files Browse the repository at this point in the history
The unit test analyzer TestBeginEndJobAnalyzer has a static used
by the unit test to see that all transitions happened. When compiled
with clang the unit test failed presumably because we had mulitple
copies of the static. This change fixes the problem and makes the code
obey the C++ one definition rule.
  • Loading branch information
Dr15Jones committed Oct 6, 2014
1 parent 4f96191 commit 276be4d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
6 changes: 4 additions & 2 deletions FWCore/Framework/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<library file="DummyData.cc,DummyRecord.cc,DepRecord.cc,Dummy2Record.cc,DepOn2Record.cc" name="FWCoreFrameworkTestDummyForEventSetup">
<use name="FWCore/Framework"/>
</library>
<library file="MockEventProcessor.cc" name="FWCoreFrameworkTest">
<library file="MockEventProcessor.cc,stubs/TestBeginEndJobAnalyzer.cc" name="FWCoreFrameworkTest">
<use name="FWCore/Framework"/>
</library>
<library file="stubs/TestOutputModule.cc" name="TestOutputModule">
Expand Down Expand Up @@ -131,8 +131,9 @@
<use name="FWCore/Framework"/>
<use name="cppunit"/>
</library>
<library file="stubs/TestBeginEndJobAnalyzer.cc,stubs/TestBeginEndJobAnalyzerModule.cc" name="FWCoreFrameworkTestBeginEndJobAnalyzer">
<library file="stubs/TestBeginEndJobAnalyzerModule.cc" name="FWCoreFrameworkTestBeginEndJobAnalyzer">
<flags EDM_PLUGIN="1"/>
<lib name="FWCoreFrameworkTest"/>
<use name="FWCore/Framework"/>
</library>
<library file="stubs/TestFailuresAnalyzer.cc" name="FWCoreFrameworkTestFailuresAnalyzer">
Expand Down Expand Up @@ -169,6 +170,7 @@
<use name="cppunit"/>
</bin>
<bin name="TestFWCoreFrameworkeventprocessor" file="testRunner.cpp,eventprocessor2_t.cppunit.cc,eventprocessor_t.cppunit.cc">
<lib name="FWCoreFrameworkTest"/>
<use name="DataFormats/Provenance"/>
<use name="DataFormats/WrappedStdDictionaries"/>
<use name="FWCore/Framework"/>
Expand Down
6 changes: 6 additions & 0 deletions FWCore/Framework/test/stubs/TestBeginEndJobAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ void hello(const char * hi) {
//std::cout << "IN " << hi << std::endl;
}

TestBeginEndJobAnalyzer::Control &
TestBeginEndJobAnalyzer::control() {
static Control l;
return l;
}

TestBeginEndJobAnalyzer::TestBeginEndJobAnalyzer(const edm::ParameterSet& /* iConfig */) {
hello("constr");
}
Expand Down
35 changes: 16 additions & 19 deletions FWCore/Framework/test/stubs/TestBeginEndJobAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,28 @@ class TestBeginEndJobAnalyzer : public edm::EDAnalyzer {
~TestBeginEndJobAnalyzer();


virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void analyze(const edm::Event&, const edm::EventSetup&) override;

virtual void beginJob();
virtual void endJob();
virtual void beginRun(edm::Run const&, edm::EventSetup const&);
virtual void endRun(edm::Run const&, edm::EventSetup const&);
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
virtual void beginJob() override;
virtual void endJob() override;
virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;



struct dso_export Control {
bool beginJobCalled;
bool endJobCalled;
bool beginRunCalled;
bool endRunCalled;
bool beginLumiCalled;
bool endLumiCalled;
bool destructorCalled;
struct Control {
bool beginJobCalled = false;
bool endJobCalled = false;
bool beginRunCalled = false;
bool endRunCalled = false;
bool beginLumiCalled = false;
bool endLumiCalled = false;
bool destructorCalled = false;
};

static Control & control() dso_export {
static Control l;
return l;
}
static Control & control();


private:
Expand Down

0 comments on commit 276be4d

Please sign in to comment.