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

#ident  "@(#)testinfo  1.9  01/05/21  SMI"


# ------------------------------------------------------------
# testinfo lists all the testname_probe.so files 
# Usage: testinfo [-l <testname>] [<vtsprobe_directory>]
# ------------------------------------------------------------

usage_error()
{
    echo Usage: testinfo "[-l <testname>] [<vtsprobe_directory>]"
    exit
}

probedir=`pwd`
LS=/usr/bin/ls
ISAINFO=/usr/bin/isainfo
DIRNAME=/usr/bin/dirname

getall() {
	if ( $LS ${probedir} | grep _probe.so > /dev/null )
	then
	    echo found the following "<testname>_probe.so" files in $probedir
	    $LS  ${probedir} | grep _probe.so
	else
	    echo "No <testname>_probe.so files found in $probedir"
	fi
}

getind() {

	if ( $LS ${probedir} | grep ${tname}_probe.so > /dev/null )
	then
	    echo found the following probe for $tname in $probedir
	    $LS ${probedir} | grep ${tname}_probe.so
	else
	    echo "No probe found for $tname in $probedir"
        fi
}

if [ $# -eq 0 ] 
then
   if [ `$ISAINFO -b` = 64 ]
   then
	probedir="`$DIRNAME $0`/../lib/probe/sparcv9"
   else 
	probedir="`$DIRNAME $0`/../lib/probe"
   fi

   getall

   exit
fi

for i
do case $i in
    	  -l)	if [ $# = 1 ] ;  then usage_error ; fi 

		if [ $# = 2 ] 
                then
		   tname=$2
		   if [ `$ISAINFO -b` = 64 ]
   		   then
		      probedir="`$DIRNAME $0`/../lib/probe/sparcv9"
   		   else
        	      probedir="`$DIRNAME $0`/../lib/probe"
   		   fi
		fi

		if [ $# = 3 ] 
		then 
		    tname=$2 
		    if [ -d $3 ] 
		    then 
		 	probedir=$3 
		    else
			echo "Error: "$3" is not a directory!" 
			exit
		    fi
		fi	

		getind

		exit ;;

       	  -*)	echo 'unknown flag '$i''  
		usage_error ;;	
    esac
done

if [ $# -eq 1   -a   -d $1 ]
then 
   probedir=$1 ; getall
else
   usage_error 
fi

exit
