#!/usr/bin/bash

error() { echo "ERROR: $*">&2; exit 1; }

cd "$(dirname $0)" || error "can't enter test directory"
[[ -f "./tests.py" ]] || error "can't locate tests.py"
[[ -f "./data-persistence-binding.so" ]] || error "can't locate data-persistence-binding.so"

export LD_LIBRARY_PATH="$PWD:.:$LD_LIBRARY_PATH"
export DATA_PERSISTENCE_DIR="$(mktemp -d /tmp/dpb.XXX)"
mkdir -p /var/log/redtest/data-persistence-binding || error "creation of result dir failed"
python3 tests.py --tap >& /var/log/redtest/data-persistence-binding/tests.tap
rm -fr "$DATA_PERSISTENCE_DIR"
exit 0

