#!/bin/bash
cd `dirname "$0"`/..

# note: for valgrind to work on 32-bit targets, the libc6-dbg:i386
# package must be installed.

set -e

for a in $(ls build); do
    if [[ "$a" == *-san ]]; then
        # ASAN doesn't tolerate being run under valgrind.
        # Shadow memory range interleaves with an existing memory mapping.
        VALGRIND=
    else
        VALGRIND="valgrind -q"
    fi
    echo "$a:"
    $VALGRIND build/$a/test
    $VALGRIND build/$a/test_unsorted
    echo
done
