sim_run_core/
platform_bundle.rs1use sim_platform_core::PureBootEnvelope;
2
3#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct BootLoadRequest {
6 pub id: String,
8 pub content_digest: String,
10}
11
12#[must_use]
15pub fn boot_load_requests(envelope: &PureBootEnvelope) -> Vec<BootLoadRequest> {
16 std::iter::once(&envelope.load_plan.application)
17 .chain(envelope.load_plan.libraries.iter())
18 .map(|content| BootLoadRequest {
19 id: content.id.0.clone(),
20 content_digest: content.content_digest.clone(),
21 })
22 .collect()
23}
24
25#[cfg(test)]
26mod tests {
27 use super::*;
28 use sim_platform_core::{BundleContent, LibraryLoadPlan, OpenSymbol};
29
30 #[test]
31 fn bootloader_consumes_only_the_shared_envelope_load_plan() {
32 let envelope = PureBootEnvelope {
33 schema: OpenSymbol("boot/envelope/v1".into()),
34 capsule: OpenSymbol("platform/site/model".into()),
35 bootstrap: OpenSymbol("bootstrap/sim-native-abi-v1".into()),
36 load_plan: LibraryLoadPlan {
37 application: content("application/portable", "sha256:app"),
38 libraries: vec![content("library/core", "sha256:core")],
39 },
40 };
41 assert_eq!(
42 boot_load_requests(&envelope),
43 vec![
44 BootLoadRequest {
45 id: "application/portable".into(),
46 content_digest: "sha256:app".into()
47 },
48 BootLoadRequest {
49 id: "library/core".into(),
50 content_digest: "sha256:core".into()
51 },
52 ]
53 );
54 }
55
56 fn content(id: &str, digest: &str) -> BundleContent {
57 BundleContent {
58 id: OpenSymbol(id.into()),
59 content_digest: digest.into(),
60 capabilities: vec![],
61 }
62 }
63}