Skip to content

Commit

Permalink
valgrind: allow for "expected errors"
Browse files Browse the repository at this point in the history
Ideally, there would always be 0 errors.   However, due to porting
issues, some platforms report a non-zero number of errors even for
trivial programs.
  • Loading branch information
gperciva committed Nov 16, 2024
1 parent 2d2a2d5 commit ccb6a8e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/shared_valgrind_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,13 @@ valgrind_setup() {
fi

# Set up valgrind command.
_valgrind_setup_cmd="valgrind \
--log-file=${_valgrind_setup_logfilename} \
--track-fds=yes \
--trace-children=yes \
--leak-check=full --show-leak-kinds=all \
--errors-for-leak-kinds=all \
_valgrind_setup_cmd="valgrind \
--log-file=${_valgrind_setup_logfilename} \
--track-fds=yes \
--trace-children=yes \
--leak-check=full \
--show-leak-kinds=all \
--errors-for-leak-kinds=all \
--suppressions=${valgrind_suppressions}"
echo "${_valgrind_setup_cmd}"
}
Expand Down Expand Up @@ -333,9 +334,13 @@ _val_checkl() {
return
fi

# Check the error summary.
# Check the error summary. Get the number of expected errors from the
# ${valgrind_fds_log} file. (Ideally this would be 0, but due to
# porting issues, some versions of valgrind on some platforms always
# report a non-zero number of errors.)
_val_checkl_num_errors=$(grep "ERROR SUMMARY: " "${_val_checkl_logfile}" | awk '{print $4}')
if [ "${_val_checkl_num_errors}" -gt 0 ]; then
_val_checkl_num_errors_basic=$(grep "ERROR SUMMARY: " "${valgrind_fds_log}" | awk '{ print $4}')
if [ "${_val_checkl_num_errors}" != "${_val_checkl_num_errors_basic}" ]; then
# There was some other error(s) -- invalid read or write,
# conditional jump based on uninitialized value(s), invalid
# free, etc.
Expand Down

0 comments on commit ccb6a8e

Please sign in to comment.