#!/usr/bin/env bash

mkdir cmake-build-release-address-sanitizer
cd cmake-build-release-address-sanitizer
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DTHREAD_SANITIZER=OFF -DADDRESS_SANITIZER=ON
make

# run the actual tests with sanitizer enabled, reporting the result
ASAN_OPTIONS="detect_stack_use_after_return=1 detect_leaks=1" ./bin/tests
STATUS_CODE=$?

exit $STATUS_CODE
