Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BM/tpm: add 15 tpm test cases #329

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* [tdx-guest](tdx-guest/README.md)
* [tdx-osv-sanity](tdx-osv-sanity/README.md) (TODO)
* [telemetry](telemetry/README.md)
* [tpm](tpm/README.md)
* [Intel_TH(Trace Hub)](th/README.md)
* [thermal](thermal/README.md)
* [topology](topology/README.md)
Expand Down
2 changes: 2 additions & 0 deletions BM/tpm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__
*.log
61 changes: 61 additions & 0 deletions BM/tpm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Trust Platform Module

## Description
Trust Platform Module(TPM) is a physical or embedded security technology
(microcontroller) that resides on a computer's motherboard or in its processor.
TPMs use cryptography to help securely store essential and critical information
on PCs to enable platform authentication.

The Intel® PTT is an integrated TPM that adheres to the 2.0 specifications
and offers the same capabilities of a discrete TPM, only it resides in the
system’s firmware, thus removing the need for dedicated processing or memory
resources.

TPM2 smoke test: test_smoke.sh
```
# python3 -m unittest -v tpm2_tests.SmokeTest
test_read_partial_overwrite (tpm2_tests.SmokeTest) ... ok
test_read_partial_resp (tpm2_tests.SmokeTest) ... ok
test_seal_with_auth (tpm2_tests.SmokeTest) ... ok
test_seal_with_policy (tpm2_tests.SmokeTest) ... ok
test_seal_with_too_long_auth (tpm2_tests.SmokeTest) ... ok
test_send_two_cmds (tpm2_tests.SmokeTest) ... ok
test_too_short_cmd (tpm2_tests.SmokeTest) ... ok
test_unseal_with_wrong_auth (tpm2_tests.SmokeTest) ... ok
test_unseal_with_wrong_policy (tpm2_tests.SmokeTest) ... ok

----------------------------------------------------------------------
Ran 9 tests in 293.561s

OK
```

TPM2 space content test: test_space.sh
```
# python3 -m unittest -v tpm2_tests.SpaceTest
test_flush_context (tpm2_tests.SpaceTest) ... ok
test_get_handles (tpm2_tests.SpaceTest) ... ok
test_invalid_cc (tpm2_tests.SpaceTest) ... ok
test_make_two_spaces (tpm2_tests.SpaceTest) ... ok

----------------------------------------------------------------------
Ran 4 tests in 261.409s

OK
```


TPM2 sync test: test_async.sh
```
# python3 -m unittest -v tpm2_tests.AsyncTest
test_async (tpm2_tests.AsyncTest) ... ok
test_flush_invalid_context (tpm2_tests.AsyncTest) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.004s

OK
```

## Expected result
All test results should show pass, no fail.
13 changes: 13 additions & 0 deletions BM/tpm/test_async.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

[ -e /dev/tpm0 ] || exit $ksft_skip
[ -e /dev/tpmrm0 ] || exit $ksft_skip

# shellcheck disable=SC3028,SC3054
TPM_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
export PYTHONPATH="$TPM_ROOT"
python3 -m unittest -v tpm2_tests.AsyncTest
12 changes: 12 additions & 0 deletions BM/tpm/test_smoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

[ -e /dev/tpm0 ] || exit $ksft_skip

# shellcheck disable=SC3028,SC3054
TPM_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
export PYTHONPATH="$TPM_ROOT"
python3 -m unittest -v tpm2_tests.SmokeTest
12 changes: 12 additions & 0 deletions BM/tpm/test_space.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)

# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

[ -e /dev/tpmrm0 ] || exit $ksft_skip

# shellcheck disable=SC3028,SC3054
TPM_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
export PYTHONPATH="$TPM_ROOT"
python3 -m unittest -v tpm2_tests.SpaceTest
9 changes: 9 additions & 0 deletions BM/tpm/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file collects Intel TPM(Trust Platform Module) tests on
# Intel® Architecture-based platforms.
# @hw_dep: [ -e "/dev/tpm0" ] @ No /dev/tpm0 device node to support TPM
# @other_dep: general_test.sh -t kconfig -k "CONFIG_TCG_TPM=y" @ No TPM kconfig CONFIG_TCG_TPM=y
# @other_warn: [ -e "/dev/tpmrm0" ] @ No /dev/tpmrm0 device node test_async.sh will skip with return 4

test_smoke.sh
test_space.sh
test_async.sh
Loading
Loading