From: R Nageswara Sastry <rnsastry@linux.ibm.com>
To: Stefan Berger <stefanb@linux.vnet.ibm.com>,
jarkko@kernel.org, linux-integrity@vger.kernel.org
Cc: peterhuewe@gmx.de, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org,
Stefan Berger <stefanb@linux.ibm.com>,
Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH] selftests: tpm2: Implement class desstructor to close file descriptor
Date: Fri, 9 Sep 2022 21:09:28 +0530 [thread overview]
Message-ID: <ca93a532-0a68-0c4f-8920-33b76603dd69@linux.ibm.com> (raw)
In-Reply-To: <20220909152056.1335261-1-stefanb@linux.vnet.ibm.com>
On 09/09/22 8:50 pm, Stefan Berger wrote:
> From: Stefan Berger <stefanb@linux.ibm.com>
>
> Implement a class destructor to close the open TPM file descriptor
> and avoid the following error message:
>
> test_flush_context (tpm2_tests.SpaceTest) ... \
> /usr/lib64/python3.6/unittest/case.py:605: ResourceWarning: \
> unclosed file <_io.FileIO name='/dev/tpmrm0' mode='rb+' closefd=True>
>
> Fixes: 6ea3dfe1e0732 ("selftests: add TPM 2.0 tests")
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: linux-kselftest@vger.kernel.org
> Cc: Jarkko Sakkinen <jarkko@kernel.org>
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Tested-by: Nageswara R Sastry <rnsastry@linux.ibm.com>
>
> ---
> tools/testing/selftests/tpm2/tpm2.py | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/testing/selftests/tpm2/tpm2.py b/tools/testing/selftests/tpm2/tpm2.py
> index 057a4f49c79d..c7363c6764fc 100644
> --- a/tools/testing/selftests/tpm2/tpm2.py
> +++ b/tools/testing/selftests/tpm2/tpm2.py
> @@ -371,6 +371,10 @@ class Client:
> fcntl.fcntl(self.tpm, fcntl.F_SETFL, flags)
> self.tpm_poll = select.poll()
>
> + def __del__(self):
> + if self.tpm:
> + self.tpm.close()
> +
> def close(self):
> self.tpm.close()
>
--
Thanks and Regards
R.Nageswara Sastry
next prev parent reply other threads:[~2022-09-09 15:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 15:20 [PATCH] selftests: tpm2: Implement class desstructor to close file descriptor Stefan Berger
2022-09-09 15:39 ` R Nageswara Sastry [this message]
2022-09-20 4:31 ` Jarkko Sakkinen
2022-09-20 13:14 ` Stefan Berger
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=ca93a532-0a68-0c4f-8920-33b76603dd69@linux.ibm.com \
--to=rnsastry@linux.ibm.com \
--cc=jarkko@kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=stefanb@linux.ibm.com \
--cc=stefanb@linux.vnet.ibm.com \
/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