#! /bin/bash
_REDIR_=$TMP_LOG/rtosTestTATPrologue.log

# To be sure, deletes the recovery file before starting
if [ -e $TMP_LOG ]; then
    rm -rf $TMP_LOG >& /dev/null
fi
echo
mkdir $TMP_LOG

echo " ****************** rtos Test TATPrologue *************** " >>  $_REDIR_

egrep -c -e"^rtai|rtLog"  /proc/modules > /dev/null
if [ $? -eq 0 ]; then
   echo "Test can not be performed because there are some RTAI LKMs are already loaded:"  >> $_REDIR_
   /sbin/lsmod >> $_REDIR_
   exit -1
fi

# Only the installed version (those in INSTALL_DIR) of the load/unload programs
# are set UID.  Thus we must remove the version stored in ../bin.
FILES_TO_REMOVE="calibrationTest switchTest"
for file in $FILES_TO_REMOVE; do
    rm -rf "../bin/load$file" >& /dev/null;
    rm -rf "../bin/unload$file" >& /dev/null;
done

