Skip to content

Commit

Permalink
testutil: improve error messaging when resetting the simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisccoulson committed Jan 11, 2025
1 parent b896a4b commit 389b7df
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions testutil/tpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,15 +1074,18 @@ func ClearTPMUsingPlatformHierarchyT(t *testing.T, tpm *tpm2.TPMContext) {

func resetTPMSimulator(tpm *tpm2.TPMContext, transport *mssim.Transport, startup bool) error {
if err := tpm.Shutdown(tpm2.StartupClear); err != nil {
return err
return fmt.Errorf("shutdown failed: %w", err)
}
if err := transport.Reset(); err != nil {
return fmt.Errorf("resetting the simulator failed: %v", err)
return fmt.Errorf("resetting the simulator failed: %w", err)
}
if !startup {
return nil
}
return tpm.Startup(tpm2.StartupClear)
if err := tpm.Startup(tpm2.StartupClear); err != nil {
return fmt.Errorf("startup failed: %w", err)
}
return nil
}

// ResetTPMSimulatorT issues a Shutdown(Clear) -> Reset -> Startup(Clear) cycle of the
Expand Down

0 comments on commit 389b7df

Please sign in to comment.