Skip to content

Commit

Permalink
Add number of compiler warnings and/or remarks to the log file
Browse files Browse the repository at this point in the history
  • Loading branch information
DusanJovic-NOAA committed Apr 24, 2024
1 parent b6c576d commit b59bc44
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions tests/rt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ usage() {
update_rtconf() {
echo "rt.sh: Checking & Updating test configuration..."
find_match() {
# This function finds if a test in $TESTS_FILE matches one
# This function finds if a test in $TESTS_FILE matches one
# in our list of tests to be run.
THIS_TEST_WITH_COMPILER=$1
shift
Expand Down Expand Up @@ -82,15 +82,15 @@ update_rtconf() {
[[ -n "${line}" ]] || continue
[[ ${#line} == 0 ]] && continue
[[ ${line} == \#* ]] && continue

if [[ ${line} =~ COMPILE ]] ; then
MACHINES=$(cut -d'|' -f5 <<< "${line}")
MACHINES=$(sed -e 's/^ *//' -e 's/ *$//' <<< "${MACHINES}")
RT_COMPILER_IN=$(cut -d'|' -f3 <<< "${line}")
RT_COMPILER_IN=$(sed -e 's/^ *//' -e 's/ *$//' <<< "${RT_COMPILER_IN}")
if [[ ${MACHINES} == '' ]]; then
compile_line=${line}
COMPILE_LINE_USED=false
COMPILE_LINE_USED=false
elif [[ ${MACHINES} == -* ]]; then
[[ ${MACHINES} =~ ${MACHINE_ID} ]] || compile_line=${line}; COMPILE_LINE_USED=false
elif [[ ${MACHINES} == +* ]]; then
Expand All @@ -114,18 +114,18 @@ update_rtconf() {
fi
if [[ ${to_run_test} == true ]]; then
TEST_IDX=$(set -e; find_match "${tmp_test} ${RT_COMPILER_IN}" "${TEST_WITH_COMPILE[@]}")

if [[ ${TEST_IDX} != -1 ]]; then
if [[ ${COMPILE_LINE_USED} == false ]]; then
echo -en '\n' >> "${RT_TEMP_CONF}"
echo -en '\n' >> "${RT_TEMP_CONF}"
echo "${compile_line}" >> "${RT_TEMP_CONF}"

COMPILE_LINE_USED=true
fi
dep_test=$(grep -w "${tmp_test}" <<< "${line}")
dep_test=$(cut -d'|' -f5 <<< "${dep_test}")
dep_test=$(sed -e 's/^ *//' -e 's/ *$//' <<< "${dep_test}")

if [[ ${dep_test} != '' ]]; then
find_match_result=$(set -e; find_match "${dep_test} ${RT_COMPILER_IN}" "${TEST_WITH_COMPILE[@]}")
if [[ ${find_match_result} == -1 ]]; then
Expand All @@ -135,7 +135,7 @@ update_rtconf() {
dep_line=$(tr -d '\n' <<< "${dep_line}")
CORRECT_LINE[1]=$(awk -F'RUN|RUN' '{print $2}' <<< "${dep_line}")
CORRECT_LINE[2]=$(awk -F'RUN|RUN' '{print $3}' <<< "${dep_line}")

if [[ ${RT_COMPILER_IN} == "intel" ]]; then
echo "RUN ${CORRECT_LINE[1]}" >> "${RT_TEMP_CONF}"
elif [[ ${RT_COMPILER_IN} == "gnu" ]]; then
Expand All @@ -144,7 +144,7 @@ update_rtconf() {
fi
fi
echo "${line}" >> "${RT_TEMP_CONF}"
fi
fi
fi
fi
done < "${TESTS_FILE}"
Expand Down Expand Up @@ -185,7 +185,7 @@ EOF
fi
echo; echo >> "${REGRESSIONTEST_LOG}"
cd tests

cat << EOF >> "${REGRESSIONTEST_LOG}"
NOTES:
Expand Down Expand Up @@ -226,18 +226,18 @@ EOF
local valid_test=false

if [[ ${line} == COMPILE* ]] ; then

CMACHINES=$(cut -d'|' -f5 <<< "${line}")
CMACHINES=$(sed -e 's/^ *//' -e 's/ *$//' <<< "${CMACHINES}")

COMPILER=$(cut -d'|' -f3 <<< "${line}")
COMPILER=$(sed -e 's/^ *//' -e 's/ *$//' <<< "${COMPILER}")

COMPILE_NAME=$(cut -d'|' -f2 <<< "${line}")
COMPILE_NAME=$(sed -e 's/^ *//' -e 's/ *$//' <<< "${COMPILE_NAME}")

COMPILE_ID=${COMPILE_NAME}_${COMPILER}

if [[ ${CMACHINES} == '' ]]; then
valid_compile=true
elif [[ ${CMACHINES} == -* ]]; then
Expand All @@ -253,6 +253,7 @@ EOF
TIME_FILE=""
COMPILE_TIME=""
RT_COMPILE_TIME=""
COMPILE_WARNINGS=""
if [[ ! -f "${LOG_DIR}/compile_${COMPILE_ID}.log" ]]; then
COMPILE_RESULT="FAILED: UNABLE TO START COMPILE"
FAIL_LOG="N/A"
Expand All @@ -266,8 +267,18 @@ EOF
COMPILE_RESULT="FAILED: TEST TIMED OUT"
FAIL_LOG="${LOG_DIR}/compile_${COMPILE_ID}.log"
fi
else
else
COMPILE_RESULT="PASS"
if [[ ${COMPILER} == "intel" ]]; then
COMPILE_NUM_WARNINGS=$(grep ": warning #" "${RUNDIR_ROOT}/compile_${COMPILE_ID}/err" | wc -l)
COMPILE_NUM_REMARKS=$(grep ": remark #" "${RUNDIR_ROOT}/compile_${COMPILE_ID}/err" | wc -l)
if [[ ${COMPILE_NUM_WARNINGS} -gt 0 || ${COMPILE_NUM_REMARKS} -gt 0 ]]; then
COMPILE_WARNINGS+="("
[[ ${COMPILE_NUM_WARNINGS} -gt 0 ]] && COMPILE_WARNINGS+=" ${COMPILE_NUM_WARNINGS} warnings"
[[ ${COMPILE_NUM_REMARKS} -gt 0 ]] && COMPILE_WARNINGS+=" ${COMPILE_NUM_REMARKS} remarks"
COMPILE_WARNINGS+=" )"
fi
fi
TIME_FILE="${LOG_DIR}/compile_${COMPILE_ID}_timestamp.txt"
if [[ -f "${TIME_FILE}" ]]; then
while read -r times || [[ -n "${times}" ]]; do
Expand All @@ -282,11 +293,11 @@ EOF
RT_COMPILE_TIME=$(date --date=@$((DATE4 - DATE1)) +'%M:%S')

done < "${TIME_FILE}"

fi
fi
echo >> "${REGRESSIONTEST_LOG}"
echo "${COMPILE_RESULT} -- COMPILE '${COMPILE_ID}' [${RT_COMPILE_TIME}, ${COMPILE_TIME}]" >> "${REGRESSIONTEST_LOG}"
echo "${COMPILE_RESULT} -- COMPILE '${COMPILE_ID}' [${RT_COMPILE_TIME}, ${COMPILE_TIME}]${COMPILE_WARNINGS}" >> "${REGRESSIONTEST_LOG}"
[[ -n ${FAIL_LOG} ]] && FAILED_COMPILES+=("COMPILE ${COMPILE_ID}: ${COMPILE_RESULT}")
[[ -n ${FAIL_LOG} ]] && FAILED_COMPILE_LOGS+=("${FAIL_LOG}")
fi
Expand All @@ -303,7 +314,7 @@ EOF
TEST_NAME=$(sed -e 's/^ *//' -e 's/ *$//' <<< "${TEST_NAME}")
GEN_BASELINE=$(cut -d '|' -f4 <<< "${line}")
GEN_BASELINE=$(sed -e 's/^ *//' -e 's/ *$//' <<< "${GEN_BASELINE}")

if [[ ${RMACHINES} == '' ]]; then
valid_test=true
elif [[ ${RMACHINES} == -* ]]; then
Expand Down Expand Up @@ -332,7 +343,7 @@ EOF
TEST_RESULT="FAILED: UNABLE TO RUN COMPARISON"
FAIL_LOG="${LOG_DIR}/run_${TEST_NAME}_${COMPILER}.log"
# We need to catch a "PASS" in rt_*.log even if a fail_test_* files exists
# I'm not sure why this can happen.
# I am not sure why this can happen.
elif grep -q "PASS" "${LOG_DIR}/rt_${TEST_NAME}_${COMPILER}.log"; then
TEST_RESULT="PASS"
else
Expand Down Expand Up @@ -381,9 +392,9 @@ EOF
fi
fi
done < "${TESTS_FILE}"

elapsed_time=$( printf '%02dh:%02dm:%02ds\n' $((SECONDS%86400/3600)) $((SECONDS%3600/60)) $((SECONDS%60)) )

cat << EOF >> "${REGRESSIONTEST_LOG}"
SYNOPSIS:
Expand All @@ -401,18 +412,18 @@ EOF
echo "-- LOG: ${FAILED_COMPILE_LOGS[${i}]}" >> "${REGRESSIONTEST_LOG}"
done
fi

# PRINT FAILED TESTS
if [[ "${#FAILED_TESTS[@]}" -ne "0" ]]; then

echo "Failed Tests:" >> "${REGRESSIONTEST_LOG}"
for j in "${!FAILED_TESTS[@]}"; do
echo "* ${FAILED_TESTS[${j}]}" >> "${REGRESSIONTEST_LOG}"
echo "-- LOG: ${FAILED_TEST_LOGS[${j}]}" >> "${REGRESSIONTEST_LOG}"
done

fi

# WRITE FAILED_TEST_ID LIST TO TEST_CHANGES_LOG
if [[ "${#FAILED_TESTS[@]}" -ne "0" ]]; then
for item in "${FAILED_TEST_ID[@]}"; do
Expand Down Expand Up @@ -723,7 +734,7 @@ case ${MACHINE_ID} in
# ROCOTOCOMPLETE=$(command -v rocotocomplete)
ROCOTO_SCHEDULER="slurm"
fi

export LD_PRELOAD=/opt/cray/pe/gcc/12.2.0/snos/lib64/libstdc++.so.6
module load PrgEnv-intel/8.3.3
module load intel-classic/2023.1.0
Expand Down Expand Up @@ -856,7 +867,7 @@ case ${MACHINE_ID} in
echo "=======Please, move to Rocky8 node fe[5-8]======="
exit 1
fi

if [[ "${ROCOTO:-false}" == true ]] ; then
module load rocoto
# ROCOTORUN=$(command -v rocotorun)
Expand Down Expand Up @@ -957,7 +968,7 @@ case ${MACHINE_ID} in
cp fv3_conf/fv3_qsub.IN_derecho fv3_conf/fv3_qsub.IN
cp fv3_conf/compile_qsub.IN_derecho fv3_conf/compile_qsub.IN


if [[ "${ROCOTO:-false}" == true ]] ; then
# ROCOTORUN=$(command -v rocotorun)
# ROCOTOSTAT=$(command -v rocotostat)
Expand Down Expand Up @@ -1112,9 +1123,9 @@ rm -rf "${LOG_DIR}"
mkdir -p "${LOG_DIR}"

if [[ ${ROCOTO} == true ]]; then

echo "rt.sh: Verifying ROCOTO support..."

case ${MACHINE_ID} in
wcoss2|acorn|expanse|stampede)
die "Rocoto not supported on this machine, please do not use '-r'."
Expand All @@ -1127,7 +1138,7 @@ if [[ ${ROCOTO} == true ]]; then
ROCOTOSTAT="$(command -v rocotostat)"
ROCOTOCOMPLETE="$(command -v rocotocomplete)"
export ROCOTOCOMPLETE ROCOTOSTAT ROCOTORUN

ROCOTO_XML=${PATHRT}/rocoto_workflow.xml
ROCOTO_STATE=${PATHRT}/rocoto_workflow.state
ROCOTO_DB=${PATHRT}/rocoto_workflow.db
Expand Down

0 comments on commit b59bc44

Please sign in to comment.