1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
#! /bin/sh
#
# Copyright (c) International Business Machines Corp., 2005
#
# This program is free software; you can redistribute it and#or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
PATH=$PATH:$LTPTOOLS
setup()
{
RC=0 # Return code from commands.
if [ -z "$LTPTMP" ] && [ -z "$TMPBASE" ]
then
LTPTMP="/tmp"
else
LTPTMP="$TMPBASE"
fi
export TPM_TMPFILE="$LTPTMP/tst_tpm.err"
rm -f $TPM_TMPFILE 2>&1
# Set known password values
if [ -z "$OWN_PWD" ]
then
export OWN_PWD="OWN PWD"
fi
if [ -z "$SRK_PWD" ]
then
export SRK_PWD="SRK PWD"
fi
tst_resm TINFO "INIT: Inititalizing tests."
which tpm_restrictpubek 1>$TPM_TMPFILE 2>&1 || RC=$?
if [ $RC -ne 0 ]
then
tst_brk TBROK $TPM_TMPFILE NULL \
"Setup: tpm_restrictpubek command does not exist. Reason:"
return $RC
fi
which tpm_getpubek 1>$TPM_TMPFILE 2>&1 || RC=$?
if [ $RC -ne 0 ]
then
tst_brk TBROK $TPM_TMPFILE NULL \
"Setup: tpm_getpubek command does not exist. Reason:"
return $RC
fi
return $RC
}
test01()
{
RC=0 # Return value from commands
export TCID=tpm_restrictpubek01 # Test ID
export TST_COUNT=1 # Test number
tpm_restrictpubek_tests_exp01.sh 1>$TPM_TMPFILE 2>&1 || RC=$?
if [ $RC -eq 0 ]
then
tst_resm TPASS "'tpm_restrictpubek -r' passed."
RC=0
else
tst_res TFAIL $TPM_TMPFILE "'tpm_restrictpubek -r' failed."
RC=1
fi
return $RC
}
test02()
{
RC=0 # Return value from commands
export TCID=tpm_restrictpubek02 # Test ID
export TST_COUNT=2 # Test number
tpm_restrictpubek_tests_exp02.sh 1>$TPM_TMPFILE 2>&1 || RC=$?
if [ $RC -eq 0 ]
then
tst_resm TPASS "'tpm_restrictpubek -s' passed."
RC=0
else
tst_res TFAIL $TPM_TMPFILE "'tpm_restrictpubek -s' failed."
RC=1
fi
return $RC
}
test03()
{
RC=0 # Return value from commands
export TCID=tpm_restrictpubek03 # Test ID
export TST_COUNT=3 # Test number
tpm_restrictpubek_tests_exp03.sh 1>$TPM_TMPFILE 2>&1 || RC=$?
if [ $RC -eq 0 ]
then
tst_resm TPASS "'tpm_getpubek' passed."
RC=0
else
tst_res TFAIL $TPM_TMPFILE "'tpm_getpubek' failed."
RC=1
fi
return $RC
}
cleanup()
{
rm -f $TPM_TMPFILE 2>&1
}
# Function: main
#
# Description: - Execute all tests, report results.
#
# Exit: - zero on success
# - non-zero on failure.
TFAILCNT=0 # Set TFAILCNT to 0, increment on failure.
RC=0 # Return code from tests.
export TCID=tpm_restrictpubek # Test ID
export TST_TOTAL=3 # Total numner of tests in this file.
export TST_COUNT=0 # Initialize identifier
setup || exit $RC # Exit if initializing testcases fails.
test01 || TFAILCNT=$(($TFAILCNT+1))
test02 || TFAILCNT=$(($TFAILCNT+1))
test03 || TFAILCNT=$(($TFAILCNT+1))
cleanup
exit $TFAILCNT
|