From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Pengfei Xu <pengfei.xu@intel.com>
Cc: Shuah Khan <shuah@kernel.org>, Qiuxu Zhuo <qiuxu.zhuo@intel.com>,
Heng Su <heng.su@intel.com>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Kai Svahn <kai.svahn@intel.com>
Subject: Re: [PATCH v2] Kernel selftests: TPM2: upgrade TPM2 tests from Python 2 to Python 3
Date: Tue, 23 Jun 2020 00:47:39 +0300 [thread overview]
Message-ID: <20200622214739.GB22727@linux.intel.com> (raw)
In-Reply-To: <20200622214613.GA22727@linux.intel.com>
On Tue, Jun 23, 2020 at 12:46:18AM +0300, Jarkko Sakkinen wrote:
> 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@intel.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.
I.e. use '.encode()' in the call site.
/Jarkko
next prev parent reply other threads:[~2020-06-22 21:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-18 8:15 [PATCH v2] Kernel selftests: TPM2: upgrade TPM2 tests from Python 2 to Python 3 Pengfei Xu
2020-06-22 21:46 ` Jarkko Sakkinen
2020-06-22 21:47 ` Jarkko Sakkinen [this message]
2020-06-23 11:41 ` Pengfei Xu
2020-06-24 23:14 ` Jarkko Sakkinen
2020-06-25 15:55 ` Pengfei Xu
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=20200622214739.GB22727@linux.intel.com \
--to=jarkko.sakkinen@linux.intel.com \
--cc=heng.su@intel.com \
--cc=kai.svahn@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pengfei.xu@intel.com \
--cc=qiuxu.zhuo@intel.com \
--cc=shuah@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox