Skip to content

Commit

Permalink
Fix unit test script bugs
Browse files Browse the repository at this point in the history
These bugs affected some of the cases where we were
running an executable we expected and intended to fail.
The script was supposed to report an error if it didn't
fail, instead was stopping the script and reporting nothing.
  • Loading branch information
wddgit committed Jul 2, 2021
1 parent 9519f09 commit 44f7106
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion FWCore/Framework/test/run_cmsRun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function die { echo $1: status $2 ; exit $2; }
# an infinite wait.
F2=${LOCAL_TEST_DIR}/testConcurrentLumiExceptions_cfg.py
echo $F2 "This test intentionally throws an exception"
(cmsRun $F2 ) && die "No exception using $F2" $?
(cmsRun $F2 ) && die "No exception using $F2" 1

# Test maxEvents output parameter
F3=${LOCAL_TEST_DIR}/testMaxEventsOutput_cfg.py
Expand Down
4 changes: 2 additions & 2 deletions FWCore/Framework/test/run_concurrent_lumis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ touch empty_file

(cmsRun ${LOCAL_TEST_DIR}/test_1_concurrent_lumi_cfg.py 2>&1) | tail -n 2 | grep -v ' 0 ' | grep -v 'e-' | diff - empty_file || die "Failure using test_1_concurrent_lumi_cfg.py" $?

(cmsRun ${LOCAL_TEST_DIR}/test_2_concurrent_lumis_cfg.py 2>&1) | tail -n 1 | grep -v ' 0 ' | grep -v 'e-' | diff - empty_file && die "Failure using test_2_concurrent_lumis_cfg.py" $?
(cmsRun ${LOCAL_TEST_DIR}/test_2_concurrent_lumis_cfg.py 2>&1) | tail -n 1 | grep -v ' 0 ' | grep -v 'e-' | diff - empty_file && die "Failure using test_2_concurrent_lumis_cfg.py" 1

exit 0
exit 0
2 changes: 1 addition & 1 deletion FWCore/Framework/test/run_module_delete_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cmsRun $TEST_DIR/test_module_delete_cfg.py || die "module deletion test failed"
echo "module deletion test succeeded"
cmsRun $TEST_DIR/test_module_delete_subprocess_cfg.py || die "module deletion test with subprocess failed" $?
echo "module deletion test with subprocess succeeded"
cmsRun $TEST_DIR/test_module_delete_improperDependencies_cfg.py && die "module deletion with improper module ordering test failed" $?
cmsRun $TEST_DIR/test_module_delete_improperDependencies_cfg.py && die "module deletion with improper module ordering test failed" 1
echo "module deletion test with improper module ordering succeeded"
cmsRun $TEST_DIR/test_module_delete_looper_cfg.py || die "module deletetion test with looper failed" $?
echo "module deletion test with looper succeeded"
Expand Down
10 changes: 2 additions & 8 deletions FWCore/Integration/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,9 @@
<use name="FWCore/Utilities"/>
</bin>

<bin file="TestIntegration.cpp" name="CatchStdExceptiontest">
<flags TEST_RUNNER_ARGS=" /bin/bash FWCore/Integration/test CatchStdExceptiontest.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<test name="CatchStdExceptiontest" command="CatchStdExceptiontest.sh"/>

<bin file="TestIntegration.cpp" name="CatchCmsExceptiontest">
<flags TEST_RUNNER_ARGS=" /bin/bash FWCore/Integration/test CatchCmsExceptiontest.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<test name="CatchCmsExceptiontest" command="CatchCmsExceptiontest.sh"/>

<bin file="TestIntegration.cpp" name="TestIntegrationExistingDictionary">
<flags TEST_RUNNER_ARGS=" /bin/bash FWCore/Integration/test run_TestExistingDictionary.sh"/>
Expand Down
17 changes: 10 additions & 7 deletions FWCore/Integration/test/CatchCmsExceptiontest.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/bin/sh
set -x
LOCAL_TEST_DIR=${CMSSW_BASE}/src/FWCore/Integration/test
LOCAL_TMP_DIR=${CMSSW_BASE}/tmp/${SCRAM_ARCH}

# Pass in name and status
function die { echo $1: status $2 ; exit $2; }

pushd ${LOCAL_TMP_DIR}

cmsRun ${LOCAL_TEST_DIR}/CatchCmsExceptiontest_cfg.py &> CatchCmsException.log && die 'Failed in using CatchCmsException_cfg.py' $?
cmsRun ${LOCAL_TEST_DIR}/CatchCmsExceptiontest_cfg.py &> CatchCmsException.log && die 'Failed in using CatchCmsException_cfg.py' 1

grep -q WhatsItESProducer CatchCmsException.log || die 'Failed to find Producers name' $?

echo running cmsRun testSkipEvent_cfg.py
cmsRun ${LOCAL_TEST_DIR}/testSkipEvent_cfg.py &> testSkipEvent.log || die 'Failed in using testSkipEvent_cfg.py' $?
#echo running cmsRun testSkipEvent_cfg.py
#cmsRun ${LOCAL_TEST_DIR}/testSkipEvent_cfg.py &> testSkipEvent.log || die 'Failed in using testSkipEvent_cfg.py' $?

echo running cmsRun CatchCmsExceptionFromSource_cfg.py
#echo running cmsRun CatchCmsExceptionFromSource_cfg.py

cmsRun ${LOCAL_TEST_DIR}/CatchCmsExceptionFromSource_cfg.py &> CatchCmsExceptionFromSource.log && \
die 'Failed because expected exception was not thrown while running cmsRun CatchCmsExceptionFromSource_cfg.py' $?
#cmsRun ${LOCAL_TEST_DIR}/CatchCmsExceptionFromSource_cfg.py &> CatchCmsExceptionFromSource.log && \
#die 'Failed because expected exception was not thrown while running cmsRun CatchCmsExceptionFromSource_cfg.py' 1

grep -q "Calling Source::beginRun" CatchCmsExceptionFromSource.log || die 'Failed to find string Calling Source::beginRun' $?
#grep -q "Calling Source::beginRun" CatchCmsExceptionFromSource.log || die 'Failed to find string Calling Source::beginRun' $?

# It is intentional that this test throws an exception. The test fails if it does not.
cmsRun ${LOCAL_TEST_DIR}/testMissingDictionaryChecking_cfg.py &> testMissingDictionaryChecking.log && die 'Failed to get exception running testMissingDictionaryChecking_cfg.py' 1
Expand Down
4 changes: 3 additions & 1 deletion FWCore/Integration/test/CatchCmsExceptiontest_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
process.WhatsItESProducer = cms.ESProducer("WhatsItESProducer")
#es_source = DoodadESSource {}

process.demo = cms.EDAnalyzer("WhatsItAnalyzer")
process.demo = cms.EDAnalyzer("WhatsItAnalyzer",
expectedValues = cms.untracked.vint32(0)
)

process.bad = cms.ESSource("EmptyESSource",
recordName = cms.string('GadgetRcd'),
Expand Down
5 changes: 4 additions & 1 deletion FWCore/Integration/test/CatchStdExceptiontest.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/sh
set -x
LOCAL_TEST_DIR=${CMSSW_BASE}/src/FWCore/Integration/test
LOCAL_TMP_DIR=${CMSSW_BASE}/tmp/${SCRAM_ARCH}

# Pass in name and status
function die { echo $1: status $2 ; exit $2; }

pushd ${LOCAL_TMP_DIR}

cmsRun ${LOCAL_TEST_DIR}/CatchStdExceptiontest_cfg.py &> CatchStdException.log && die 'Failed in using CatchStdException_cfg.py' $?
cmsRun ${LOCAL_TEST_DIR}/CatchStdExceptiontest_cfg.py &> CatchStdException.log && die 'Failed in using CatchStdException_cfg.py' 1

grep -q WhatsItESProducer CatchStdException.log || die 'Failed to find Producers name' $?
#grep -w ESProducer CatcheStdException.log
Expand Down
4 changes: 3 additions & 1 deletion FWCore/Integration/test/CatchStdExceptiontest_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
)
#es_source = DoodadESSource {}

process.demo = cms.EDAnalyzer("WhatsItAnalyzer")
process.demo = cms.EDAnalyzer("WhatsItAnalyzer",
expectedValues = cms.untracked.vint32(0)
)

process.bad = cms.ESSource("EmptyESSource",
recordName = cms.string('GadgetRcd'),
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Integration/test/run_RunMerge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pushd ${LOCAL_TMP_DIR}
cmsRun -p ${LOCAL_TEST_DIR}/${test}TEST_cfg.py || die "cmsRun ${test}TEST_cfg.py" $?

echo ${test}TESTFAIL------------------------------------------------------------
cmsRun -p ${LOCAL_TEST_DIR}/${test}TESTFAIL_cfg.py 2>/dev/null && die "cmsRun ${test}TESTFAIL_cfg.py" $?
cmsRun -p ${LOCAL_TEST_DIR}/${test}TESTFAIL_cfg.py 2>/dev/null && die "cmsRun ${test}TESTFAIL_cfg.py" 1

echo ${test}TEST1------------------------------------------------------------
cmsRun -p ${LOCAL_TEST_DIR}/${test}TEST1_cfg.py || die "cmsRun ${test}TEST1_cfg.py" $?
Expand Down
4 changes: 2 additions & 2 deletions FWCore/Integration/test/run_TestEDAlias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ pushd ${LOCAL_TMP_DIR}

echo "*************************************************"
echo "Test EDAlias aliasing for many modules with possibly ambiguous get via edm::View"
cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py && die "cmsRun ${test}ManyModulesAmbiguous_cfg.py 1" $?
cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py && die "cmsRun ${test}ManyModulesAmbiguous_cfg.py 1" 1
cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py includeAliasToFoo=0 || die "cmsRun ${test}ManyModulesAmbiguous_cfg.py includeAliasToFoo=0" $?
cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py includeAliasToBar=0 || die "cmsRun ${test}ManyModulesAmbiguous_cfg.py includeAliasToBar=0" $?
cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py consumerGets=0 || die "cmsRun ${test}ManyModulesAmbiguous_cfg.py consumerGets=0" $?
cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py explicitProcessName=1 & die "cmsRun ${test}ManyModulesAmbiguous_cfg.py explicitProcessName=1" $?
cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py explicitProcessName=1 && die "cmsRun ${test}ManyModulesAmbiguous_cfg.py explicitProcessName=1" 1

popd

Expand Down
6 changes: 3 additions & 3 deletions FWCore/Integration/test/run_TestSwitchProducer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ pushd ${LOCAL_TMP_DIR}

echo "*************************************************"
echo "Keeping SwitchProducer-with-EDAlias and the aliased-for product should fail"
cmsRun -n ${NUMTHREADS} ${LOCAL_TEST_DIR}/${test}AliasOutput_cfg.py && die "cmsRun ${test}AliasOutput_cfg.py did not throw an exception" $?
cmsRun -n ${NUMTHREADS} ${LOCAL_TEST_DIR}/${test}AliasOutput_cfg.py && die "cmsRun ${test}AliasOutput_cfg.py did not throw an exception" 1

echo "*************************************************"
echo "Alias to non-existent product should fail only when a corresponding product is accessed"
cmsRun -n ${NUMTHREADS} ${LOCAL_TEST_DIR}/${test}AliasToNonExistent_cfg.py && die "cmsRun ${test}AliasToNonExistent_cfg.py did not throw an exception" $?
cmsRun -n ${NUMTHREADS} ${LOCAL_TEST_DIR}/${test}AliasToNonExistent_cfg.py && die "cmsRun ${test}AliasToNonExistent_cfg.py did not throw an exception" 1

echo "*************************************************"
echo "SwitchProducer-with-EDAlias being before the aliased-for producer in a Path should fail"
cmsRun -n ${NUMTHREADS} ${LOCAL_TEST_DIR}/${test}PathWrongOrder_cfg.py && die "cmsRun ${test}PathWrongOrder_cfg.py did not throw an exception" $?
cmsRun -n ${NUMTHREADS} ${LOCAL_TEST_DIR}/${test}PathWrongOrder_cfg.py && die "cmsRun ${test}PathWrongOrder_cfg.py did not throw an exception" 1

echo "SwitchProducer tests succeeded"
echo "*************************************************"
Expand Down
6 changes: 3 additions & 3 deletions FWCore/Integration/test/run_ThinningTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pushd ${LOCAL_TMP_DIR}
cmsRun -p ${LOCAL_TEST_DIR}/DetSetVectorThinningTest1_cfg.py || die "cmsRun DetSetVectorThinningTest1_cfg.py" $?
cmsRun -p ${LOCAL_TEST_DIR}/DetSetVectorThinningTest2_cfg.py || die "cmsRun DetSetVectorThinningTest2_cfg.py" $?

cmsRun -p ${LOCAL_TEST_DIR}/SlimmingTestSiblings_cfg.py && die "cmsRun SlimmingTestSiblings_cfg.py" $?
cmsRun -p ${LOCAL_TEST_DIR}/SlimmingTestSiblings_cfg.py && die "cmsRun SlimmingTestSiblings_cfg.py"1

cmsRun -p ${LOCAL_TEST_DIR}/SlimmingTestFartherSiblings_cfg.py && die "cmsRun SlimmingTestFartherSiblings_cfg.py" $?
cmsRun -p ${LOCAL_TEST_DIR}/SlimmingTestFartherSiblings_cfg.py && die "cmsRun SlimmingTestFartherSiblings_cfg.py" 1

cmsRun -p ${LOCAL_TEST_DIR}/SlimmingTest1_cfg.py || die "cmsRun SlimmingTest1_cfg.py" $?

Expand All @@ -49,7 +49,7 @@ pushd ${LOCAL_TMP_DIR}
cmsRun -p ${LOCAL_TEST_DIR}/SlimmingTest3I_cfg.py || die "cmsRun SlimmingTest3I_cfg.py" $?

cmsRun -p ${LOCAL_TEST_DIR}/SlimmingTest4B_cfg.py || die "cmsRun SlimmingTest4B_cfg.py" $?
cmsRun -p ${LOCAL_TEST_DIR}/SlimmingTest4F_cfg.py && die "cmsRun SlimmingTest4F_cfg.py" $?
cmsRun -p ${LOCAL_TEST_DIR}/SlimmingTest4F_cfg.py && die "cmsRun SlimmingTest4F_cfg.py" 1

popd

Expand Down
2 changes: 1 addition & 1 deletion FWCore/Integration/test/run_unscheduledFailOnOutput.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function die { echo Failure $1: status $2 ; exit $2 ; }

pushd ${LOCAL_TMP_DIR}

cmsRun ${CFG_DIR}/${test}Rethrow_cfg.py && die "cmsRun ${test}Rethrow_cfg.py did not fail" $?
cmsRun ${CFG_DIR}/${test}Rethrow_cfg.py && die "cmsRun ${test}Rethrow_cfg.py did not fail" 1

cmsRun ${CFG_DIR}/${test}IgnoreCompletely_cfg.py || die "cmsRun ${test}IgnoreCompletely_cfg.py" $?
cmsRun ${CFG_DIR}/${test}read_found_events.py || die "cmsRun ${test}read_found_events.py for IgnoreCompletely" $?
Expand Down
2 changes: 1 addition & 1 deletion FWCore/MessageService/test/u24.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ status=0

rm -f u24.log

cmsRun -p $LOCAL_TEST_DIR/u24_cfg.py && exit $?
cmsRun -p $LOCAL_TEST_DIR/u24_cfg.py && exit 1

for file in u24.log
do
Expand Down
2 changes: 1 addition & 1 deletion IOPool/Input/test/TestPoolInput.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ cmsRun ${LOCAL_TEST_DIR}/RunPerLumiTest_cfg.py 25 >& ${LOCAL_TMP_DIR}/RunPerLumi
grep 'record' ${LOCAL_TMP_DIR}/RunPerLumiTest.txt | cut -d ' ' -f 4-11 > ${LOCAL_TMP_DIR}/RunPerLumiTest.filtered.txt
diff ${LOCAL_TEST_DIR}/unit_test_outputs/RunPerLumiTest.filtered.txt ${LOCAL_TMP_DIR}/RunPerLumiTest.filtered.txt || die 'incorrect output using RunPerLumiTest_cfg.py' $?

cmsRun ${LOCAL_TEST_DIR}/RunPerLumiTest_cfg.py 50 >& ${LOCAL_TMP_DIR}/tooManyLumis.txt && die 'RunPerLumiTest_cfg.py should have failed but did not' $?
cmsRun ${LOCAL_TEST_DIR}/RunPerLumiTest_cfg.py 50 >& ${LOCAL_TMP_DIR}/tooManyLumis.txt && die 'RunPerLumiTest_cfg.py should have failed but did not' 1
grep "MismatchedInputFiles" ${LOCAL_TMP_DIR}/tooManyLumis.txt || die 'RunPerLumiTest_cfg.py should have failed but did not' $?

cmsRun ${LOCAL_TEST_DIR}/firstLuminosityBlockForEachRunTest_cfg.py 'file:RunPerLumiTest.root' 25 1 25 1 5 || die 'Failure using firstLuminosityBlockForEachRunTest_cfg.py' $?
Expand Down

0 comments on commit 44f7106

Please sign in to comment.