#!/bin/bash

set -e

cd tests

TMP_OUT=$(mktemp)
trap 'rm -f "$TMP_OUT"' EXIT

# excluded:
# - list1: rrdcached test bugged when running with installed rrdcached
#
find . -mindepth 1 -maxdepth 1 -type f -perm '/u+x' | grep -v -e list1 | sort | while read -r i; do
    echo "Running test: ${i}"
    if ! RRDTOOL=/usr/bin/rrdtool "${i}" >"$TMP_OUT" 2>&1; then
        echo "Test ${i} FAILED. Output:"
        echo "--------------------------------------------------"
        cat "$TMP_OUT"
        echo "--------------------------------------------------"
        exit 1
    fi
done

echo "All tests passed."
