3 # Copyright (c) International Business Machines Corp., 2005
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.
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
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # test_tpm_tools.sh - Run the tpm-tools test suite.
22 # Must be root to run the testsuite
25 # echo "FAILED: Must be root to execute this script"
29 # Set the LTPROOT directory
32 echo $LTPROOT |
grep testscripts
> /dev
/null
2>&1
39 # Set the PATH to include testcase/bin
40 # and the sbin directories
41 export LTPBIN
=$LTPROOT/testcases
/bin
42 export PATH
=$PATH:/sbin
:/usr
/sbin
:/usr
/local
/sbin
:$LTPBIN
44 # We will store the logfiles in $LTPROOT/results, so make sure
46 if [ ! -d $LTPROOT/results
]
48 mkdir
$LTPROOT/results
51 # Check for programs/daemons/groups...
54 if [ -z "$LTPTMP" ] && [ -z "$TMPBASE" ]
60 export TPM_TMPFILE
="$LTPTMP/tst_tpm.err"
61 rm -f $TPM_TMPFILE 1>/dev
/null
2>&1
63 # Check for the expect command
64 rm -f $TPM_TMPFILE 1>/dev
/null
2>&1
65 which expect
1>$TPM_TMPFILE 2>&1
68 echo "The 'expect' command is not available. Be sure the expect package has been installed properly"
72 # Check for TrouSerS and that it is running
73 rm -f $TPM_TMPFILE 1>/dev
/null
2>&1
74 which tcsd
1>$TPM_TMPFILE 2>&1
77 echo "The trousers TSS stack is not available. Be sure trousers has been installed properly"
78 if [ -f $TPM_TMPFILE ]
84 rm -f $TPM_TMPFILE 1>/dev
/null
2>&1
86 grep tcsd
$TPM_TMPFILE 1>/dev
/null
89 echo "The trousers TSS stack is not running. Be sure to start the trousers daemon (tcsd)"
94 # Make the opencryptoki testing optional
95 if [ -z "$TPM_NOPKCS11" ]
98 # Check for the pkcs11 group and that the user is a member of it
99 grep -q ^pkcs11
: /etc
/group
102 echo "The 'pkcs11' group does not exist. Be sure openCryptoki has been installed properly"
106 groups |
grep pkcs11
1>/dev
/null
2>&1
109 echo "User '$USER' is not a member of the 'pkcs11' group"
113 # Check for openCryptoki and that it is running
114 # Additionally, delete the user's TPM token data store.
115 rm -f $TPM_TMPFILE 1>/dev
/null
2>&1
116 which pkcsslotd
1>$TPM_TMPFILE 2>&1
119 echo "The openCryptoki PKCS#11 slot daemon is not available. Be sure openCryptoki has been installed properly"
120 if [ -f $TPM_TMPFILE ]
126 rm -f $TPM_TMPFILE 1>/dev
/null
2>&1
127 ps
-ef 1>$TPM_TMPFILE
128 grep pkcsslotd
$TPM_TMPFILE 1>/dev
/null
131 echo "The openCryptoki PKCS#11 slot daemon is not running. Be sure to start the openCryptoki slot daemon (pkcsslotd)"
134 P11DIR
=`which pkcsslotd | sed s-/sbin/pkcsslotd--`
135 if [ "$P11DIR" = "/usr" ]
140 grep libpkcs11_tpm
$P11DIR/var
/lib
/opencryptoki
/pk_config_data
1>/dev
/null
143 echo "The TPM PKCS#11 token is not active. Be sure openCryptoki has been installed properly"
146 if [ -d $P11DIR/var
/lib
/opencryptoki
/tpm
/$USER ]
148 rm -rf $P11DIR/var
/lib
/opencryptoki
/tpm
/$USER
159 # Set known password values
160 export OWN_PWD
="OWN PWD"
161 export NEW_OWN_PWD
="NEW OWN PWD"
162 export SRK_PWD
="SRK PWD"
163 export NEW_SRK_PWD
="NEW SRK PWD"
164 export P11_SO_PWD
="P11 SO PWD"
165 export NEW_P11_SO_PWD
="NEW P11 SO PWD"
166 export P11_USER_PWD
="P11 USER PWD"
167 export NEW_P11_USER_PWD
="NEW P11 USER PWD"
169 echo "Running the tpm-tools testsuite..."
170 $LTPROOT/pan
/ltp-pan
-d 5 -S -a $LTPROOT/results
/tpm_tools
-n ltp-tpm-tools
-l $LTPROOT/results
/tpm_tools.logfile
-o $LTPROOT/results
/tpm_tools.outfile
-p -f $LTPROOT/runtest
/tpm_tools