Skip to content

Commit

Permalink
Add test script with callgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
lczech committed Mar 10, 2024
1 parent 1d5bf48 commit 5aeac18
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ if [[ $1 == "heap" || $1 == "massif" ]] ; then
exit 1
fi
fi
if [[ $1 == "call" || $1 == "callgrind" || $1 == "cachegrind" ]] ; then
mode="call"
shift
if [ -z "`which valgrind`" ] ; then
echo "Program 'valgrind' not found. Cannot run memory tests."
exit 1
fi
fi
if [[ $1 == "speed" ]] ; then
mode="speed"
shift
Expand Down Expand Up @@ -226,6 +234,16 @@ function run_heap() {
return 0
}

# Run a valgrind callgrind.
# Takes the test case as input, returns 0 if successfull.
function run_call() {
outfile=${valgrind_out_file}
valgrind --tool=callgrind --log-file=${outfile} ${test_exe} --gtest_filter=${1} > /dev/null

# Return 0 only if nothing bad happend.
return 0
}

# Run the test `speed_runs` times and show execution times.
# Takes the test case as input, returns 0 if successfull.
function run_speed() {
Expand Down Expand Up @@ -356,6 +374,10 @@ for line in `${test_exe} --gtest_list_tests --gtest_filter="${filter}"` ; do
run_heap $test_id 2>> ${valgrind_out_file}
success=$?
fi
if [[ ${mode} == "call" ]] ; then
run_call $test_id 2>> ${valgrind_out_file}
success=$?
fi
if [[ ${mode} == "speed" ]] ; then
run_speed $test_id 2>> ${gtest_out_file}
success=$?
Expand Down

0 comments on commit 5aeac18

Please sign in to comment.