Skip to content

Fix the test_valgrind.sh script running tests under valgrind #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/.spellcheck-conf.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[default]
# Don't correct the following words:
extend-ignore-words-re = ["ASSER", "Tne", "ba", "BA"]

[files]
# completely exclude those files from consideration:
extend-exclude = ["test/supp/*.supp"]
3 changes: 1 addition & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ jobs:
cmake --build ${{github.workspace}}/build --config Debug -j$(nproc)

- name: Run tests under valgrind
working-directory: ${{github.workspace}}/build
run: ../test/test_valgrind.sh ${{matrix.tool}}
run: ${{github.workspace}}/test/test_valgrind.sh ${{github.workspace}} ${{github.workspace}}/build ${{matrix.tool}}
117 changes: 117 additions & 0 deletions test/supp/umf_test-provider_os_memory_config.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
Invalid read of size 8
Memcheck:Addr8
fun:memmove
fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm
fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm
fun:_ZN18providerConfigTest11read_memoryEv
fun:_ZN44providerConfigTest_protection_flag_none_Test8TestBodyEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing4Test3RunEv
fun:_ZN7testing8TestInfo3RunEv
fun:_ZN7testing9TestSuite3RunEv
fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
}

{
Bad permissions for mapped region
Memcheck:Leak
match-leak-kinds: definite
fun:_Znwm
fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm
fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm
fun:_ZN18providerConfigTest11read_memoryEv
fun:_ZN44providerConfigTest_protection_flag_none_Test8TestBodyEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing4Test3RunEv
fun:_ZN7testing8TestInfo3RunEv
fun:_ZN7testing9TestSuite3RunEv
fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
}

{
4,608 bytes in 2 blocks are possibly lost in loss record 342 of 346
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:malloc
fun:_dlfo_mappings_segment_allocate
fun:_dl_find_object_update_1
fun:_dl_find_object_update
fun:dl_open_worker_begin
fun:_dl_catch_exception
fun:dl_open_worker
fun:_dl_catch_exception
fun:_dl_open
fun:dlopen_doit
fun:_dl_catch_exception
fun:_dl_catch_error
fun:_dlerror_run
fun:dlopen_implementation
fun:dlopen@@GLIBC_*
}

{
Invalid write of size 8
Memcheck:Addr8
fun:memset
fun:_ZN18providerConfigTest12write_memoryESt17basic_string_viewIcSt11char_traitsIcEE
fun:_ZN44providerConfigTest_protection_flag_none_Test8TestBodyEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing4Test3RunEv
fun:_ZN7testing8TestInfo3RunEv
fun:_ZN7testing9TestSuite3RunEv
fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8UnitTest3RunEv
}

{
4,608 bytes in 2 blocks are possibly lost in loss record 342 of 346
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:malloc
fun:_dlfo_mappings_segment_allocate
fun:_dl_find_object_update_1
fun:_dl_find_object_update
fun:dl_open_worker_begin
fun:_dl_catch_exception
fun:dl_open_worker
fun:_dl_catch_exception
fun:_dl_open
fun:dlopen_doit
fun:_dl_catch_exception
fun:_dl_catch_error
fun:_dlerror_run
fun:dlopen_implementation
fun:dlopen@@GLIBC_*
}

{
4,608 bytes in 2 blocks are possibly lost in loss record 343 of 347
Memcheck:Leak
match-leak-kinds: possible
fun:malloc
fun:malloc
fun:_dlfo_mappings_segment_allocate
fun:_dl_find_object_update_1
fun:_dl_find_object_update
fun:dl_open_worker_begin
fun:_dl_catch_exception
fun:dl_open_worker
fun:_dl_catch_exception
fun:_dl_open
fun:dlopen_doit
fun:_dl_catch_exception
fun:_dl_catch_error
fun:_dlerror_run
fun:dlopen_implementation
fun:dlopen@@GLIBC_*
}
60 changes: 41 additions & 19 deletions test/test_valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,35 @@

set -e

TOOL=$1
WORKSPACE=$1
BUILD_DIR=$2
TOOL=$3

function print_usage() {
echo "$(basename $0) - run UMF tests under valgrind tools (memcheck, drd or helgrind)"
echo "This script must be run in the UMF build directory. It looks for './test/umf_test-*' test executables."
echo "Usage: $(basename $0) <memcheck|drd|helgrind>"
echo "$(basename $0) - run all UMF tests under a valgrind tool (memcheck, drd or helgrind)"
echo "This script looks for './test/umf_test-*' test executables in the UMF build directory."
echo "Usage: $(basename $0) <workspace_dir> <build_dir> <memcheck|drd|helgrind>"
}

if ! valgrind --version > /dev/null; then
echo "error: valgrind not found"
exit 1
fi

if [ $(ls -1 ./test/umf_test-* 2>/dev/null | wc -l) -eq 0 ]; then
echo "error: UMF tests ./test/umf_test-* not found (perhaps wrong directory)"
if [ "$3" == "" ]; then
echo -e "error: too few arguments\n"
print_usage
exit 1
fi

if [ "$TOOL" == "" ]; then
echo "error: valgrind tool is missing"
if [ ! -f $WORKSPACE/README.md ]; then
echo -e "error: incorrect <workspace_dir>: $WORKSPACE\n"
print_usage
exit 1
fi

if [ $(ls -1 ${BUILD_DIR}/test/umf_test-* 2>/dev/null | wc -l) -eq 0 ]; then
echo -e "error: UMF tests ./test/umf_test-* not found in the build directory: ${BUILD_DIR}\n"
print_usage
exit 1
fi
Expand All @@ -41,31 +49,45 @@ helgrind)
OPTION="--tool=helgrind"
;;
*)
echo "error: unknown tool: $TOOL"
echo -e "error: unknown valgrind tool: $TOOL\n"
print_usage
exit 1
;;
esac

FAIL=0
WORKSPACE=$(realpath $WORKSPACE)
BUILD_DIR=$(realpath $BUILD_DIR)

cd ${BUILD_DIR}/test/
mkdir -p cpuid

echo "Gathering data for hwloc so it can be run under valgrind:"
hwloc-gather-cpuid ./cpuid

echo
echo "Working directory: $(pwd)"
echo "Running: \"valgrind $OPTION\" for the following tests:"

for tf in $(ls -1 ./test/umf_test-*); do
[ ! -x $tf ] && continue
echo -n "$tf "
LOG=${tf}.log
HWLOC_CPUID_PATH=./cpuid valgrind $OPTION $tf >$LOG 2>&1 || echo -n "(valgrind failed) "
if grep -q -e "ERROR SUMMARY: 0 errors from 0 contexts" $LOG; then
FAIL=0
rm -f umf_test-*.log umf_test-*.err

for test in $(ls -1 ./umf_test-*); do
[ ! -x $test ] && continue
echo -n "$test "
LOG=${test}.log
ERR=${test}.err
SUP="${WORKSPACE}/test/supp/${test}.supp"
OPT_SUP=""
[ -f ${SUP} ] && OPT_SUP="--suppressions=${SUP}"
HWLOC_CPUID_PATH=./cpuid valgrind $OPTION $OPT_SUP --gen-suppressions=all $test >$LOG 2>&1 || echo -n "(valgrind failed) "
# grep for "ERROR SUMMARY" with errors (there can be many lines with "ERROR SUMMARY")
grep -e "ERROR SUMMARY:" $LOG | grep -v -e "ERROR SUMMARY: 0 errors from 0 contexts" > $ERR || true
if [ $(cat $ERR | wc -l) -eq 0 ]; then
echo "- OK"
rm $LOG
rm -f $LOG $ERR
else
echo "- FAILED! : $(grep -e "ERROR SUMMARY:" $LOG | cut -d' ' -f2-)"
echo "- FAILED!"
cat $ERR | cut -d' ' -f2-
FAIL=1
fi || true
done
Expand All @@ -76,7 +98,7 @@ echo
echo "======================================================================"
echo

for log in $(ls -1 ./test/umf_test-*.log); do
for log in $(ls -1 umf_test-*.log); do
echo ">>>>>>> LOG $log"
cat $log
echo
Expand Down