From ccb6a8ec800a8a9215018ca228348f8d291aaafe Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Sat, 16 Nov 2024 12:58:37 -0800 Subject: [PATCH] valgrind: allow for "expected errors" 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. --- tests/shared_valgrind_functions.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/shared_valgrind_functions.sh b/tests/shared_valgrind_functions.sh index 1bfc98c2..f07e37b8 100644 --- a/tests/shared_valgrind_functions.sh +++ b/tests/shared_valgrind_functions.sh @@ -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}" } @@ -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.