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 setup() 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 "$OWN_PWD" ] 36 then 37 export OWN_PWD="OWN PWD" 38 fi 39 if [ -z "$SRK_PWD" ] 40 then 41 export SRK_PWD="SRK PWD" 42 fi 43 44 tst_resm TINFO "INIT: Inititalizing tests." 45 46 which tpm_restrictpubek 1>$TPM_TMPFILE 2>&1 || RC=$? 47 if [ $RC -ne 0 ] 48 then 49 tst_brk TBROK $TPM_TMPFILE NULL \ 50 "Setup: tpm_restrictpubek command does not exist. Reason:" 51 return $RC 52 fi 53 54 which tpm_getpubek 1>$TPM_TMPFILE 2>&1 || RC=$? 55 if [ $RC -ne 0 ] 56 then 57 tst_brk TBROK $TPM_TMPFILE NULL \ 58 "Setup: tpm_getpubek command does not exist. Reason:" 59 return $RC 60 fi 61 62 return $RC 63 } 64 65 test01() 66 { 67 RC=0 # Return value from commands 68 export TCID=tpm_restrictpubek01 # Test ID 69 export TST_COUNT=1 # Test number 70 71 tpm_restrictpubek_tests_exp01.sh 1>$TPM_TMPFILE 2>&1 || RC=$? 72 if [ $RC -eq 0 ] 73 then 74 tst_resm TPASS "'tpm_restrictpubek -r' passed." 75 RC=0 76 else 77 tst_res TFAIL $TPM_TMPFILE "'tpm_restrictpubek -r' failed." 78 RC=1 79 fi 80 return $RC 81 } 82 83 test02() 84 { 85 RC=0 # Return value from commands 86 export TCID=tpm_restrictpubek02 # Test ID 87 export TST_COUNT=2 # Test number 88 89 tpm_restrictpubek_tests_exp02.sh 1>$TPM_TMPFILE 2>&1 || RC=$? 90 if [ $RC -eq 0 ] 91 then 92 tst_resm TPASS "'tpm_restrictpubek -s' passed." 93 RC=0 94 else 95 tst_res TFAIL $TPM_TMPFILE "'tpm_restrictpubek -s' failed." 96 RC=1 97 fi 98 return $RC 99 } 100 101 test03() 102 { 103 RC=0 # Return value from commands 104 export TCID=tpm_restrictpubek03 # Test ID 105 export TST_COUNT=3 # Test number 106 107 tpm_restrictpubek_tests_exp03.sh 1>$TPM_TMPFILE 2>&1 || RC=$? 108 if [ $RC -eq 0 ] 109 then 110 tst_resm TPASS "'tpm_getpubek' passed." 111 RC=0 112 else 113 tst_res TFAIL $TPM_TMPFILE "'tpm_getpubek' failed." 114 RC=1 115 fi 116 return $RC 117 } 118 119 cleanup() 120 { 121 rm -f $TPM_TMPFILE 2>&1 122 } 123 124 # Function: main 125 # 126 # Description: - Execute all tests, report results. 127 # 128 # Exit: - zero on success 129 # - non-zero on failure. 130 131 TFAILCNT=0 # Set TFAILCNT to 0, increment on failure. 132 RC=0 # Return code from tests. 133 134 export TCID=tpm_restrictpubek # Test ID 135 export TST_TOTAL=3 # Total numner of tests in this file. 136 export TST_COUNT=0 # Initialize identifier 137 138 setup || exit $RC # Exit if initializing testcases fails. 139 140 test01 || TFAILCNT=$(($TFAILCNT+1)) 141 test02 || TFAILCNT=$(($TFAILCNT+1)) 142 test03 || TFAILCNT=$(($TFAILCNT+1)) 143 144 cleanup 145 146 exit $TFAILCNT 147