#!/bin/bash

TESTS="2timer_test clock_getrestest  clock_gettimetest clock_gettimetest2 clock_gettimetest3 clock_gettimetest4 timer_test "

PRIV_TESTS="clock_settimetest 4-1 abs_timer_test clock_nanosleeptest"
FAIL=""
    SETCOLOR_SUCCESS="echo -en \\033[1;32m"
    SETCOLOR_FAILURE="echo -en \\033[1;31m"
    SETCOLOR_WARNING="echo -en \\033[1;33m"
    SETCOLOR_NORMAL="echo -en \\033[0;39m"
do_it () {
echo $1
    for t in $1 ; do
	echo "Running ************************************************************************** $t"
	if ! ./$t ; then
	    FAIL="$t $FAIL"
	fi
    done
}
do_it_priv () {
    for t in $1 ; do
	echo "Running ************************************************************************** $t"
	if !  ./$t ; then
	    FAIL="$t $FAIL"
	fi
    done
}

do_it "$TESTS"

do_it_priv "$PRIV_TESTS"

if [ "$FAIL" != "" ] ; then
    $SETCOLOR_FAILURE
    echo "The following tests failed:"
    for f in $FAIL ; do
	echo $f
    done
else
    $SETCOLOR_WARNING
    echo "All tests passed!"
fi
$SETCOLOR_NORMAL