about summary refs log tree commit diff stats
path: root/templates/c/scripts/valgrind_test.sh
blob: 4d0d964c4a8ca32219a18ac7f69c6eca0081f1d2 (plain) (blame)
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
#! /usr/bin/env sh

for arg in "$@"; do
    case "$arg" in
    "--help" | "-h")
        cat <<-EOF
            valgrind_test.sh [BINARY_NAME] [ARGS_FOR_BINARY..]
EOF
        exit 0
        ;;
    esac
done

binary_name="${1-main}"
[ -n "$1" ] && shift 1

log_file="$(git rev-parse --show-toplevel)/target/valgrind_out.report"
mkdir --parents "$(dirname "$log_file")"

CFLAGS="-ggdb3" make "$binary_name"

valgrind --leak-check=full \
    --show-leak-kinds=all \
    --show-error-list=yes \
    --track-origins=yes \
    --log-file="$log_file" \
    "./target/$binary_name" "$@"

cat "$log_file"