#!/bin/sh
# Check for requirements, run AIS tests if found.
#

test `id -ng` = "ais" || BADGROUP=yes
{ ps -u root | grep aisexec >/dev/null; } || NOAISEXEC=yes

if test -n "$BADGROUP" -o -n "$NOAISEXEC"; then
    cat <<EOF

    =========== WARNING: NOT RUNNING AIS TESTS ==============

    Tests that depend on the openais library (used for clustering)
    will not be run because:

EOF
    test -n "$BADGROUP" && cat <<EOF
    You do not appear to have you group ID set to "ais". Make ais your
    primary group, or run "newgrp ais" before running the tests.

EOF
    test -n "$NOAISEXEC" && cat <<EOF    
    The aisexec daemon is not running. Make sure /etc/ais/openais.conf
    is a valid configuration and aisexec is run by root.
EOF

    cat <<EOF

    ==========================================================
    
EOF
    exit 0;			# A warning, not a failure.
fi

FAILED=0
for test in `cat ais_tests`; do
    ./$test || FAILED=`expr $FAILED + 1`
done
exit $FAILED
