Skip to content

Commit

Permalink
selftests: tpm: add async space test with noneexisting handle
Browse files Browse the repository at this point in the history
Add a test for /dev/tpmrm0 in async mode that checks if
the code handles invalid handles correctly.

Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: <linux-integrity@vger.kernel.org>
Cc: <linux-kselftest@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Tested-by: Jarkko Sakkinen<jarkko@kernel.org>
Signed-off-by: Tadeusz Struk <tstruk@gmail.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
  • Loading branch information
Tadeusz Struk authored and Jarkko Sakkinen committed Mar 8, 2022
1 parent 2e8e4c8 commit 8335adb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tools/testing/selftests/tpm2/tpm2_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,19 @@ def test_async(self):
log.debug("Calling get_cap in a NON_BLOCKING mode")
async_client.get_cap(tpm2.TPM2_CAP_HANDLES, tpm2.HR_LOADED_SESSION)
async_client.close()

def test_flush_invalid_context(self):
log = logging.getLogger(__name__)
log.debug(sys._getframe().f_code.co_name)

async_client = tpm2.Client(tpm2.Client.FLAG_SPACE | tpm2.Client.FLAG_NONBLOCK)
log.debug("Calling flush_context passing in an invalid handle ")
handle = 0x80123456
rc = 0
try:
async_client.flush_context(handle)
except OSError as e:
rc = e.errno

self.assertEqual(rc, 22)
async_client.close()

0 comments on commit 8335adb

Please sign in to comment.