Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions .github/workflows/test_valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,40 @@ name: valgrind check
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

on:
# Allows you to run this workflow manually.
workflow_dispatch:
inputs:
MAKEFLAGS:
type: string
description: 'Make flags to use for compilation (like -j4)'
default: '-j4'
MPI:
type: string
description: 'Use MPI for compilation (ON/OFF)'
default: 'ON'
BUILD_TYPE:
type: string
description: 'Build type (Release/Debug)'
default: 'Debug'
TEST_LEVEL:
type: string
description: 'Test level used for configuring (T8_TEST_LEVEL_FULL, T8_TEST_LEVEL_MEDIUM, or T8_TEST_LEVEL_BASIC)'
default: 'T8_TEST_LEVEL_BASIC'
workflow_call:
inputs:
MAKEFLAGS:
required: true
type: string
description: 'Make flags to use for compilation (like -j4)'
default: '-j4'
MPI:
required: true
type: string
description: 'Use MPI for compilation (ON/OFF)'
default: 'ON'
BUILD_TYPE:
required: true
type: string
description: 'Build type (Release/Debug)'
default: 'Debug'
TEST_LEVEL:
required: true
type: string
description: 'Test level used for configuring (T8_TEST_LEVEL_FULL, T8_TEST_LEVEL_MEDIUM, or T8_TEST_LEVEL_BASIC)'
default: 'T8_TEST_LEVEL_FULL'
Expand Down Expand Up @@ -101,9 +119,7 @@ jobs:
path: build/CMakeFiles/CMakeOutput.log
- name: ninja
run: cd build && ninja $MAKEFLAGS
- name: ninja install
run: cd build && ninja install $MAKEFLAGS
# Execute script that runs a Valgrind check for all test binaries.
# We use 3 parallel processes to run the binaries in parallel with MPI.
# We use 4 parallel processes to run the binaries in parallel with MPI.
- name: Valgrind check
run: cd scripts && bash ./check_all_test_binaries_valgrind.sh --ntasks=3
run: cd scripts && bash ./check_all_test_binaries_valgrind.sh --ntasks=4
3 changes: 0 additions & 3 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ jobs:
needs: preparation
uses: ./.github/workflows/test_valgrind.yml
with:
MAKEFLAGS: -j4
MPI: ON
BUILD_TYPE: Debug
TEST_LEVEL: T8_TEST_LEVEL_BASIC # Do Valgrind check for test level T8_TEST_LEVEL_BASIC for performance reasons.

# Generate code coverage and deploy to Codecov.
Expand Down
2 changes: 1 addition & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The paths are relative paths assuming an execution from the test/ folder in the
#### check_all_test_binaries_valgrind.sh

This script performs a valgrind check on each test binary found by [find_all_test_binary_paths.sh](find_all_test_binary_paths.sh).
The valgrind check is done by [check_valgrind.sh](check_valgrind.sh). It is assumed that the build folder ../build/test/ with the correct test binaries exists. With `--ntasks=[NUMBER]`, you can provide the number of processes to use with mpi (default is 1).
The valgrind check is done by [check_valgrind.sh](check_valgrind.sh). It is assumed that the build folder ../build/test/ with the correct test binaries exists. With `--ntasks=[NUMBER]`, you can provide the number of processes to use with mpi for parallel tests (default is 1).

## Others

Expand Down
45 changes: 34 additions & 11 deletions scripts/check_all_test_binaries_valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
# The script returns 1 if an error is found and 0 otherwise.
# This script must be executed from the scripts/ folder.
# It is assumed that the build folder ../build/test/ with the correct test binaries exists.
# With "--ntasks=[NUMBER]", you can provide the number of processes to use with MPI (default is 1).
# With "--ntasks=[NUMBER]", you can provide the number of processes to use with MPI for parallel tests (default is 1).
#

USAGE="\nUSAGE: This script executes valgrind in parallel on each test binary available. Use the syntax \n
$0 --ntasks=[NUM_TASKS]\n
Providing the number of parallel processes to use with MPI is optional.\n"
Providing the number of parallel processes to use with MPI for parallel tests is optional.\n"

# Check if a number of processes is provided. If not, set to 1.
num_procs=1
Expand Down Expand Up @@ -79,16 +79,39 @@ status=0
counter=0
valgrind_suppressions_file=../../scripts/valgrind_suppressions_file.supp

# First run all serial tests in parallel.
serial_count=$(echo $test_bin_paths | tr ' ' '\n' | grep -c '_serial')
echo "Running valgrind checks on $serial_count serial test binaries in parallel..."
for bin_path in $test_bin_paths; do
counter=$(( $counter + 1 ))
echo -n "[$counter/$num_paths] "
# Run check_valgrind script for each test binary.
bash ../../scripts/check_valgrind.sh $bin_path --supp=$valgrind_suppressions_file --ntasks=$num_procs 2>&1
status=$?
# If status is not 0, an error occurred.
if test $status -ne 0; then
echo "Error occurred during the valgrind check of $bin_path."
exit 1
if [[ $bin_path == *"_serial"* ]]; then
counter=$(( $counter + 1 ))
# Run check_valgrind script for each test binary. The & at the end allows parallel execution.
bash ../../scripts/check_valgrind.sh $bin_path --supp=$valgrind_suppressions_file --ntasks=1 2>&1 &
status=$?
# If status is not 0, an error occurred.
if test $status -ne 0; then
echo "Error occurred during the valgrind check of $bin_path."
kill $(jobs -p)
exit 1
fi
fi
done
# Wait until all serial valgrind checks are done.
wait
echo "Valgrind found no errors in the ${counter} serial test executables."
echo "Check remaining parallel tests."
for bin_path in $test_bin_paths; do
if [[ $bin_path == *"_parallel"* ]]; then
counter=$(( $counter + 1 ))
echo -n "[$counter/$num_paths] "
# Run check_valgrind script for each test binary.
bash ../../scripts/check_valgrind.sh $bin_path --supp=$valgrind_suppressions_file --ntasks=$num_procs 2>&1
status=$?
# If status is not 0, an error occurred.
if test $status -ne 0; then
echo "Error occurred during the valgrind check of $bin_path."
exit 1
fi
fi
done

Expand Down
2 changes: 1 addition & 1 deletion scripts/check_valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ done
echo "Valgrind check of ${FILE} using ${num_procs} processes..."

# Write valgrind output to variable OUTPUT_FILE.
OUTPUT_FILE="valgrind-output.log"
OUTPUT_FILE="valgrind-output-$(basename "$FILE").log"
# Set valgrind flags.
VALGRIND_FLAGS="${VALGRIND_FLAGS} --leak-check=full --track-origins=yes \
--trace-children=yes --show-leak-kinds=definite,indirect,possible \
Expand Down