# test script to run server from valgrind and apply all unit-tests to it
BINDIR=$1
if [ "$BINDIR" = "" ] ; then
echo 'please type "make memcheck_srv" to run this script'
exit 1
fi
valgrind --tool=memcheck --leak-check=full --error-exitcode=1 --gen-suppressions=all --track-fds=yes --suppressions=memcheck.suppress $BINDIR/omiserver --ignoreAuthentication --livetime 300 2> /tmp/out.unittest &
sleep 3
$BINDIR/unittest -a skipServer=true || exit 1
sleep 2
$BINDIR/omiserver -s
sleep 5
cat /tmp/out.unittest
grep 'ERROR SUMMARY: [1-9]' /tmp/out.unittest && echo "FAILED" && exit 1
exit 0