Skip to content

Commit e3341a1

Browse files
authored
Merge pull request #189 from ldorau/Fix_valgrind_script
Fix the test_valgrind.sh script running tests under valgrind
2 parents e4402d6 + efd90d2 commit e3341a1

File tree

4 files changed

+163
-21
lines changed

4 files changed

+163
-21
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[default]
22
# Don't correct the following words:
33
extend-ignore-words-re = ["ASSER", "Tne", "ba", "BA"]
4+
5+
[files]
6+
# completely exclude those files from consideration:
7+
extend-exclude = ["test/supp/*.supp"]

.github/workflows/nightly.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,4 @@ jobs:
4141
cmake --build ${{github.workspace}}/build --config Debug -j$(nproc)
4242
4343
- name: Run tests under valgrind
44-
working-directory: ${{github.workspace}}/build
45-
run: ../test/test_valgrind.sh ${{matrix.tool}}
44+
run: ${{github.workspace}}/test/test_valgrind.sh ${{github.workspace}} ${{github.workspace}}/build ${{matrix.tool}}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
{
2+
Invalid read of size 8
3+
Memcheck:Addr8
4+
fun:memmove
5+
fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm
6+
fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm
7+
fun:_ZN18providerConfigTest11read_memoryEv
8+
fun:_ZN44providerConfigTest_protection_flag_none_Test8TestBodyEv
9+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
10+
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
11+
fun:_ZN7testing4Test3RunEv
12+
fun:_ZN7testing8TestInfo3RunEv
13+
fun:_ZN7testing9TestSuite3RunEv
14+
fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
15+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
16+
}
17+
18+
{
19+
Bad permissions for mapped region
20+
Memcheck:Leak
21+
match-leak-kinds: definite
22+
fun:_Znwm
23+
fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm
24+
fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm
25+
fun:_ZN18providerConfigTest11read_memoryEv
26+
fun:_ZN44providerConfigTest_protection_flag_none_Test8TestBodyEv
27+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
28+
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
29+
fun:_ZN7testing4Test3RunEv
30+
fun:_ZN7testing8TestInfo3RunEv
31+
fun:_ZN7testing9TestSuite3RunEv
32+
fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
33+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
34+
}
35+
36+
{
37+
4,608 bytes in 2 blocks are possibly lost in loss record 342 of 346
38+
Memcheck:Leak
39+
match-leak-kinds: possible
40+
fun:malloc
41+
fun:malloc
42+
fun:_dlfo_mappings_segment_allocate
43+
fun:_dl_find_object_update_1
44+
fun:_dl_find_object_update
45+
fun:dl_open_worker_begin
46+
fun:_dl_catch_exception
47+
fun:dl_open_worker
48+
fun:_dl_catch_exception
49+
fun:_dl_open
50+
fun:dlopen_doit
51+
fun:_dl_catch_exception
52+
fun:_dl_catch_error
53+
fun:_dlerror_run
54+
fun:dlopen_implementation
55+
fun:dlopen@@GLIBC_*
56+
}
57+
58+
{
59+
Invalid write of size 8
60+
Memcheck:Addr8
61+
fun:memset
62+
fun:_ZN18providerConfigTest12write_memoryESt17basic_string_viewIcSt11char_traitsIcEE
63+
fun:_ZN44providerConfigTest_protection_flag_none_Test8TestBodyEv
64+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
65+
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
66+
fun:_ZN7testing4Test3RunEv
67+
fun:_ZN7testing8TestInfo3RunEv
68+
fun:_ZN7testing9TestSuite3RunEv
69+
fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
70+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
71+
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
72+
fun:_ZN7testing8UnitTest3RunEv
73+
}
74+
75+
{
76+
4,608 bytes in 2 blocks are possibly lost in loss record 342 of 346
77+
Memcheck:Leak
78+
match-leak-kinds: possible
79+
fun:malloc
80+
fun:malloc
81+
fun:_dlfo_mappings_segment_allocate
82+
fun:_dl_find_object_update_1
83+
fun:_dl_find_object_update
84+
fun:dl_open_worker_begin
85+
fun:_dl_catch_exception
86+
fun:dl_open_worker
87+
fun:_dl_catch_exception
88+
fun:_dl_open
89+
fun:dlopen_doit
90+
fun:_dl_catch_exception
91+
fun:_dl_catch_error
92+
fun:_dlerror_run
93+
fun:dlopen_implementation
94+
fun:dlopen@@GLIBC_*
95+
}
96+
97+
{
98+
4,608 bytes in 2 blocks are possibly lost in loss record 343 of 347
99+
Memcheck:Leak
100+
match-leak-kinds: possible
101+
fun:malloc
102+
fun:malloc
103+
fun:_dlfo_mappings_segment_allocate
104+
fun:_dl_find_object_update_1
105+
fun:_dl_find_object_update
106+
fun:dl_open_worker_begin
107+
fun:_dl_catch_exception
108+
fun:dl_open_worker
109+
fun:_dl_catch_exception
110+
fun:_dl_open
111+
fun:dlopen_doit
112+
fun:_dl_catch_exception
113+
fun:_dl_catch_error
114+
fun:_dlerror_run
115+
fun:dlopen_implementation
116+
fun:dlopen@@GLIBC_*
117+
}

test/test_valgrind.sh

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,35 @@
55

66
set -e
77

8-
TOOL=$1
8+
WORKSPACE=$1
9+
BUILD_DIR=$2
10+
TOOL=$3
911

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

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

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

27-
if [ "$TOOL" == "" ]; then
28-
echo "error: valgrind tool is missing"
29+
if [ ! -f $WORKSPACE/README.md ]; then
30+
echo -e "error: incorrect <workspace_dir>: $WORKSPACE\n"
31+
print_usage
32+
exit 1
33+
fi
34+
35+
if [ $(ls -1 ${BUILD_DIR}/test/umf_test-* 2>/dev/null | wc -l) -eq 0 ]; then
36+
echo -e "error: UMF tests ./test/umf_test-* not found in the build directory: ${BUILD_DIR}\n"
2937
print_usage
3038
exit 1
3139
fi
@@ -41,31 +49,45 @@ helgrind)
4149
OPTION="--tool=helgrind"
4250
;;
4351
*)
44-
echo "error: unknown tool: $TOOL"
52+
echo -e "error: unknown valgrind tool: $TOOL\n"
4553
print_usage
4654
exit 1
4755
;;
4856
esac
4957

50-
FAIL=0
58+
WORKSPACE=$(realpath $WORKSPACE)
59+
BUILD_DIR=$(realpath $BUILD_DIR)
5160

61+
cd ${BUILD_DIR}/test/
5262
mkdir -p cpuid
5363

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

67+
echo
68+
echo "Working directory: $(pwd)"
5769
echo "Running: \"valgrind $OPTION\" for the following tests:"
5870

59-
for tf in $(ls -1 ./test/umf_test-*); do
60-
[ ! -x $tf ] && continue
61-
echo -n "$tf "
62-
LOG=${tf}.log
63-
HWLOC_CPUID_PATH=./cpuid valgrind $OPTION $tf >$LOG 2>&1 || echo -n "(valgrind failed) "
64-
if grep -q -e "ERROR SUMMARY: 0 errors from 0 contexts" $LOG; then
71+
FAIL=0
72+
rm -f umf_test-*.log umf_test-*.err
73+
74+
for test in $(ls -1 ./umf_test-*); do
75+
[ ! -x $test ] && continue
76+
echo -n "$test "
77+
LOG=${test}.log
78+
ERR=${test}.err
79+
SUP="${WORKSPACE}/test/supp/${test}.supp"
80+
OPT_SUP=""
81+
[ -f ${SUP} ] && OPT_SUP="--suppressions=${SUP}"
82+
HWLOC_CPUID_PATH=./cpuid valgrind $OPTION $OPT_SUP --gen-suppressions=all $test >$LOG 2>&1 || echo -n "(valgrind failed) "
83+
# grep for "ERROR SUMMARY" with errors (there can be many lines with "ERROR SUMMARY")
84+
grep -e "ERROR SUMMARY:" $LOG | grep -v -e "ERROR SUMMARY: 0 errors from 0 contexts" > $ERR || true
85+
if [ $(cat $ERR | wc -l) -eq 0 ]; then
6586
echo "- OK"
66-
rm $LOG
87+
rm -f $LOG $ERR
6788
else
68-
echo "- FAILED! : $(grep -e "ERROR SUMMARY:" $LOG | cut -d' ' -f2-)"
89+
echo "- FAILED!"
90+
cat $ERR | cut -d' ' -f2-
6991
FAIL=1
7092
fi || true
7193
done
@@ -76,7 +98,7 @@ echo
7698
echo "======================================================================"
7799
echo
78100

79-
for log in $(ls -1 ./test/umf_test-*.log); do
101+
for log in $(ls -1 umf_test-*.log); do
80102
echo ">>>>>>> LOG $log"
81103
cat $log
82104
echo

0 commit comments

Comments
 (0)