#!/bin/sh
#
#  Copyright(c) 1995 Sun Microsystems, Inc.
#  All rights reserved.

#ident  "@(#)testrm  1.10  01/04/16  SMI"


# ----------------------------------------------------------------
# testrm script removes testname_probe.so from the VTS shared object
# probe directory. 
#
# Usage: testrm <testname> [<probe_lib_dir>]
#
# The testname_probe.so is moved to <probe_dir>/deleted_probe dir
# so that it could be added back later using testadd.
# If <probe_lib_dir> is not specified, current dir is assumed to
# be the probe shared lib directory.
#
# ----------------------------------------------------------------

usage_error()
{
    echo Usage: $0 "<testname> [<probe_lib_dir>]"
    echo " <testname>       : Test name "
    echo " <probe_lib_dir>  : Probe shared library dir pathname"
    echo "Note: testrm removes probe shared library for test <testname>"
    echo "      If <probe_lib_dir> not specified, current dir is assumed."
    exit 1
}

if [ $# -eq 0 -o $# -gt 2 ]; then usage_error; fi

tinfo=${1}_probe.so

# Give error if a testname passed is not a simple test name. 
# Note that passing a pathname for testname arg is allowed in testadd but not
# in testrm.
#
if [ "`dirname ${1}`" != "." ]
then
 echo "
 Error: The <testname> argument should be simple testname not a pathname
 "
 usage_error
 exit 1
fi

if [ $# -eq 2 ]
then
   libdir=$2
else
   libdir=.
fi

if [ ! -f "$libdir/$tinfo" ]
then
  echo "Error: The test probe lib $libdir/$tinfo not found."
  exit 1
fi

if [ ! -d $libdir/deleted_probe ]
then
  mkdir -m 755 $libdir/deleted_probe >/dev/null 2>&1
fi

if ( mv $libdir/$tinfo $libdir/deleted_probe >/dev/null 2>&1 )
then
  echo The test probe for ${1} was removed from SunVTS.
else
  echo "Error: Problem moving test shared lib from $libdir/$tinfo"
  echo "       to $libdir/deleted_probe directory"
fi

