• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "$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	if [ -z "$NEW_OWN_PWD" ]
44	then
45		export NEW_OWN_PWD="NEW OWN PWD"
46	fi
47	if [ -z "$NEW_SRK_PWD" ]
48	then
49		export NEW_SRK_PWD="NEW SRK PWD"
50	fi
51
52	tst_resm TINFO "INIT: Inititalizing tests."
53
54	which tpm_changeownerauth 1>$TPM_TMPFILE 2>&1 || RC=$?
55	if [ $RC -ne 0 ]
56	then
57		tst_brk TBROK $TPM_TMPFILE NULL \
58			"Setup: tpm_changeownerauth command does not exist. Reason:"
59		return $RC
60	fi
61
62	return $RC
63}
64
65test01()
66{
67	RC=0				# Return value from commands
68	export TCID=tpm_changeauth01	# Test ID
69	export TST_COUNT=1		# Test number
70
71	tpm_changeauth_tests_exp01.sh 1>$TPM_TMPFILE 2>&1 || RC=$?
72	if [ $RC -eq 0 ]
73	then
74		tst_resm TPASS "'tpm_changeauth -o' passed."
75		RC=0
76	else
77		tst_res TFAIL $TPM_TMPFILE "'tpm_changeauth -o' failed."
78		RC=1
79	fi
80	return $RC
81}
82
83test02()
84{
85	RC=0				# Return value from commands
86	export TCID=tpm_changeauth02	# Test ID
87	export TST_COUNT=2		# Test number
88
89	tpm_changeauth_tests_exp02.sh 1>$TPM_TMPFILE 2>&1 || RC=$?
90	if [ $RC -eq 0 ]
91	then
92		tst_resm TPASS "'tpm_changeauth -s' passed."
93		RC=0
94	else
95		tst_res TFAIL $TPM_TMPFILE "'tpm_changeauth -s' failed."
96		RC=1
97	fi
98	return $RC
99}
100
101test03()
102{
103	RC=0				# Return value from commands
104	export TCID=tpm_changeauth03	# Test ID
105	export TST_COUNT=3		# Test number
106
107	tpm_changeauth_tests_exp03.sh 1>$TPM_TMPFILE 2>&1 || RC=$?
108	if [ $RC -eq 0 ]
109	then
110		tst_resm TPASS "'tpm_changeauth -s -o' passed."
111		RC=0
112	else
113		tst_res TFAIL $TPM_TMPFILE "'tpm_changeauth -s -o' failed."
114		RC=1
115	fi
116	return $RC
117}
118
119cleanup()
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
131TFAILCNT=0			# Set TFAILCNT to 0, increment on failure.
132RC=0				# Return code from tests.
133
134export TCID=tpm_changeauth	# Test ID
135export TST_TOTAL=3		# Total numner of tests in this file.
136export TST_COUNT=0		# Initialize identifier
137
138setup || exit $RC		# Exit if initializing testcases fails.
139
140test01 || TFAILCNT=$(($TFAILCNT+1))
141test02 || TFAILCNT=$(($TFAILCNT+1))
142test03 || TFAILCNT=$(($TFAILCNT+1))
143
144cleanup
145
146exit $TFAILCNT
147