Skip to content

Commit

Permalink
testutil: remove last use of mssim.OpenConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisccoulson committed Jan 12, 2024
1 parent 8f702d5 commit 27f974d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions testutil/tpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,14 @@ func (c *tpmSimulatorLaunchContext) launch(opts *TPMSimulatorOptions) error {
return fmt.Errorf("cannot start simulator: %w", err)
}

var transport *mssim.Transport
device := mssim.NewLocalDevice(c.port)
var tpm *tpm2.TPMContext

// Give the simulator 5 seconds to start up
Loop:
for i := 0; ; i++ {
var err error
transport, err = mssim.OpenConnection("", c.port)
tpm, err = tpm2.OpenTPMDevice(device)
switch {
case err != nil && i == 4:
return fmt.Errorf("cannot open simulator connection: %w", err)
Expand All @@ -488,8 +490,6 @@ Loop:
break Loop
}
}

tpm := tpm2.NewTPMContext(transport)
defer tpm.Close()

if err := tpm.Startup(tpm2.StartupClear); err != nil {
Expand Down

0 comments on commit 27f974d

Please sign in to comment.