Skip to content

Commit 41ffb8e

Browse files
authored
Merge pull request #48908 from Dr15Jones/movePoolTests
Moved Pool based tests from FWCore to IOPool
2 parents b7921f3 + d36ff43 commit 41ffb8e

File tree

246 files changed

+959
-1032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+959
-1032
lines changed

FWCore/Framework/test/BuildFile.xml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@
193193
<use name="FWCore/Utilities"/>
194194
</library>
195195

196+
<library file="stubs/TriggerResultsTestSource.cc" name="FWCoreFrameworkTriggerResultsTestSource">
197+
<flags EDM_PLUGIN="1"/>
198+
<use name="FWCore/Framework"/>
199+
<use name="FWCore/ParameterSet"/>
200+
<use name="FWCore/Utilities"/>
201+
<use name="FWCore/Sources"/>
202+
</library>
203+
204+
196205
<bin name="TestFWCoreFramework" file="testRunner.cpp,maker2_t.cppunit.cc,maker_t.cppunit.cc,productregistry.cppunit.cc,edproducer_productregistry_callback.cc,event_getrefbeforeput_t.cppunit.cc,generichandle_t.cppunit.cc,edconsumerbase_t.cppunit.cc,global_producer_t.cppunit.cc,global_filter_t.cppunit.cc,one_outputmodule_t.cppunit.cc,global_outputmodule_t.cppunit.cc,stream_producer_t.cppunit.cc,stream_filter_t.cppunit.cc,limited_producer_t.cppunit.cc,limited_filter_t.cppunit.cc,limited_outputmodule_t.cppunit.cc,checkForModuleDependencyCorrectness_t.cppunit.cc">
197206
<use name="DataFormats/Common"/>
198207
<use name="DataFormats/Provenance"/>
@@ -338,16 +347,9 @@
338347
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathSameProcessAnotherModuleBefore" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=sameProcess --anotherModule=before 2>&amp;1 | grep 'to request a trigger name that does not exist'"/>
339348
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathSameProcessAnotherModuleAfter" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=sameProcess --anotherModule=after 2>&amp;1 | grep 'to request a trigger name that does not exist'"/>
340349

341-
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlier" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPathEarlier_cfg.py"/>
342-
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlierProcess" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=earlierProcess 2>&amp;1 | grep 'to request a trigger name that does not exist'">
343-
<flags PRE_TEST="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlier"/>
344-
</test>
345-
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlierProcessBefore" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=earlierProcess --anotherModule=before 2>&amp;1 | grep 'to request a trigger name that does not exist'">
346-
<flags PRE_TEST="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlier"/>
347-
</test>
348-
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlierProcessAfter" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=earlierProcess --anotherModule=after 2>&amp;1 | grep 'to request a trigger name that does not exist'">
349-
<flags PRE_TEST="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlier"/>
350-
</test>
350+
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlierProcess" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=earlierProcess 2>&amp;1 | grep 'to request a trigger name that does not exist'"/>
351+
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlierProcessBefore" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=earlierProcess --anotherModule=before 2>&amp;1 | grep 'to request a trigger name that does not exist'"/>
352+
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathEarlierProcessAfter" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=earlierProcess --anotherModule=after 2>&amp;1 | grep 'to request a trigger name that does not exist'"/>
351353

352354
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathMissingProcess" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=missingProcess 2>&amp;1 | grep 'An exception of category .ProductNotFound'"/>
353355
<test name="testFWCoreFrameworkOutputModuleSelectEventsMissingPathMissingProcessAnotherModuleBefore" command="cmsRun ${LOCALTOP}/src/FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py --missingPath=missingProcess --anotherModule=before 2>&amp;1 | grep 'An exception of category .ProductNotFound'"/>

FWCore/Framework/test/run_cmsRun.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ echo $F2 "This test intentionally throws an exception"
2222
# Test maxEvents output parameter
2323
F3=${LOCAL_TEST_DIR}/testMaxEventsOutput_cfg.py
2424
echo $F3
25-
(cmsRun $F3 ) || die "Failure running cmsRun $F3" $?
25+
(cmsRun $F3 ) > testMaxEventsOutput.log 2>&1 || die "Failure running cmsRun $F3" $?
2626
# 6th word on the line containing the string "events"
27-
# output by edmFileUtil
28-
nEvents=`edmFileUtil file:testMaxEventsOutput.root | grep events | awk ' {print $6; exit} '`
27+
nEvents=`grep '>>> processed' testMaxEventsOutput.log | awk ' {print $3; exit} '`
2928
if [ "$nEvents" -lt 6 ] || [ "$nEvents" -gt 9 ]; then
3029
echo "maxEvents output test failed, nEvents = " $nEvents
3130
exit 1
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#include "FWCore/Sources/interface/PuttableSourceBase.h"
2+
#include "FWCore/Sources/interface/IDGeneratorSourceBase.h"
3+
#include "FWCore/Framework/interface/InputSourceMacros.h"
4+
5+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
6+
#include "FWCore/Version/interface/GetReleaseVersion.h"
7+
#include "DataFormats/Common/interface/TriggerResults.h"
8+
#include "DataFormats/Common/interface/Wrapper.h"
9+
10+
#include <memory>
11+
namespace edmtest {
12+
namespace {
13+
edm::ProductDescription makeDesc(std::string const& iProcess) {
14+
edm::ProductDescription desc(
15+
edm::InEvent, "TriggerResults", iProcess, "", edm::TypeID(typeid(edm::TriggerResults)));
16+
desc.setIsProvenanceSetOnRead();
17+
desc.setProduced(false);
18+
return desc;
19+
}
20+
21+
std::pair<edm::ParameterSetID, edm::ParameterSetID> calcID(edm::ProductDescription const& iDesc,
22+
std::vector<std::string> const& iPaths) {
23+
edm::ParameterSet pset;
24+
std::string const& processName = iDesc.processName();
25+
typedef std::vector<std::string> vstring;
26+
vstring empty;
27+
28+
vstring modlbl;
29+
pset.addParameter("@all_sources", modlbl);
30+
31+
edm::ParameterSet triggerPaths;
32+
triggerPaths.addParameter<vstring>("@trigger_paths", iPaths);
33+
pset.addParameter<edm::ParameterSet>("@trigger_paths", triggerPaths);
34+
triggerPaths.registerIt();
35+
36+
pset.addParameter<vstring>("@all_esmodules", empty);
37+
pset.addParameter<vstring>("@all_esprefers", empty);
38+
pset.addParameter<vstring>("@all_essources", empty);
39+
pset.addParameter<vstring>("@all_loopers", empty);
40+
pset.addParameter<vstring>("@all_modules", empty);
41+
pset.addParameter<vstring>("@end_paths", empty);
42+
pset.addParameter<vstring>("@paths", iPaths);
43+
pset.addParameter<std::string>("@process_name", processName);
44+
// Now we register the process parameter set.
45+
pset.registerIt();
46+
47+
return std::make_pair(pset.id(), triggerPaths.id());
48+
}
49+
} // namespace
50+
class TriggerResultsTestSource : public edm::IDGeneratorSourceBase<edm::PuttableSourceBase> {
51+
public:
52+
TriggerResultsTestSource(edm::ParameterSet const&, edm::InputSourceDescription const&);
53+
54+
void readEvent_(edm::EventPrincipal& eventPrincipal) final;
55+
56+
bool setRunAndEventInfo(edm::EventID& id,
57+
edm::TimeValue_t& time,
58+
edm::EventAuxiliary::ExperimentType& etype) override {
59+
return true;
60+
}
61+
static void fillDescriptions(edm::ConfigurationDescriptions&);
62+
63+
private:
64+
const std::string process_;
65+
const std::vector<std::string> paths_;
66+
const std::vector<unsigned int> states_;
67+
const edm::ProductDescription desc_;
68+
edm::ParameterSetID processPsetID_;
69+
edm::ParameterSetID psetID_;
70+
};
71+
72+
TriggerResultsTestSource::TriggerResultsTestSource(edm::ParameterSet const& iPSet,
73+
edm::InputSourceDescription const& iDesc)
74+
: edm::IDGeneratorSourceBase<edm::PuttableSourceBase>(iPSet, iDesc, false),
75+
process_(iPSet.getUntrackedParameter<std::string>("process")),
76+
paths_(iPSet.getUntrackedParameter<std::vector<std::string>>("paths")),
77+
states_(iPSet.getUntrackedParameter<std::vector<unsigned int>>("pathStates")),
78+
desc_(makeDesc(process_)) {
79+
{
80+
auto [processPsetID, psetID] = calcID(desc_, paths_);
81+
processPsetID_ = std::move(processPsetID);
82+
psetID_ = std::move(psetID);
83+
}
84+
std::vector<edm::BranchDescription> products;
85+
products.reserve(1);
86+
products.emplace_back(desc_);
87+
std::vector<std::string> processOrder(1, process_);
88+
productRegistryUpdate().updateFromInput(products, processOrder);
89+
assert(paths_.size() == states_.size());
90+
91+
edm::ProcessHistory ph;
92+
ph.emplace_back(process_, processPsetID_, edm::getReleaseVersion(), edm::HardwareResourcesDescription());
93+
processHistoryRegistryForUpdate().registerProcessHistory(ph);
94+
}
95+
96+
void TriggerResultsTestSource::fillDescriptions(edm::ConfigurationDescriptions& iConfigs) {
97+
edm::ParameterSetDescription desc;
98+
edm::IDGeneratorSourceBase<edm::PuttableSourceBase>::fillDescription(desc);
99+
desc.addUntracked<std::string>("process", std::string(""));
100+
desc.addUntracked<std::vector<std::string>>("paths")->setComment("names of paths");
101+
desc.addUntracked<std::vector<unsigned int>>("pathStates")
102+
->setComment(
103+
"The state of the path. The number of entires must be the same as in 'paths' and the value must be between "
104+
"0-2 inclusive.");
105+
106+
iConfigs.addDefault(desc);
107+
}
108+
109+
void TriggerResultsTestSource::readEvent_(edm::EventPrincipal& eventPrincipal) {
110+
doReadEvent(eventPrincipal, [this](edm::EventPrincipal& eventPrincipal) {
111+
edm::HLTGlobalStatus status(paths_.size());
112+
for (std::size_t i = 0; i < paths_.size(); ++i) {
113+
status.at(i) = edm::HLTPathStatus(static_cast<edm::hlt::HLTState>(states_[i]));
114+
}
115+
116+
auto ptr = std::make_unique<edm::Wrapper<edm::TriggerResults>>(edm::WrapperBase::Emplace(), status, psetID_);
117+
eventPrincipal.put(desc_, std::move(ptr), edm::ProductProvenance(desc_.branchID()));
118+
});
119+
}
120+
} // namespace edmtest
121+
122+
using edmtest::TriggerResultsTestSource;
123+
DEFINE_FWK_INPUT_SOURCE(TriggerResultsTestSource);

FWCore/Framework/test/testMaxEventsOutput_cfg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
)
3434

3535
process.p1 = cms.Path(process.busy1)
36-
process.out = cms.OutputModule("PoolOutputModule",
37-
fileName = cms.untracked.string('testMaxEventsOutput.root')
38-
)
36+
37+
from FWCore.Modules.modules import AsciiOutputModule
38+
process.out = AsciiOutputModule(verbosity=0)
3939

4040
process.e = cms.EndPath(process.out)
4141

FWCore/Framework/test/testOutputModuleSelectEventsMissingPathEarlier_cfg.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

FWCore/Framework/test/testOutputModuleSelectEventsMissingPath_cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
process.source = cms.Source("EmptySource")
1313
if args.missingPath == "earlierProcess":
14-
process.source = cms.Source("PoolSource", fileNames=cms.untracked.vstring("file:testOutputModuleSelectEventsMissingPath.root"))
14+
process.source = cms.Source("TriggerResultsTestSource", paths = cms.untracked.vstring("p1"), pathStates=cms.untracked.vuint32(2), process=cms.untracked.string("EARLIER"))
1515
process.maxEvents.input = 3
1616

1717
selectEvents = {

FWCore/Framework/test/testPathStatus_cfg.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444

4545
process.prod1 = cms.EDProducer("IntProducer", ivalue = cms.int32(1))
4646

47-
process.out = cms.OutputModule("PoolOutputModule",
48-
fileName = cms.untracked.string('testPathStatus.root')
49-
)
47+
process.out = cms.OutputModule("AsciiOutputModule", verbosity = cms.untracked.uint32(0))
5048

5149
process.path1 = cms.Path(process.prod1 * process.f1 * process.f2)
5250
process.path2 = cms.Path()

FWCore/Framework/test/testPrintDependencies.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
process.OtherThing = cms.EDProducer("OtherThingProducer")
1515

16-
process.output = cms.OutputModule("PoolOutputModule",
17-
fileName = cms.untracked.string('file:PoolOutputTest.root')
18-
)
16+
process.output = cms.OutputModule("AsciiOutputModule", verbosity = cms.untracked.uint32(0))
1917

2018
process.source = cms.Source("EmptySource")
2119

FWCore/Integration/test/AssociationMapTest_cfg.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,4 @@
4545
associationMapTag8 = cms.InputTag("associationMapProducer", "twoArg")
4646
)
4747

48-
process.out = cms.OutputModule("PoolOutputModule",
49-
fileName = cms.untracked.string('AssociationMapTest.root')
50-
)
51-
5248
process.p = cms.Path(process.intvec1 * process.intvec2 * process.associationMapProducer * process.test)
53-
54-
process.e = cms.EndPath(process.out)

0 commit comments

Comments
 (0)