Home | History | Annotate | Download | only in tpm_version
      1 #! /bin/sh
      2 #
      3 # Copyright (c) International Business Machines  Corp., 2005
      4 #
      5 # This program is free software;  you can redistribute it and#or modify
      6 # it under the terms of the GNU General Public License as published by
      7 # the Free Software Foundation; either version 2 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful, but
     11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     12 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     13 # for more details.
     14 #
     15 # You should have received a copy of the GNU General Public License
     16 # along with this program;  if not, write to the Free Software
     17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     18 #
     19 
     20 export TCID=tpm_version
     21 export TST_TOTAL=1
     22 export TST_COUNT=1
     23 
     24 setup()
     25 {
     26 	RC=0				# Return code from commands.
     27 
     28 	if [ -z "$LTPTMP" ] && [ -z "$TMPBASE" ]
     29 	then
     30 		LTPTMP="/tmp"
     31 	else
     32 		LTPTMP="$TMPBASE"
     33 	fi
     34 
     35 	export TPM_TMPFILE="$LTPTMP/tst_tpm.err"
     36 	rm -f $TPM_TMPFILE 2>&1
     37 
     38 	tst_resm TINFO "INIT: Inititalizing tests."
     39 
     40 	which tpm_version 1>$TPM_TMPFILE 2>&1 || RC=$?
     41 	if [ $RC -ne 0 ]
     42 	then
     43 		tst_brk TBROK $TPM_TMPFILE NULL \
     44 			"Test: tpm_version command does not exist. Reason:"
     45 		return $RC
     46 	fi
     47 
     48 	return $RC
     49 }
     50 
     51 test01()
     52 {
     53 	RC=0				# Return value from commands
     54 	export TCID=tpm_version01	# Test ID
     55 	export TST_COUNT=1		# Test number
     56 
     57 	tpm_version 1>$TPM_TMPFILE 2>&1 || RC=$?
     58 	if [ $RC -eq 0 ]
     59 	then
     60 		tst_resm TPASS "'tpm_version' passed."
     61 		RC=0
     62 	else
     63 		tst_res TFAIL $TPM_TMPFILE "'tpm_version' failed."
     64 		RC=1
     65 	fi
     66 	return $RC
     67 }
     68 
     69 cleanup()
     70 {
     71 	rm -f $TPM_TMPFILE 2>&1
     72 }
     73 
     74 # Function:	main
     75 #
     76 # Description:	- Execute all tests, report results.
     77 #
     78 # Exit:		- zero on success
     79 # 		- non-zero on failure.
     80 
     81 TFAILCNT=0			# Set TFAILCNT to 0, increment on failure.
     82 RC=0				# Return code from tests.
     83 
     84 setup || exit $RC		# Exit if initializing testcases fails.
     85 
     86 export TCID=tpm_version		# Test ID
     87 export TST_TOTAL=1		# Total numner of tests in this file.
     88 export TST_COUNT=0		# Initialize identifier
     89 
     90 test01 || TFAILCNT=$(($TFAILCNT+1))
     91 
     92 cleanup
     93 
     94 exit $TFAILCNT
     95