All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fcl_checks.sh
Go to the documentation of this file.
1 #!/usr/bin/env bash
2 
3 echo "%%%------------------------------%%%"
4 echo "% Executing $(basename ${0}) script %"
5 echo "%%%------------------------------%%%"
6 
7 echo "args: ${@}"
8 
9 #########################################################################
10 ### Establish environment and read in the arguments from the cfg file ###
11 #########################################################################
12 
13 CWD="$(pwd)"
14 
15 WORKSPACE=${WORKSPACE:-$PWD}
16 ci_cur_exp_name=${ci_cur_exp_name:-${EXPERIMENT}}
17 
18 WORK_DIR="${CWD}/fcl_tests"
19 LOCAL_REF_DIR="${WORK_DIR}/references"
20 
21 echo -e "\nWorking Directory: ${WORK_DIR}"
22 
23 while :
24 do
25  case "x$1" in
26  x--refdir) REF_DIR="${2}"; shift; shift;;
28  x--input-file) INPUT_FILE="${2}"; shift; shift;;
29  x--update-ref-files) UPDATE_REF_FILE_ON=1; shift;;
30  x) break;;
31  esac
32 done
33 
34 
35 ######################################################
36 ### Create working and reference store directories ###
37 ######################################################
38 
39 rm -rf "${WORK_DIR}"
40 mkdir "${WORK_DIR}"
41 mkdir "${LOCAL_REF_DIR}"
42 cd "${WORK_DIR}"
43 
44 
45 ######################################
46 ### Loop over fcl files for checks ###
47 ######################################
48 
49 ACCESS_REF_DIR=${REF_DIR///pnfs/http://fndca1.fnal.gov:8000/pnfs/fnal.gov/usr}
50 REF_FILE=${INPUT_FILE}
51 
52 exit_code_parsing=0
53 exit_code_dump=0
54 
55 echo -e "\nRemote Reference Directory: ${ACCESS_REF_DIR}"
56 
57 if [[ ${UPDATE_REF_FILE_ON} -gt 0 ]]; then
58  echo -e "\nUpdating ref files for fcl checks"
59  export datestamp=$(date +"%Y%m%d%H%M")
60 
61 else
62  if IFDH_DEBUG=0 ifdh ll ${ACCESS_REF_DIR}/${REF_FILE}
63  then
64  echo -e "\nFound reference tar: ${ACCESS_REF_DIR}/${REF_FILE}"
65  echo "ifdh cp ${ACCESS_REF_DIR}/${REF_FILE} ${LOCAL_REF_DIR}/${REF_FILE}"
66  ifdh cp ${ACCESS_REF_DIR}/${REF_FILE} ${LOCAL_REF_DIR}/${REF_FILE}
67  echo -e "\nExtract tar to local references directory"
68  echo "tar -xzvf references/${REF_FILE} -C ${LOCAL_REF_DIR}"
69  tar -xzvf references/${REF_FILE} -C ${LOCAL_REF_DIR}
70  else
71  exit_code=${?}
72  echo -e "\nCannot find reference tar: ${ACCESS_REF_DIR}/${REF_FILE}"
73  echo "Exiting with exit code: ${exit_code}"
74  EXITSTATUS=F
75  ERRORSTRING="Failure accessing reference tar file~Check the log"
76  echo "`basename $CWD`~${exit_code}~${EXITSTATUS}~$ERRORSTRING" >> $WORKSPACE/data_production_stats${ci_cur_exp_name}.log
77  exit $exit_code
78  fi
79 
80  echo -e "\nList of reference files in: ${LOCAL_REF_DIR}"
81  echo "$(ls ${LOCAL_REF_DIR}/*)"
82 fi
83 
84 echo -e "\nList of files from: ${SBNDCODE_DIR}/test/fcl_file_checks.list"
85 echo "$(cat ${SBNDCODE_DIR}/test/fcl_file_checks.list)"
86 
87 for fcl in `cat ${SBNDCODE_DIR}/test/fcl_file_checks.list`
88 
89 do
90  echo -e "\nTesting fcl file ${fcl}"
91 
92 
93  #######################################
94  ### Perform debug check on fcl file ###
95  #######################################
96 
97  fclout=${fcl%.fcl}_fhicl_dump.out
98  larout=${fcl%.fcl}_lar.out
99  larerr=${fcl%.fcl}_lar.err
100  lar -c ${fcl} --debug-config $fclout > $larout 2> $larerr
101 
102 
103  ##############################################
104  ### Check fcl could be parsed successfully ###
105  ##############################################
106 
107  stat=$?
108 
109  if [[ $stat -ne 0 && $stat -ne 1 ]]; then
110  echo "Error parsing ${fcl} --- Exited with status ${stat}"
111  echo "==================================================================================================================================="
112  cat ${larerr}
113  echo "==================================================================================================================================="
114  let exit_code_parsing=201
115  continue
116  else
117  echo "Successful parsing of ${fcl} --- Exited with status ${stat}"
118  fi
119 
120 
121  ###############################################################################
122  ### Check the diff between the fcl configs for the ref and current versions ###
123  ###############################################################################
124 
125  if [[ ${UPDATE_REF_FILE_ON} -gt 0 ]]; then
126  continue
127  fi
128 
129  if [[ ! -f ${LOCAL_REF_DIR}/${fcl%.fcl}_fhicl_dump.out ]]
130  then
131  echo "Cannot open reference file: ${LOCAL_REF_DIR}/${fcl%.fcl}_fhicl_dump.out it does not exist"
132  let exit_code_dump=201
133  continue
134  fi
135 
136  fcl_diff=$(diff ${LOCAL_REF_DIR}/${fcl%.fcl}_fhicl_dump.out ${fclout})
137 
138  if [[ -n $fcl_diff ]]; then
139  echo "Non-zero diff from file: ${fcl}"
140  echo "==================================================================================================================================="
141  echo "$fcl_diff"
142  echo "==================================================================================================================================="
143  let exit_code_dump=201
144  else
145  echo "Zero diff from file: ${fcl}"
146  fi
147  echo
148 done
149 
150 
151 ############################################
152 ### Update reference file (if requested) ###
153 ############################################
154 
155 if [[ ${UPDATE_REF_FILE_ON} -gt 0 ]]; then
156 
157  cd ${WORK_DIR}
158  echo -e "\nMaking tar of new output files"
159  echo "tar -czvf ${CWD}/${CUROUTPUT} *_fhicl_dump.out"
160  tar -czvf ${CWD}/${CUROUTPUT} *_fhicl_dump.out
161 fi
162 
163 
164 ##################################
165 ### Prepare exit code and exit ###
166 ##################################
167 
168 exit_code=0
169 
170 if [[ $exit_code_parsing -ne 0 && $exit_code_dump -ne 0 ]]; then
171  ERRORSTRING="Error parsing fcl file and differences in fhicl dump outputs~Check error in log"
172  let exit_code=201
173 elif [[ $exit_code_parsing -ne 0 ]]; then
174  ERRORSTRING="Error parsing fcl file~Check error in log"
175  let exit_code=201
176 elif [[ $exit_code_dump -ne 0 ]]; then
177  ERRORSTRING="Differences in fhicl dump outputs~Update reference files"
178  let exit_code=201
179 else
180  ERRORSTRING="All checks successful"
181 fi
182 
183 echo -e "\nExiting with exit code: $exit_code"
184 echo $ERRORSTRING | cut -d~ -f 1
185 
186 
187 if [[ $exit_code -ne 0 ]]; then
188  EXITSTATUS=W
189  echo "`basename $CWD`~${exit_code}~${EXITSTATUS}~$ERRORSTRING" >> $WORKSPACE/data_production_stats${ci_cur_exp_name}.log
190 fi
191 
192 exit $exit_code
x output file CUROUTPUT
Definition: fcl_checks.sh:27
process_name standard_reco_uboone fcl
CWD
Definition: fcl_checks.sh:13
process_name opflash particleana ie x
* file
Definition: file_to_url.sh:69
then source cvmfs dune opensciencegrid org products dune setup_dune sh exit elif[-f/grid/fermiapp/products/dune/setup_dune_fermiapp.sh]
shift
Definition: fcl_checks.sh:26
find $MRB_BUILDDIR larpandora job name *fcl print while read fcl do echo Testing fcl file $fcl fclout
x update ref files UPDATE_REF_FILE_ON
Definition: fcl_checks.sh:29
then shift fi
do cd
then dohelp exit fi tar
Definition: make_tarball.sh:51
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
do i e
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test
x input file INPUT_FILE
Definition: fcl_checks.sh:28