mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-05 06:21:53 +00:00
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
12da6c23fb
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>
This commit is contained in:
committed by
Nagendra Modadugu
parent
479b74223d
commit
f102027b10
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user