diff --git a/Cargo.lock b/Cargo.lock index ec8ed09f45..d167434831 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -814,6 +814,7 @@ dependencies = [ "elf", "openssl", "rand", + "regex", "zerocopy", ] diff --git a/test/Cargo.toml b/test/Cargo.toml index 40ce58649e..3c21d59090 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -20,6 +20,7 @@ caliptra-runtime = { workspace = true, default-features = false } elf.workspace = true openssl.workspace = true rand.workspace = true +regex.workspace = true zerocopy.workspace = true caliptra-hw-model.workspace = true dpe.workspace = true diff --git a/test/tests/caliptra_integration_tests/smoke_test.rs b/test/tests/caliptra_integration_tests/smoke_test.rs index 2d61625e56..e348407b5d 100644 --- a/test/tests/caliptra_integration_tests/smoke_test.rs +++ b/test/tests/caliptra_integration_tests/smoke_test.rs @@ -20,6 +20,7 @@ use openssl::nid::Nid; use openssl::sha::{sha384, Sha384}; use rand::rngs::StdRng; use rand::SeedableRng; +use regex::Regex; use std::mem; use zerocopy::AsBytes; @@ -31,6 +32,15 @@ fn assert_output_contains(haystack: &str, needle: &str) { ); } +#[track_caller] +fn assert_output_contains_regex(haystack: &str, needle: &str) { + let re = Regex::new(needle).unwrap(); + assert! { + re.is_match(haystack), + "Expected substring in output not found: {needle}" + } +} + #[test] fn retrieve_csr_test() { const GENERATE_IDEVID_CSR: u32 = 1; @@ -177,7 +187,7 @@ fn smoke_test() { assert_output_contains(&output, "[kat] sha1"); assert_output_contains(&output, "[kat] SHA2-256"); assert_output_contains(&output, "[kat] SHA2-384"); - assert_output_contains(&output, "[kat] SHA2-512-ACC"); + assert_output_contains_regex(&output, r"\[kat\] SHA2-(384|512)-ACC"); assert_output_contains(&output, "[kat] HMAC-384"); assert_output_contains(&output, "[kat] LMS"); assert_output_contains(&output, "[kat] --");