| 1 |
# TPM 2.0 client library |
| 2 |
|
| 3 |
## Tests |
| 4 |
|
| 5 |
This library contains unit tests in `github.com/google/go-tpm/tpm2`, which just |
| 6 |
tests that various encoding and error checking functions work correctly. It also |
| 7 |
contains more comprehensive integration tests in |
| 8 |
`github.com/google/go-tpm/tpm2/test`, which run actual commands on a TPM. |
| 9 |
|
| 10 |
By default, these integration tests are run against the |
| 11 |
[`go-tpm-tools`](https://github.com/google/go-tpm-tools) |
| 12 |
simulator, which is baesed on the |
| 13 |
[Microsoft Reference TPM2 code](https://github.com/microsoft/ms-tpm-20-ref). To |
| 14 |
run both the unit and integration tests, run (in this directory) |
| 15 |
```bash |
| 16 |
go test . ./test |
| 17 |
``` |
| 18 |
|
| 19 |
These integration tests can also be run against a real TPM device. This is |
| 20 |
slightly more complex as the tests often need to be built as a normal user and |
| 21 |
then executed as root. For example, |
| 22 |
```bash |
| 23 |
# Build the test binary without running it |
| 24 |
go test -c github.com/google/go-tpm/tpm2/test |
| 25 |
# Execute the test binary as root |
| 26 |
sudo ./test.test --tpm-path=/dev/tpmrm0 |
| 27 |
``` |
| 28 |
On Linux, The `--tpm-path` causes the integration tests to be run against a |
| 29 |
real TPM located at that path (usually `/dev/tpmrm0` or `/dev/tpm0`). On Windows, the story is similar, execept that |
| 30 |
the `--use-tbs` flag is used instead. |
| 31 |
|
| 32 |
Tip: if your TPM host is remote and you don't want to install Go on it, this |
| 33 |
same two-step process can be used. The test binary can be copied to a remote |
| 34 |
host and run without extra installation (as the test binary has very few |
| 35 |
*runtime* dependancies). |