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 20setup() 21{ 22 RC=0 # Return code from commands. 23 24 if [ -z "$LTPTMP" ] && [ -z "$TMPBASE" ] 25 then 26 LTPTMP="/tmp" 27 else 28 LTPTMP="$TMPBASE" 29 fi 30 31 export TPM_TMPFILE="$LTPTMP/tst_tpm.err" 32 rm -f $TPM_TMPFILE 2>&1 33 34 # Set known password values 35 if [ -z "$P11_SO_PWD" ] 36 then 37 export P11_SO_PWD="P11 SO PWD" 38 fi 39 if [ -z "$P11_USER_PWD" ] 40 then 41 export P11_USER_PWD="P11 USER PWD" 42 fi 43 44 tst_resm TINFO "INIT: Inititalizing tests." 45 46 which tpmtoken_objects 1>$TPM_TMPFILE 2>&1 || RC=$? 47 if [ $RC -ne 0 ] 48 then 49 tst_brk TBROK $TPM_TMPFILE NULL \ 50 "Setup: tpmtoken_objects command does not exist. Reason:" 51 return $RC 52 fi 53 54 return $RC 55} 56 57test01() 58{ 59 RC=0 # Return value from commands 60 export TCID=tpmtoken_objects01 # Test ID 61 export TST_COUNT=1 # Test number 62 63 tpmtoken_objects_tests_exp01.sh 1>$TPM_TMPFILE 2>&1 || RC=$? 64 if [ $RC -eq 0 ] 65 then 66 tst_resm TPASS "'tpmtoken_objects' passed." 67 RC=0 68 else 69 tst_res TFAIL $TPM_TMPFILE "'tpmtoken_objects' failed." 70 RC=1 71 fi 72 return $RC 73} 74 75test02() 76{ 77 RC=0 # Return value from commands 78 export TCID=tpmtoken_objects02 # Test ID 79 export TST_COUNT=2 # Test number 80 81 tpmtoken_objects -p 1>$TPM_TMPFILE 2>&1 || RC=$? 82 if [ $RC -eq 0 ] 83 then 84 tst_resm TPASS "'tpmtoken_objects -p' passed." 85 RC=0 86 else 87 tst_res TFAIL $TPM_TMPFILE "'tpmtoken_objects -p' failed." 88 RC=1 89 fi 90 return $RC 91} 92 93cleanup() 94{ 95 rm -f $TPM_TMPFILE 2>&1 96} 97 98# Function: main 99# 100# Description: - Execute all tests, report results. 101# 102# Exit: - zero on success 103# - non-zero on failure. 104 105TFAILCNT=0 # Set TFAILCNT to 0, increment on failure. 106RC=0 # Return code from tests. 107 108export TCID=tpmtoken_objects # Test ID 109export TST_TOTAL=2 # Total numner of tests in this file. 110export TST_COUNT=0 # Initialize identifier 111 112if [ -n "$TPM_NOPKCS11" ] 113then 114 tst_resm TINFO "'tpmtoken_objects' skipped." 115 exit $TFAILCNT 116fi 117 118setup || exit $RC # Exit if initializing testcases fails. 119 120test01 || TFAILCNT=$(($TFAILCNT+1)) 121test02 || TFAILCNT=$(($TFAILCNT+1)) 122 123cleanup 124 125exit $TFAILCNT 126