All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 5/7] test/py: tpm2: switch from 'tpm' to 'tpm2' command
Date: Thu, 19 Jul 2018 22:35:10 +0200	[thread overview]
Message-ID: <20180719203512.346-6-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20180719203512.346-1-miquel.raynal@bootlin.com>

While using the 'tpm' command should work on most cases, this test suite
only works with TPMv2 and since the work to make both versions build at
the same time, we might end up having both 'tpm' (TPMv1) and 'tpm2'
(TPMv2) commands available at the same time. Ensure this test suite
always use the right one.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 test/py/tests/test_tpm2.py | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py
index 01ffb3178d..3e1f42d83e 100644
--- a/test/py/tests/test_tpm2.py
+++ b/test/py/tests/test_tpm2.py
@@ -29,22 +29,22 @@ def force_init(u_boot_console, force=False):
     twice will spawn an error used to detect that the TPM was not reset and no
     initialization code should be run.
     """
-    output = u_boot_console.run_command('tpm init')
+    output = u_boot_console.run_command('tpm2 init')
     if force or not 'Error' in output:
         u_boot_console.run_command('echo --- start of init ---')
-        u_boot_console.run_command('tpm startup TPM2_SU_CLEAR')
-        u_boot_console.run_command('tpm self_test full')
-        u_boot_console.run_command('tpm clear TPM2_RH_LOCKOUT')
+        u_boot_console.run_command('tpm2 startup TPM2_SU_CLEAR')
+        u_boot_console.run_command('tpm2 self_test full')
+        u_boot_console.run_command('tpm2 clear TPM2_RH_LOCKOUT')
         output = u_boot_console.run_command('echo $?')
         if not output.endswith('0'):
-            u_boot_console.run_command('tpm clear TPM2_RH_PLATFORM')
+            u_boot_console.run_command('tpm2 clear TPM2_RH_PLATFORM')
         u_boot_console.run_command('echo --- end of init ---')
 
 @pytest.mark.buildconfigspec('cmd_tpm_v2')
 def test_tpm2_init(u_boot_console):
     """Init the software stack to use TPMv2 commands."""
 
-    u_boot_console.run_command('tpm init')
+    u_boot_console.run_command('tpm2 init')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -55,7 +55,7 @@ def test_tpm2_startup(u_boot_console):
     Initiate the TPM internal state machine.
     """
 
-    u_boot_console.run_command('tpm startup TPM2_SU_CLEAR')
+    u_boot_console.run_command('tpm2 startup TPM2_SU_CLEAR')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -66,7 +66,7 @@ def test_tpm2_self_test_full(u_boot_console):
     Ask the TPM to perform all self tests to also enable full capabilities.
     """
 
-    u_boot_console.run_command('tpm self_test full')
+    u_boot_console.run_command('tpm2 self_test full')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -78,7 +78,7 @@ def test_tpm2_continue_self_test(u_boot_console):
     to enter a fully operational state.
     """
 
-    u_boot_console.run_command('tpm self_test continue')
+    u_boot_console.run_command('tpm2 self_test continue')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -95,11 +95,11 @@ def test_tpm2_clear(u_boot_console):
     PLATFORM hierarchies are also available.
     """
 
-    u_boot_console.run_command('tpm clear TPM2_RH_LOCKOUT')
+    u_boot_console.run_command('tpm2 clear TPM2_RH_LOCKOUT')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
-    u_boot_console.run_command('tpm clear TPM2_RH_PLATFORM')
+    u_boot_console.run_command('tpm2 clear TPM2_RH_PLATFORM')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -115,13 +115,13 @@ def test_tpm2_change_auth(u_boot_console):
 
     force_init(u_boot_console)
 
-    u_boot_console.run_command('tpm change_auth TPM2_RH_LOCKOUT unicorn')
+    u_boot_console.run_command('tpm2 change_auth TPM2_RH_LOCKOUT unicorn')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
-    u_boot_console.run_command('tpm clear TPM2_RH_LOCKOUT unicorn')
+    u_boot_console.run_command('tpm2 clear TPM2_RH_LOCKOUT unicorn')
     output = u_boot_console.run_command('echo $?')
-    u_boot_console.run_command('tpm clear TPM2_RH_PLATFORM')
+    u_boot_console.run_command('tpm2 clear TPM2_RH_PLATFORM')
     assert output.endswith('0')
 
 @pytest.mark.buildconfigspec('cmd_tpm_v2')
@@ -140,7 +140,7 @@ def test_tpm2_get_capability(u_boot_console):
     force_init(u_boot_console)
     ram = u_boot_utils.find_ram_base(u_boot_console)
 
-    read_cap = u_boot_console.run_command('tpm get_capability 0x6 0x20e 0x200 1') #0x%x 1' % ram)
+    read_cap = u_boot_console.run_command('tpm2 get_capability 0x6 0x20e 0x200 1') #0x%x 1' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
     assert 'Property 0x0000020e: 0x00000000' in read_cap
@@ -163,12 +163,12 @@ def test_tpm2_dam_parameters(u_boot_console):
     ram = u_boot_utils.find_ram_base(u_boot_console)
 
     # Set the DAM parameters to known values
-    u_boot_console.run_command('tpm dam_parameters 3 10 0')
+    u_boot_console.run_command('tpm2 dam_parameters 3 10 0')
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
     # Check the values have been saved
-    read_cap = u_boot_console.run_command('tpm get_capability 0x6 0x20f 0x%x 3' % ram)
+    read_cap = u_boot_console.run_command('tpm2 get_capability 0x6 0x20f 0x%x 3' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
     assert 'Property 0x0000020f: 0x00000003' in read_cap
@@ -185,7 +185,7 @@ def test_tpm2_pcr_read(u_boot_console):
     force_init(u_boot_console)
     ram = u_boot_utils.find_ram_base(u_boot_console) + 1024
 
-    read_pcr = u_boot_console.run_command('tpm pcr_read 0 0x%x' % ram)
+    read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
@@ -212,11 +212,11 @@ def test_tpm2_pcr_extend(u_boot_console):
     force_init(u_boot_console)
     ram = u_boot_utils.find_ram_base(u_boot_console) + 1024
 
-    u_boot_console.run_command('tpm pcr_extend 0 0x%x' % ram)
+    u_boot_console.run_command('tpm2 pcr_extend 0 0x%x' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
 
-    read_pcr = u_boot_console.run_command('tpm pcr_read 0 0x%x' % ram)
+    read_pcr = u_boot_console.run_command('tpm2 pcr_read 0 0x%x' % ram)
     output = u_boot_console.run_command('echo $?')
     assert output.endswith('0')
     assert 'f5 a5 fd 42 d1 6a 20 30 27 98 ef 6e d3 09 97 9b' in read_pcr
-- 
2.14.1

  parent reply	other threads:[~2018-07-19 20:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19 20:35 [U-Boot] [PATCH v2 0/7] Allow both TPM stacks to be compiled at the same time Miquel Raynal
2018-07-19 20:35 ` [U-Boot] [PATCH v2 1/7] tpm: fix typo in kernel doc Miquel Raynal
2018-07-30 20:00   ` [U-Boot] [U-Boot,v2,1/7] " Tom Rini
2018-07-19 20:35 ` [U-Boot] [PATCH v2 2/7] tpm: compile Sandbox driver by default Miquel Raynal
2018-07-30 20:01   ` [U-Boot] [U-Boot, v2, " Tom Rini
2018-07-19 20:35 ` [U-Boot] [PATCH v2 3/7] tpm: remove stale symbol in Kconfig Miquel Raynal
2018-07-20  2:17   ` Simon Glass
2018-07-30 20:01   ` [U-Boot] [U-Boot,v2,3/7] " Tom Rini
2018-07-19 20:35 ` [U-Boot] [PATCH v2 4/7] tpm: allow TPM v1 and v2 to be compiled at the same time Miquel Raynal
2018-07-20  2:17   ` Simon Glass
2018-07-30 20:01   ` [U-Boot] [U-Boot, v2, " Tom Rini
2018-07-19 20:35 ` Miquel Raynal [this message]
2018-07-30 20:01   ` [U-Boot] [U-Boot, v2, 5/7] test/py: tpm2: switch from 'tpm' to 'tpm2' command Tom Rini
2018-07-19 20:35 ` [U-Boot] [PATCH v2 6/7] tpm: make TPM_V2 be compiled by default Miquel Raynal
2018-07-30 20:01   ` [U-Boot] [U-Boot, v2, " Tom Rini
2018-07-19 20:35 ` [U-Boot] [PATCH v2 7/7] sandbox: compile both TPM stack versions and drivers Miquel Raynal
2018-07-30 20:01   ` [U-Boot] [U-Boot, v2, " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180719203512.346-6-miquel.raynal@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.