Skip to content

Commit

Permalink
unit tests for hltPrintMenuVersions and hltMenuContentToCSVs
Browse files Browse the repository at this point in the history
  • Loading branch information
missirol committed Oct 7, 2023
1 parent f317cd3 commit d4d0faa
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 5 deletions.
10 changes: 5 additions & 5 deletions HLTrigger/Configuration/scripts/hltPrintMenuVersions
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ if __name__ == '__main__':
do_twiki_edits = opts.do_twiki_edits
)

if len(hltMenuVersions):
for (configuration, description) in hltMenuVersions:
print(f' * ={configuration}=: {description}')
else:
print('No Configuration Found !!')
if len(hltMenuVersions) == 0:
print('No Configuration Found !!\n')
raise SystemExit(1)

for (configuration, description) in hltMenuVersions:
print(f' * ={configuration}=: {description}')
print()
2 changes: 2 additions & 0 deletions HLTrigger/Configuration/test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test*log*
*.csv
6 changes: 6 additions & 0 deletions HLTrigger/Configuration/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
<!-- test access to EDM files used in HLT-AddOnTests and HLT-Validation tests -->
<test name="testAccessToEDMInputsOfHLTTests" command="testAccessToEDMInputsOfHLTTests.sh"/>

<!-- test script hltPrintMenuVersions -->
<test name="test_hltPrintMenuVersions" command="test_hltPrintMenuVersions.sh"/>

<!-- test script hltMenuContentToCSVs -->
<test name="test_hltMenuContentToCSVs" command="test_hltMenuContentToCSVs.sh"/>
24 changes: 24 additions & 0 deletions HLTrigger/Configuration/test/test_hltMenuContentToCSVs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Pass in name and status
function die {
printf "\n%s: status %s\n" "$1" "$2"
if [ $# -gt 2 ]; then
printf "%s\n" "=== Log File =========="
cat $3
printf "%s\n" "=== End of Log File ==="
fi
exit $2
}

if [ -z "${SCRAM_TEST_PATH}" ]; then
printf "\n%s\n\n" "ERROR -- environment variable SCRAM_TEST_PATH not defined"
exit 1
fi

# run test job
exeDir="${SCRAM_TEST_PATH}"/../scripts/utils

"${exeDir}"/hltMenuContentToCSVs /dev/CMSSW_13_0_0/GRun \
--meta "${exeDir}"/hltPathOwners.json &> test_hltMenuContentToCSVs_log \
|| die "Failure running hltMenuContentToCSVs" $? test_hltMenuContentToCSVs_log
36 changes: 36 additions & 0 deletions HLTrigger/Configuration/test/test_hltPrintMenuVersions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Pass in name and status
function die {
printf "\n%s: status %s\n" "$1" "$2"
if [ $# -gt 2 ]; then
printf "%s\n" "=== Log File =========="
cat $3
printf "%s\n" "=== End of Log File ==="
fi
exit $2
}

# run test job
test_hltPrintMenuVersions_1="hltPrintMenuVersions /dev/CMSSW_13_0_0/Fake2"

${test_hltPrintMenuVersions_1} &> test_hltPrintMenuVersions_log \
|| die "Failure '${test_hltPrintMenuVersions_1}'" $? test_hltPrintMenuVersions_log

cat <<@EOF > test_hltPrintMenuVersions_log_expected
HLT Configuration: /dev/CMSSW_13_0_0/Fake2 (database = "run3")
* =/dev/CMSSW_13_0_0/Fake2/V9 (CMSSW_13_0_2)=: !Migration to release template of !CMSSW_13_0_2
* =/dev/CMSSW_13_0_0/Fake2/V8 (CMSSW_13_0_1)=: !Migration
* =/dev/CMSSW_13_0_0/Fake2/V7 (CMSSW_13_0_0)=: [[https://its.cern.ch/jira/browse/CMSHLT-2651][CMSHLT-2651]]: changed compression settings of all !OutputModules to (algorithm=ZSTD, level=3)
* =/dev/CMSSW_13_0_0/Fake2/V6 (CMSSW_13_0_0)=: !Migration
* =/dev/CMSSW_13_0_0/Fake2/V5 (CMSSW_13_0_0_pre4)=: !Migration
* =/dev/CMSSW_13_0_0/Fake2/V4 (CMSSW_13_0_0_pre3)=: !Migration
* =/dev/CMSSW_13_0_0/Fake2/V3 (CMSSW_13_0_0_pre2)=: !Migration
* =/dev/CMSSW_13_0_0/Fake2/V2 (CMSSW_13_0_0_pre1)=: !Migration
* =/dev/CMSSW_13_0_0/Fake2/V1 (CMSSW_12_6_0_pre5)=: saveAs /dev/CMSSW_12_6_0/Fake2/V6 [7242]
@EOF

diff test_hltPrintMenuVersions_log test_hltPrintMenuVersions_log_expected \
|| die "Unexpected differences in outputs of '${test_hltPrintMenuVersions_1}'" $?

0 comments on commit d4d0faa

Please sign in to comment.