From 5aeac184fc0b5d78b72e944309a8d688d85fc581 Mon Sep 17 00:00:00 2001 From: Lucas Czech Date: Sun, 10 Mar 2024 18:03:02 -0300 Subject: [PATCH] Add test script with callgrind --- test/run.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/run.sh b/test/run.sh index c26ca6f7..f29a34cc 100755 --- a/test/run.sh +++ b/test/run.sh @@ -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 @@ -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() { @@ -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=$?