#! /bin/sh
#*******************************************************************************
# ALMA - Atacama Large Millimiter Array
# (c) Associated Universities Inc., 2005 
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#
# "@(#) $Id: CalibrationTest,v 1.4 2005/11/24 13:50:46 bjeram Exp $"
#
# who       when      what
# --------  --------  ----------------------------------------------
# jkern  2005-01-04  created
#

#************************************************************************
#   NAME
#     CalibrationTest
#   SYNOPSIS
#     This script is used to drive the calibration tests
#------------------------------------------------------------------------
#

# This is very simple, all the smarts of the test are stored in the 
# load and unload programs.
dmesg > before.dmesg
loadcalibrationTest &

max_iter=50
CALPID=`ps -e | awk '/calibrate/ {print $1}'`

i=0
while [ "$CALPID" == "" -a $i -lt $max_iter ]
 do
 sleep 2
 i=`expr $i + 1`
 CALPID=`ps -e | awk '/calibrate/ {print $1}'`
done

if [ $i -lt $max_iter ]
then
    ssh root@$HOST kill -2 `ps -e | awk '/calibrate/ {print $1}'`
    ssh root@$HOST kill -2 `ps -e | awk '/calibrate/ {print $1}'`
    sleep 2
else
    echo 'I could not find PID for calibrate!'
fi
unloadcalibrationTest

#
# ___oOo___
