tpm: add startup response tests

Cover the accepted TPM2_Startup(CLEAR) response codes so the swtpm
reset handling keeps tolerating already-initialized TPMs.

Assisted-by: Copilot:GPT-5.5
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu
2026-05-30 15:43:44 -07:00
committed by Rob Bradford
parent f4f5fcc06d
commit 8d0dc52cfa

View File

@@ -562,3 +562,19 @@ impl Drop for Emulator {
}
}
}
#[cfg(test)]
mod unit_tests {
use super::*;
#[test]
fn test_startup_response_accepts_success_and_initialized() {
assert!(startup_response_is_ok(TPM_SUCCESS));
assert!(startup_response_is_ok(TPM_RC_INITIALIZE));
}
#[test]
fn test_startup_response_rejects_other_errors() {
assert!(!startup_response_is_ok(0x101));
}
}