summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagendra modadugu <ngm@google.com>2016-11-15 20:56:45 -0800
committerNagendra Modadugu <ngm@google.com>2017-01-27 05:52:19 +0000
commitf102027b106071ac515cf487abc70558e8e4f4ea (patch)
treefc7ec138105ba071855df61bf97740d95b6a951b /test
parent479b74223d598b415226914a6947a9e2536dcf57 (diff)
downloadchrome-ec-f102027b106071ac515cf487abc70558e8e4f4ea.tar.gz
CR50: update tpmtest.py to handle a success command code
Update tpmtest.py to handle a success command code (i.e. return value of 0) as per change 12da6c23fbb9b72bc23d870d6283cf56ae7f448c This change makes the test suite runnable (not all tests pass though - sha and upgrade tests are broken). Also rename local variable subcmd to avoid a name collision. BUG=none BRANCH=none TEST=tpmtest.py passes, except for sha & upgrade Change-Id: I927ead775a1e41b9abf9f905b9f191e8bd5e108b Signed-off-by: nagendra modadugu <ngm@google.com> Reviewed-on: https://chromium-review.googlesource.com/411535 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'test')
-rwxr-xr-xtest/tpm_test/tpmtest.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/tpm_test/tpmtest.py b/test/tpm_test/tpmtest.py
index 09cf8fdc2d..a774e4913e 100755
--- a/test/tpm_test/tpmtest.py
+++ b/test/tpm_test/tpmtest.py
@@ -73,7 +73,12 @@ class TPM(object):
if size > 4096:
raise subcmd.TpmTestError(prefix + 'invalid size %d' % size)
if response_mode:
- return
+ # Startup response code or extension command response code
+ if cmd_code == 0x100 or cmd_code == 0:
+ return
+ else:
+ raise subcmd.TpmTestError(
+ prefix + 'invalid command code 0x%x' % cmd_code)
if cmd_code >= 0x11f and cmd_code <= 0x18f:
return # This is a valid command
if cmd_code == EXT_CMD:
@@ -111,16 +116,16 @@ class TPM(object):
error message describes the problem.
"""
header_size = struct.calcsize(self.HEADER_FMT)
- tag, size, cmd, subcmd = struct.unpack(self.HEADER_FMT,
+ tag, size, cmd, sub = struct.unpack(self.HEADER_FMT,
response[:header_size])
if tag != 0x8001:
raise subcmd.TpmTestError('Wrong response tag: %4.4x' % tag)
- if cmd != EXT_CMD:
+ if cmd:
raise subcmd.TpmTestError('Unexpected response command field: %8.8x' %
cmd)
- if subcmd != expected_subcmd:
+ if sub != expected_subcmd:
raise subcmd.TpmTestError('Unexpected response subcommand field: %2.2x' %
- subcmd)
+ sub)
if size != len(response):
raise subcmd.TpmTestError('Size mismatch: header %d, actual %d' % (
size, len(response)))