Add testhelper.Open with TCP support#436
Merged
Merged
Conversation
Adds support for spawning a local reference simulator binary via the new '--tpm-sim-path' flag. The simulator is spawned inside a temporary directory with '--pick_ports' enabled. Port files are polled on startup and parsed to open the TCP transport.
All unit tests under `tpm2/test` are refactored to use `testhelper.Open` to utilize this support.
To show that this works:
1. Build the Reference Simulator:
cmake --build /usr/local/google/home/joerichey/dev/tcg/TPM/build --target Simulator
2. Run tests using the built binary:
go test ./tpm2/test -tpm-sim-path /usr/local/google/home/joerichey/dev/tcg/TPM/build/Simulator/Simulator
Note:
The RSA 3072 and 4096 parameter tests ('TestTestParms') are expected to fail when executed against the Reference Simulator because the Reference Simulator compiles with native support for 3072-bit and 4096-bit RSA keys, whereas the test suite expects them to be unsupported and return TPM_RC_VALUE.
Signed-off-by: Joe Richey <joerichey@google.com>
Member
|
Here's the idea we discussed earlier about how to handle spawning the simulator per-test: It uses the go test ./tpm2/test --tpm-sim-path ~/dev/tcg/TPM/build/Simulator/SimulatorPasses all the tests except for the ones we expect it to fail. |
…implify TCP Stop - Raise maxListLength to 32767 to support larger contexts from modern simulator configurations (Part 2, Section 10.3.1). - Rename transport/test directory to transport/testhelper and clean up test helper imports. - Refactor startProcess to initialize the process struct first and defer Close. - Simplify TCP Stop logic by only sending tpmStop and omitting platformStop. - Clean up port file polling in readPorts to use io/fs and time.Ticker.
Signed-off-by: Joe Richey <joerichey@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds TCP support to the simulator.
Summary of changes:
cmd_addrandplat_addr) to specify command and platform TCP ports.OpenSimulator()to check for these flags. If both are provided, it initializes a TCP transport connection instead of using the default local simulator.