forked from OpenSCAP/openscap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
valgrind_test.sh
executable file
·36 lines (29 loc) · 972 Bytes
/
valgrind_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# Runs valgrind tests.
#
# Authors:
# Jan Černý <[email protected]>
# set up variables
oscap_program=$actualdir/utils/.libs/oscap
valgrind_output=/tmp/valgrind_$$.log
logfile=$actualdir/tests/valgrind_test.log
error_code=66
suppfile=$actualdir/tests/suppressions.supp
valgrind_args="--trace-children=yes --free-fill=55 --malloc-fill=55 --leak-check=full --show-reachable=yes --show-leak-kinds=all --log-file=$valgrind_output.%p --suppressions=$suppfile --error-exitcode=$error_code"
echo "VALGRIND TEST" >> $logfile
echo "working directory: " `pwd` >> $logfile
echo "command: oscap $@" >> $logfile
# run valgrind
valgrind $valgrind_args $oscap_program "$@"
ret_val=$?
if [ $ret_val -eq $error_code ] ; then
echo "Memory error detected!" >> $logfile
cat $valgrind_output* >> $logfile
result=1 # fail the test
else
echo "OK" >> $logfile
result=0 # pass the test
fi
echo "" >> $logfile
rm $valgrind_output*
exit $result