#!/bin/bash

DIR=$(dirname $0)

tests=( $DIR/health_thread_exit $DIR/health_thread_stall $DIR/health_tp_fail)
exit_code=0

function start_tests ()
{
	for bin in ${tests[@]};
	do
		if [ ! -e $bin ]; then
			echo -e "$bin not found, passing"
			continue
		fi

		./$bin
		# Test must return 0 to pass.
		if [ $? -ne 0 ]; then
			exit_code=1
			break
		fi
	done
}

if [ "$(id -u)" != "0" ]; then
	echo -e "Need root for health test."
	exit 0
fi

start_tests

exit $exit_code
