Browse Source

multiboot2-header: update changelog + integration test

Philipp Schuster 11 months ago
parent
commit
90ec7578cc

+ 8 - 2
integration-test/bins/multiboot2_chainloader/src/loader.rs

@@ -1,7 +1,8 @@
+use core::ops::Deref;
 use elf_rs::{ElfFile, ProgramHeaderEntry, ProgramType};
 use multiboot2::{
-    BootLoaderNameTag, CommandLineTag, MemoryArea, MemoryAreaType, MemoryMapTag,
-    ModuleTag,
+    BootLoaderNameTag, CommandLineTag, MemoryArea, MemoryAreaType, MemoryMapTag, ModuleTag,
+    SmbiosTag,
 };
 
 /// Loads the first module into memory. Assumes that the module is a ELF file.
@@ -56,6 +57,11 @@ pub fn load_module(mut modules: multiboot::information::ModuleIter) -> ! {
             elf_mod.end as u32,
             elf_mod.string.unwrap(),
         ))
+        // Test that we can add SmbiosTag multiple times.
+        .add_tag(SmbiosTag::new(1, 1, &[1, 2, 3]).deref())
+        .unwrap()
+        .add_tag(SmbiosTag::new(1, 2, &[1, 2, 3]).deref())
+        .expect("should allow tag multiple times")
         .build();
 
     log::info!(

+ 1 - 0
multiboot2-header/Changelog.md

@@ -4,6 +4,7 @@
 
 - added `EndHeaderTag::default()`
 - MSRV is 1.69
+- Can add multiple `TagType::Smbios` tags in the builder.
 
 ## 0.3.2 (2023-11-30)
 

+ 12 - 0
multiboot2/src/builder/boxed_dst.rs

@@ -141,4 +141,16 @@ mod tests {
         assert_eq!(tag.size as usize, METADATA_SIZE + content.len());
         assert_eq!(tag.string(), Ok(content_rust_str));
     }
+
+    #[test]
+    fn can_hold_tag_trait() {
+        fn consume<T: TagTrait + ?Sized>(_: &T) {}
+        let content = b"hallo\0";
+
+        let tag = BoxedDst::<CustomTag>::new(content);
+        consume(tag.deref());
+        consume(&*tag);
+        // Compiler not smart enough?
+        // consume(&tag);
+    }
 }