Skip to content

Commit b595d26

Browse files
committed
ci: add miri
1 parent b90a127 commit b595d26

File tree

12 files changed

+45
-4
lines changed

12 files changed

+45
-4
lines changed

.github/workflows/_build-rust.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ on:
5050
required: false
5151
default: true
5252
description: Execute tests.
53+
do-miri:
54+
type: boolean
55+
required: false
56+
default: false
57+
description: Execute unit tests with miri.
5358

5459
jobs:
5560
rust:
@@ -104,3 +109,10 @@ jobs:
104109
Expand-Archive .\cargo-nextest.zip
105110
cp .\cargo-nextest/cargo-nextest.exe .
106111
.\cargo-nextest.exe nextest run --features ${{ inputs.features }} --no-default-features
112+
- name: Unit Test with Miri
113+
if: inputs.do-miri
114+
# "--tests" so that the doctests are skipped. Currently, the doctest
115+
# in miri fails.
116+
run: |
117+
rustup component add miri
118+
cargo miri test --tests

.github/workflows/rust.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,14 @@ jobs:
161161
- run: cd integration-test && nix-shell --run "echo OK" && cd ..
162162
# Now, run the actual test.
163163
- run: cd integration-test && nix-shell --run ./run.sh && cd ..
164+
165+
miri:
166+
name: tests with miri (nightly)
167+
needs: build_nightly
168+
uses: ./.github/workflows/_build-rust.yml
169+
with:
170+
rust-version: nightly
171+
do-style-check: false
172+
do-test: false
173+
do-miri: true
174+
features: builder,unstable

multiboot2-header/src/builder/header.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ mod tests {
356356
}
357357

358358
#[test]
359+
#[cfg_attr(miri, ignore)]
359360
fn test_builder() {
360361
// Step 1/2: Build Header
361362
let mb2_hdr_data = create_builder().build();

multiboot2-header/src/builder/information_request.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ mod tests {
9898
use crate::{HeaderTagFlag, InformationRequestHeaderTag, MbiTagType, MbiTagTypeId};
9999

100100
#[test]
101+
#[cfg_attr(miri, ignore)]
101102
fn test_builder() {
102103
let builder = InformationRequestHeaderTagBuilder::new(HeaderTagFlag::Required)
103104
.add_ir(MbiTagType::EfiMmap)

multiboot2-header/src/builder/traits.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ mod tests {
5151
use super::*;
5252

5353
#[test]
54+
#[cfg_attr(miri, ignore)]
5455
fn test_as_bytes() {
5556
struct Foobar {
5657
a: u32,

multiboot2/src/boot_loader_name.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ mod tests {
8282

8383
const MSG: &str = "hello";
8484

85-
/// Returns the tag structure in bytes in native endian format.
85+
/// Returns the tag structure in bytes in little endian format.
8686
fn get_bytes() -> std::vec::Vec<u8> {
8787
// size is: 4 bytes for tag + 4 bytes for size + length of null-terminated string
8888
let size = (4 + 4 + MSG.as_bytes().len() + 1) as u32;
@@ -101,6 +101,7 @@ mod tests {
101101

102102
/// Tests to parse a string with a terminating null byte from the tag (as the spec defines).
103103
#[test]
104+
#[cfg_attr(miri, ignore)]
104105
fn test_parse_str() {
105106
let tag = get_bytes();
106107
let tag = unsafe { &*tag.as_ptr().cast::<Tag>() };

multiboot2/src/builder/information.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ mod tests {
408408
}
409409

410410
#[test]
411+
#[cfg_attr(miri, ignore)]
411412
fn test_builder() {
412413
// Step 1/2: Build MBI
413414
let mb2i_data = create_builder().build();

multiboot2/src/builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ mod tests {
139139
let tag_type_id = 1337_u32;
140140
let content = "hallo";
141141

142-
let tag = unsafe { BoxedDst::<CustomTag>::new(tag_type_id, content.as_bytes()) };
142+
let tag = BoxedDst::<CustomTag>::new(tag_type_id, content.as_bytes());
143143
assert_eq!(tag.typ, tag_type_id);
144144
assert_eq!(tag.size as usize, METADATA_SIZE + content.len());
145145
assert_eq!(tag.string(), Ok(content));

multiboot2/src/command_line.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ mod tests {
9191

9292
const MSG: &str = "hello";
9393

94-
/// Returns the tag structure in bytes in native endian format.
94+
/// Returns the tag structure in bytes in little endian format.
9595
fn get_bytes() -> std::vec::Vec<u8> {
9696
// size is: 4 bytes for tag + 4 bytes for size + length of null-terminated string
9797
let size = (4 + 4 + MSG.as_bytes().len() + 1) as u32;
@@ -110,6 +110,7 @@ mod tests {
110110

111111
/// Tests to parse a string with a terminating null byte from the tag (as the spec defines).
112112
#[test]
113+
#[cfg_attr(miri, ignore)]
113114
fn test_parse_str() {
114115
let tag = get_bytes();
115116
let tag = unsafe { &*tag.as_ptr().cast::<Tag>() };

multiboot2/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ mod tests {
661661
}
662662

663663
#[test]
664+
#[cfg_attr(miri, ignore)]
664665
fn name_tag() {
665666
#[repr(C, align(8))]
666667
struct Bytes([u8; 32]);
@@ -695,6 +696,7 @@ mod tests {
695696
}
696697

697698
#[test]
699+
#[cfg_attr(miri, ignore)]
698700
fn framebuffer_tag_rgb() {
699701
// direct RGB mode test:
700702
// taken from GRUB2 running in QEMU at
@@ -755,6 +757,7 @@ mod tests {
755757
}
756758

757759
#[test]
760+
#[cfg_attr(miri, ignore)]
758761
fn framebuffer_tag_indexed() {
759762
// indexed mode test:
760763
// this is synthetic, as I can't get QEMU
@@ -826,6 +829,7 @@ mod tests {
826829
}
827830

828831
#[test]
832+
#[cfg_attr(miri, ignore)]
829833
fn vbe_info_tag() {
830834
//Taken from GRUB2 running in QEMU.
831835
#[repr(C, align(8))]
@@ -996,6 +1000,7 @@ mod tests {
9961000
/// Tests to parse a MBI that was statically extracted from a test run with
9971001
/// GRUB as bootloader.
9981002
#[test]
1003+
#[cfg_attr(miri, ignore)]
9991004
fn grub2() {
10001005
#[repr(C, align(8))]
10011006
struct Bytes([u8; 960]);
@@ -1411,6 +1416,7 @@ mod tests {
14111416
}
14121417

14131418
#[test]
1419+
#[cfg_attr(miri, ignore)]
14141420
fn elf_sections() {
14151421
#[repr(C, align(8))]
14161422
struct Bytes([u8; 168]);
@@ -1487,6 +1493,7 @@ mod tests {
14871493
}
14881494

14891495
#[test]
1496+
#[cfg_attr(miri, ignore)]
14901497
fn efi_memory_map() {
14911498
#[repr(C, align(8))]
14921499
struct Bytes([u8; 72]);
@@ -1565,6 +1572,7 @@ mod tests {
15651572

15661573
/// Example for a custom tag.
15671574
#[test]
1575+
#[cfg_attr(miri, ignore)]
15681576
fn get_custom_tag_from_mbi() {
15691577
const CUSTOM_TAG_ID: u32 = 0x1337;
15701578

@@ -1626,6 +1634,7 @@ mod tests {
16261634

16271635
/// Example for a custom DST tag.
16281636
#[test]
1637+
#[cfg_attr(miri, ignore)]
16291638
fn get_custom_dst_tag_from_mbi() {
16301639
const CUSTOM_TAG_ID: u32 = 0x1337;
16311640

@@ -1703,6 +1712,7 @@ mod tests {
17031712

17041713
/// Tests that `get_tag` can consume multiple types that implement `Into<TagTypeId>`
17051714
#[test]
1715+
#[cfg_attr(miri, ignore)]
17061716
fn get_tag_into_variants() {
17071717
#[repr(C, align(8))]
17081718
struct Bytes([u8; 32]);

multiboot2/src/module.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ mod tests {
131131

132132
const MSG: &str = "hello";
133133

134-
/// Returns the tag structure in bytes in native endian format.
134+
/// Returns the tag structure in bytes in little endian format.
135135
fn get_bytes() -> std::vec::Vec<u8> {
136136
// size is: 4 bytes for tag + 4 bytes for size + length of null-terminated string
137137
// 4 bytes mod_start + 4 bytes mod_end
@@ -153,6 +153,7 @@ mod tests {
153153

154154
/// Tests to parse a string with a terminating null byte from the tag (as the spec defines).
155155
#[test]
156+
#[cfg_attr(miri, ignore)]
156157
fn test_parse_str() {
157158
let tag = get_bytes();
158159
let tag = unsafe { &*tag.as_ptr().cast::<Tag>() };

multiboot2/src/smbios.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ mod tests {
7777

7878
/// Test to parse a given tag.
7979
#[test]
80+
#[cfg_attr(miri, ignore)]
8081
fn test_parse() {
8182
let tag = get_bytes();
8283
let tag = unsafe { &*tag.as_ptr().cast::<Tag>() };

0 commit comments

Comments
 (0)