Debian Codegraph @

tpm/testing.md

raw
1 # Testing TPM 1.2 Functionality
2
3 **TODO(https://github.com/google/go-tpm/issues/91):** Support for testing the TPM 1.2 stack against
4 a simulator is a work in progress. Today, it requires several manual steps.
5
6 ## Overview
7
8 As TPM 1.2s are phased out of common developer devices, testing changes to the TPM 1.2 stack is
9 difficult without special hardware. To support development on the TPM 1.2 stack without special
10 hardware, a TPM 1.2 simulator or emulator may be used. This document discusses how to use
11 [IBM's TPM 1.2 simulator](http://ibmswtpm.sourceforge.net) (on a Linux or Mac OS device, Windows is
12 not yet supported) to run the go-tpm TPM 1.2 tests (in the `go-tpm/tpm/` directory).
13
14 ## Downloading, building, and using the IBM TPM 1.2 Simulator
15
16 * Download the latest release of the
17 [IBM TPM 1.2 Simulator](https://sourceforge.net/projects/ibmswtpm/), unpack the tarball, and `cd`
18 into it.
19 * Add `-DTPM_UNIX_DOMAIN_SOCKET` to `tpm/makefile-en-ac`.
20 * Build the simulator with `make -f tpm/makefile-en-ac`
21 * Set `TEMP_TPM=/tmp/tpm` or some other suitable temporary location for the TPM state files and Unix
22 domain socket.
23 * Start the simulator with `TPM_PATH=${TEMP_TPM} TPM_PORT=${TEMP_TPM}/tpm.sock`
24
25 ## Running the TPM 1.2 tests against the IBM TPM 1.2 Simulator
26
27 * Comment out the line `t.Skip()` in `TestTakeOwnership`. This test normally does not work on
28 physical TPMs, so it is normally disabled.
29 * Use `TestTakeOwnership` to take ownership of the simulated TPM with `TPM_PATH=${TEMP_TPM}/tpm.sock
30 go test -v ./tpm/... -run TestTakeOwnership -count=1`
31 * Run the full test suite with `TPM_PATH=${TEMP_TPM}/tpm.sock go test -v ./tpm/...`
32
33 ## Future Improvements
34
35 * Add setup logic to the TPM 1.2 tests to take ownership of an unowned TPM under test.
36 * Wrap a TPM 1.2 simulator somewhere (possibly in https://github.com/google/go-tpm-tools) and
37 integrate it into test setup for the TPM 1.2 tests.
38 * Resolve issues that necessitated the use of `t.Skip()` in current tests.
39 * Either add an informative comment along with a skip when a test fails for an expected reason, or
40 remove the test.
41 * Resolve issues with current tests that fail on the simulator (such as `TestGetAlgs`).
42 * Automate the use of a simulator in a Continuous Integration environment that is accessible to
43 GitHub.