Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:19

0001 #!/bin/bash -e
0002 
0003 # This script updates the file "${CMSSW_BASE}"/src/HLTrigger/Configuration/test/testAccessToEDMInputsOfHLTTests_filelist.txt
0004 # with the list of EDM files potentially used by HLT tests in the main release cycles of CMSSW (i.e. branches named CMSSW_\d_\d_X).
0005 
0006 # path to output file
0007 outputFile="${CMSSW_BASE}"/src/HLTrigger/Configuration/test/testAccessToEDMInputsOfHLTTests_filelist.txt
0008 
0009 # path to directory hosting this script
0010 TESTDIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
0011 
0012 # ensure that directory hosting this script corresponds to ${CMSSW_BASE}/src/HLTrigger/Configuration/test
0013 if [ "${TESTDIR}" != "${CMSSW_BASE}"/src/HLTrigger/Configuration/test ]; then
0014   printf "\n%s\n" "ERROR -- the directory hosting testAccessToHLTTestInputs.sh [1] does not correspond to \${CMSSW_BASE}/src/HLTrigger/Configuration/test [2]"
0015   printf "%s\n"   "         [1] ${TESTDIR}"
0016   printf "%s\n\n" "         [2] ${CMSSW_BASE}/src/HLTrigger/Configuration/test"
0017   exit 1
0018 fi
0019 
0020 # files in CMSSW using EDM inputs for HLT tests
0021 cmsswFiles=(
0022   HLTrigger/Configuration/test/cmsDriver.csh
0023   Configuration/HLT/python/addOnTestsHLT.py
0024   Utilities/ReleaseScripts/scripts/addOnTests.py
0025 )
0026 
0027 # list of CMSSW branches to be checked
0028 # official-cmssw is the default name of the remote corresponding to the central CMSSW repository
0029 cmsswBranches=($(git branch -a | grep 'remotes/official-cmssw/CMSSW_[0-9]*_[0-9]*_X$'))
0030 cmsswBranches+=("HEAD") # add HEAD to include updates committed locally
0031 
0032 # create 1st temporary file (list of EDM input files used by HLT tests, incl. duplicates)
0033 TMPFILE1=$(mktemp)
0034 
0035 # grep from base directory
0036 cd "${CMSSW_BASE}"/src
0037 
0038 printf "%s\n" "-------------------------"
0039 printf "%s\n" "Finding list of EDM files used by HLT tests in CMSSW (branches: '^CMSSW_[0-9]*_[0-9]*_X$')..."
0040 
0041 # loop over CMSSW branches to be grep-d
0042 for cmsswBranch in "${cmsswBranches[@]}"; do
0043   foo=($(git grep -h "[='\" ]/store/.*.root" ${cmsswBranch} -- ${cmsswFiles[*]} 2> /dev/null |
0044     sed 's|=/store/| /store/|g' | sed "s|'| |g" | sed 's|"| |g' |
0045     awk '{ for(i=1;i<=NF;i++) if ($i ~ /\/store\/.*.root/) print $i }'))
0046   printf "\n  %s\n" "${cmsswBranch}"
0047   for bar in "${foo[@]}"; do
0048     printf "    %s\n" "${bar}"
0049     echo "${bar}" >> "${TMPFILE1}"
0050   done
0051   unset foo bar
0052 done; unset cmsswBranch
0053 
0054 # create 2nd temporary file (list of available EDM input files used by HLT tests, without duplicates)
0055 TMPFILE2=$(mktemp)
0056 
0057 # edmFileIsAvailable:
0058 #  use LFN to check if a EDM file is in the ibeos cache,
0059 #  or can be accessed remotely via global redirector
0060 function edmFileIsAvailable() {
0061   [ $# -eq 1 ] || return 1
0062   # check access to ibeos cache
0063   edmFileUtil -f root://eoscms.cern.ch//eos/cms/store/user/cmsbuild"${1}" &> /dev/null
0064   [ $? -ne 0 ] || return 0
0065   # check remote access via global redirector
0066   edmFileUtil -f root://cms-xrd-global.cern.ch/"${1}" &> /dev/null
0067   return $?
0068 }
0069 
0070 printf "%s\n" "-------------------------"
0071 printf "%s\n" "Checking availability of EDM files..."
0072 printf "%s\n" "(checks whether the file is in the ibeos cache, or it can be accessed remotely via the redirector cms-xrd-global.cern.ch)"
0073 
0074 for inputFile in $(cat "${TMPFILE1}" | sort -u); do
0075   printf '\e[1;34m%-20s\e[m %s\033[0K\r' "[Checking...]" "${inputFile}"
0076   if ! edmFileIsAvailable "${inputFile}"; then
0077     printf '\e[1;31m%-20s\e[m %s\n' "[File not available]" "${inputFile}"
0078     continue
0079   fi
0080   printf '\e[1;32m%-20s\e[m %s\n' "[File available]" "${inputFile}"
0081   echo "${inputFile}" >> "${TMPFILE2}"
0082 done
0083 unset inputFile
0084 
0085 # create/update output file
0086 cat "${TMPFILE2}" | sort -u > "${outputFile}"
0087 
0088 printf "%s\n" "-------------------------"
0089 printf "%s\n" "File updated: ${outputFile}"
0090 printf "%s\n" "-------------------------"
0091 
0092 # return to test/ directory
0093 cd "${TESTDIR}"