[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200622214613.GA22727@linux.intel.com>
Date: Tue, 23 Jun 2020 00:46:13 +0300
From: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
To: Pengfei Xu <pengfei.xu@...el.com>
Cc: Shuah Khan <shuah@...nel.org>, Qiuxu Zhuo <qiuxu.zhuo@...el.com>,
Heng Su <heng.su@...el.com>, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org, Kai Svahn <kai.svahn@...el.com>
Subject: Re: [PATCH v2] Kernel selftests: TPM2: upgrade TPM2 tests from
Python 2 to Python 3
On Thu, Jun 18, 2020 at 04:15:02PM +0800, Pengfei Xu wrote:
> Python 2 is no longer supported by the Python upstream project, so
> upgrade TPM2 tests to Python 3.
>
> Signed-off-by: Pengfei Xu <pengfei.xu@...el.com>
Use "selftests: tpm: <short summary>".
> ---
> tools/testing/selftests/tpm2/test_smoke.sh | 4 +-
> tools/testing/selftests/tpm2/test_space.sh | 2 +-
> tools/testing/selftests/tpm2/tpm2.py | 68 ++++++++++++++--------
> tools/testing/selftests/tpm2/tpm2_tests.py | 24 +++++---
> 4 files changed, 61 insertions(+), 37 deletions(-)
>
> diff --git a/tools/testing/selftests/tpm2/test_smoke.sh b/tools/testing/selftests/tpm2/test_smoke.sh
> index 663062701d5a..d05467f6d258 100755
> --- a/tools/testing/selftests/tpm2/test_smoke.sh
> +++ b/tools/testing/selftests/tpm2/test_smoke.sh
> @@ -6,8 +6,8 @@ ksft_skip=4
>
> [ -f /dev/tpm0 ] || exit $ksft_skip
>
> -python -m unittest -v tpm2_tests.SmokeTest
> -python -m unittest -v tpm2_tests.AsyncTest
> +python3 -m unittest -v tpm2_tests.SmokeTest
> +python3 -m unittest -v tpm2_tests.AsyncTest
>
> CLEAR_CMD=$(which tpm2_clear)
> if [ -n $CLEAR_CMD ]; then
> diff --git a/tools/testing/selftests/tpm2/test_space.sh b/tools/testing/selftests/tpm2/test_space.sh
> index 36c9d030a1c6..151c64e8ee9f 100755
> --- a/tools/testing/selftests/tpm2/test_space.sh
> +++ b/tools/testing/selftests/tpm2/test_space.sh
> @@ -6,4 +6,4 @@ ksft_skip=4
>
> [ -f /dev/tpmrm0 ] || exit $ksft_skip
>
> -python -m unittest -v tpm2_tests.SpaceTest
> +python3 -m unittest -v tpm2_tests.SpaceTest
> diff --git a/tools/testing/selftests/tpm2/tpm2.py b/tools/testing/selftests/tpm2/tpm2.py
> index d0fcb66a88a6..b0ccc1499c53 100644
> --- a/tools/testing/selftests/tpm2/tpm2.py
> +++ b/tools/testing/selftests/tpm2/tpm2.py
> @@ -247,14 +247,18 @@ class ProtocolError(Exception):
> class AuthCommand(object):
> """TPMS_AUTH_COMMAND"""
>
> - def __init__(self, session_handle=TPM2_RS_PW, nonce='', session_attributes=0,
> - hmac=''):
> + def __init__(self, session_handle=TPM2_RS_PW, nonce=''.encode(),
> + session_attributes=0, hmac=''.encode()):
> + if not isinstance(nonce, bytes):
> + nonce = nonce.encode()
> + if not isinstance(hmac, bytes):
> + hmac = hmac.encode()
This looks messy. Please, instead
def __init__(self, session_handle=TPM2_RS_PW, nonce=bytes(),
session_attributes=0, hmac=bytes()):
self.session_handle = session_handle
self.nonce = nonce
self.session_attributes = session_attributes
Applies also to other places.
/Jarkko
Powered by blists - more mailing lists