summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-09-13 10:19:24 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-09-26 16:14:05 -0700
commit0309b5581713ca4f9bd59dbca5c58bbda4acf676 (patch)
tree6708be295d243281d9861071a8c8e719b2879a05
parentea36e7d59b9bd05f65d85518ec611e1904ac6f2b (diff)
downloadchrome-ec-0309b5581713ca4f9bd59dbca5c58bbda4acf676.tar.gz
tpmtest: make the test work again
The TPM test directory has bitrotted and does not compile any more, leave alone pass tests. This patch updates the tests to match changed EC codebase: test/tpm_test/Makefile - look for include files in more directories test/tpm_test/bn_test.c - add implementation of always_memset() which for the EC tree now comes from a different tree and provide a plug for watchdog_reload() which is no used by dcrypto code (which in fact is not a good idea, but an issue for another day). test/tpm_test/hash_test.py - update to match new format of return messages test/tpm_test/upgrade_test.py - update to match the new format of return messages and limit the test to installing just 2K worth of data BRANCH=cr50 BUG=none TEST=./test/tpmtest/tpmtest.py now passes Change-Id: Ibcd7fcfba06cd83023e35a2ac4f37ec896492ad4 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/665322 Reviewed-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rw-r--r--test/tpm_test/Makefile5
-rw-r--r--test/tpm_test/bn_test.c10
-rw-r--r--test/tpm_test/hash_test.py2
-rw-r--r--test/tpm_test/upgrade_test.py4
4 files changed, 18 insertions, 3 deletions
diff --git a/test/tpm_test/Makefile b/test/tpm_test/Makefile
index 9963fcfe01..eeed4c2650 100644
--- a/test/tpm_test/Makefile
+++ b/test/tpm_test/Makefile
@@ -25,7 +25,12 @@ vpath %c $(src) ../../chip/g/dcrypto $(src)/testlib
CFLAGS = -fPIC
CFLAGS += -I /usr/include/python2.7
CFLAGS += -I../../../../third_party/cryptoc/include
+CFLAGS += -I../../board/cr50
+CFLAGS += -I../../chip/g
CFLAGS += -I../../chip/g/dcrypto
+CFLAGS += -I../../include
+CFLAGS += -I..
+CFLAGS += -I../..
CFLAGS += -I.
CFLAGS += -Itestlib
CFLAGS += -DLIBFTDI1=1
diff --git a/test/tpm_test/bn_test.c b/test/tpm_test/bn_test.c
index c0eda9f450..9daf1bae64 100644
--- a/test/tpm_test/bn_test.c
+++ b/test/tpm_test/bn_test.c
@@ -114,6 +114,16 @@ fail:
return result;
}
+void *always_memset(void *s, int c, size_t n)
+{
+ memset(s, c, n);
+ return s;
+}
+
+void watchdog_reload(void)
+{
+}
+
int main(void)
{
assert(test_bn_modinv() == 0);
diff --git a/test/tpm_test/hash_test.py b/test/tpm_test/hash_test.py
index 66c5fbf00b..29b2214fc6 100644
--- a/test/tpm_test/hash_test.py
+++ b/test/tpm_test/hash_test.py
@@ -25,7 +25,7 @@ MODE_SHA256 = 1
# A standard empty response to HASH extended commands.
EMPTY_RESPONSE = ''.join('%c' % x for x in (0x80, 0x01, 0x00, 0x00, 0x00, 0x0c,
- 0xba, 0xcc, 0xd0, 0x0a, 0x00, 0x01))
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01))
test_inputs = (
# SHA mode cmd mode handle text
(MODE_SHA1, 'single', 0, 'anything really will work here'),
diff --git a/test/tpm_test/upgrade_test.py b/test/tpm_test/upgrade_test.py
index db70b5ce76..2d2c0b7169 100644
--- a/test/tpm_test/upgrade_test.py
+++ b/test/tpm_test/upgrade_test.py
@@ -36,7 +36,7 @@ def upgrade(tpm):
if len(base_str) < 4:
raise subcmd.TpmTestError('Initialization error %d' %
ord(base_str[0]))
- base = struct.unpack('>I', base_str)[0]
+ base = struct.unpack_from('>4I', base_str)[3]
if base == 0x84000:
fname = 'build/cr50/RW/ec.RW_B.flat'
elif base == 0x44000:
@@ -44,7 +44,7 @@ def upgrade(tpm):
else:
raise subcmd.TpmTestError('Unknown base address 0x%x' % base)
fname = os.path.join(os.path.dirname(__file__), '../..', fname)
- data = open(fname, 'r').read()
+ data = open(fname, 'r').read()[:2000]
transferred = 0
block_size = 1024