Skip to content

Commit

Permalink
testutil: change the prototype for wrapMssimTransport
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisccoulson committed Jul 31, 2024
1 parent 8b41c43 commit 12ba3f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion testutil/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/canonical/go-tpm2"
)

func MockWrapMssimTransport(fn func(tpm2.Transport, TPMFeatureFlags) (*Transport, error)) (restore func()) {
func MockWrapMssimTransport(fn func(tpm2.Transport) (*Transport, error)) (restore func()) {
origWrapMssimTransport := wrapMssimTransport
wrapMssimTransport = fn
return func() {
Expand Down
6 changes: 4 additions & 2 deletions testutil/tpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ var (
// MssimPort defines the port number of the TPM simulator command port where TPMBackend is TPMBackendMssim.
MssimPort uint = 2321

wrapMssimTransport = WrapTransport
wrapMssimTransport = func(transport tpm2.Transport) (*Transport, error) {
return WrapTransport(transport, TPMFeatureFlags(math.MaxUint32))
}

ErrSkipNoTPM = errors.New("no TPM configured for the test")
)
Expand Down Expand Up @@ -970,7 +972,7 @@ func (d *simulatorDevice) Open() (tpm2.Transport, error) {
return nil, err
}

return wrapMssimTransport(transport, TPMFeatureFlags(math.MaxUint32))
return wrapMssimTransport(transport)
}

func (d *simulatorDevice) String() string {
Expand Down
2 changes: 1 addition & 1 deletion testutil/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *transportSuite) SetUpTest(c *C) {
}

func (s *transportSuite) initTPMContext(c *C, permittedFeatures TPMFeatureFlags) {
restore := MockWrapMssimTransport(func(transport tpm2.Transport, _ TPMFeatureFlags) (*Transport, error) {
restore := MockWrapMssimTransport(func(transport tpm2.Transport) (*Transport, error) {
return WrapTransport(&ignoreCloseTransport{transport: transport}, permittedFeatures)
})
defer restore()
Expand Down

0 comments on commit 12ba3f6

Please sign in to comment.