From 8f702d5524ae28fbbc6b55f9bf318657e09fe0d6 Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Fri, 12 Jan 2024 22:28:06 +0000 Subject: [PATCH] testutil: use OpenTPMDevice --- testutil/tpm.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/testutil/tpm.go b/testutil/tpm.go index 7be58c9..0b6110d 100644 --- a/testutil/tpm.go +++ b/testutil/tpm.go @@ -257,18 +257,17 @@ func (c *tpmSimulatorLaunchContext) stopAndTerminate() (err error) { c.captureErr("terminate", c.terminateFn(stopOk)) }() - transport, err := mssim.OpenConnection("", c.port) + device := mssim.NewLocalDevice(c.port) + tpm, err := tpm2.OpenTPMDevice(device) if err != nil { return fmt.Errorf("cannot open simulator connection for stop: %w", err) } - - tpm := tpm2.NewTPMContext(transport) tpm.SetCommandTimeout(5 * time.Second) c.captureErr("shutdown", func() error { return tpm.Shutdown(tpm2.StartupClear) }) - if err := transport.Stop(); err != nil { + if err := tpm.Transport().(*mssim.Transport).Stop(); err != nil { return fmt.Errorf("cannot stop simulator: %w", err) } if err := tpm.Close(); err != nil {