-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* js/valgrind: valgrind: do not require valgrind 3.4.0 or newer test-lib: avoid assuming that templates/ are in the GIT_EXEC_PATH Tests: let --valgrind imply --verbose and --tee Add a script to coalesce the valgrind outputs t/Makefile: provide a 'valgrind' target test-lib.sh: optionally output to test-results/$TEST.out, too Valgrind support: check for more than just programming errors valgrind: ignore ldso and more libz errors Add valgrind support in test scripts
- Loading branch information
Showing
7 changed files
with
301 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/bin/ | ||
/templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/bin/sh | ||
|
||
out_prefix=$(dirname "$0")/../test-results/valgrind.out | ||
output= | ||
count=0 | ||
total_count=0 | ||
missing_message= | ||
new_line=' | ||
' | ||
|
||
# start outputting the current valgrind error in $out_prefix.++$count, | ||
# and the test case which failed in the corresponding .message file | ||
start_output () { | ||
test -z "$output" || return | ||
|
||
# progress | ||
total_count=$(($total_count+1)) | ||
test -t 2 && printf "\rFound %d errors" $total_count >&2 | ||
|
||
count=$(($count+1)) | ||
output=$out_prefix.$count | ||
: > $output | ||
|
||
echo "*** $1 ***" > $output.message | ||
} | ||
|
||
finish_output () { | ||
test ! -z "$output" || return | ||
output= | ||
|
||
# if a test case has more than one valgrind error, we need to | ||
# copy the last .message file to the previous errors | ||
test -z "$missing_message" || { | ||
while test $missing_message -lt $count | ||
do | ||
cp $out_prefix.$count.message \ | ||
$out_prefix.$missing_message.message | ||
missing_message=$(($missing_message+1)) | ||
done | ||
missing_message= | ||
} | ||
} | ||
|
||
# group the valgrind errors by backtrace | ||
output_all () { | ||
last_line= | ||
j=0 | ||
i=1 | ||
while test $i -le $count | ||
do | ||
# output <number> <backtrace-in-one-line> | ||
echo "$i $(tr '\n' ' ' < $out_prefix.$i)" | ||
i=$(($i+1)) | ||
done | | ||
sort -t ' ' -k 2 | # order by <backtrace-in-one-line> | ||
while read number line | ||
do | ||
# find duplicates, do not output backtrace twice | ||
if test "$line" != "$last_line" | ||
then | ||
last_line=$line | ||
j=$(($j+1)) | ||
printf "\nValgrind error $j:\n\n" | ||
cat $out_prefix.$number | ||
printf "\nfound in:\n" | ||
fi | ||
# print the test case where this came from | ||
printf "\n" | ||
cat $out_prefix.$number.message | ||
done | ||
} | ||
|
||
handle_one () { | ||
OLDIFS=$IFS | ||
IFS="$new_line" | ||
while read line | ||
do | ||
case "$line" in | ||
# backtrace, possibly a new one | ||
==[0-9]*) | ||
|
||
# Does the current valgrind error have a message yet? | ||
case "$output" in | ||
*.message) | ||
test -z "$missing_message" && | ||
missing_message=$count | ||
output= | ||
esac | ||
|
||
start_output $(basename $1) | ||
echo "$line" | | ||
sed 's/==[0-9]*==/==valgrind==/' >> $output | ||
;; | ||
# end of backtrace | ||
'}') | ||
test -z "$output" || { | ||
echo "$line" >> $output | ||
test $output = ${output%.message} && | ||
output=$output.message | ||
} | ||
;; | ||
# end of test case | ||
'') | ||
finish_output | ||
;; | ||
# normal line; if $output is set, print the line | ||
*) | ||
test -z "$output" || echo "$line" >> $output | ||
;; | ||
esac | ||
done < $1 | ||
IFS=$OLDIFS | ||
|
||
# just to be safe | ||
finish_output | ||
} | ||
|
||
for test_script in "$(dirname "$0")"/../test-results/*.out | ||
do | ||
handle_one $test_script | ||
done | ||
|
||
output_all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
ignore-zlib-errors-cond | ||
Memcheck:Cond | ||
obj:*libz.so* | ||
} | ||
|
||
{ | ||
ignore-zlib-errors-value8 | ||
Memcheck:Value8 | ||
obj:*libz.so* | ||
} | ||
|
||
{ | ||
ignore-zlib-errors-value4 | ||
Memcheck:Value4 | ||
obj:*libz.so* | ||
} | ||
|
||
{ | ||
ignore-ldso-cond | ||
Memcheck:Cond | ||
obj:*ld-*.so | ||
} | ||
|
||
{ | ||
ignore-ldso-addr8 | ||
Memcheck:Addr8 | ||
obj:*ld-*.so | ||
} | ||
|
||
{ | ||
ignore-ldso-addr4 | ||
Memcheck:Addr4 | ||
obj:*ld-*.so | ||
} | ||
|
||
{ | ||
writing-data-from-zlib-triggers-even-more-errors | ||
Memcheck:Param | ||
write(buf) | ||
obj:/lib/ld-*.so | ||
fun:write_in_full | ||
fun:write_buffer | ||
fun:write_loose_object | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
base=$(basename "$0") | ||
|
||
TRACK_ORIGINS= | ||
|
||
VALGRIND_VERSION=$(valgrind --version) | ||
VALGRIND_MAJOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*\([0-9]*\)') | ||
VALGRIND_MINOR=$(expr "$VALGRIND_VERSION" : '[^0-9]*[0-9]*\.\([0-9]*\)') | ||
test 3 -gt "$VALGRIND_MAJOR" || | ||
test 3 -eq "$VALGRIND_MAJOR" -a 4 -gt "$VALGRIND_MINOR" || | ||
TRACK_ORIGINS=--track-origins=yes | ||
|
||
exec valgrind -q --error-exitcode=126 \ | ||
--leak-check=no \ | ||
--suppressions="$GIT_VALGRIND/default.supp" \ | ||
--gen-suppressions=all \ | ||
$TRACK_ORIGINS \ | ||
--log-fd=4 \ | ||
--input-fd=4 \ | ||
$GIT_VALGRIND_OPTIONS \ | ||
"$GIT_VALGRIND"/../../"$base" "$@" |