Skip to content

Commit f5bfdfb

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

File tree

15 files changed

+60
-3
lines changed

15 files changed

+60
-3
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

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ exclude = [
99
]
1010

1111
[workspace.dependencies]
12+
aligned-vec = { version = "0.5", default-features = false }
1213
bitflags = "2"
1314
derive_more = { version = "0.99", default-features = false, features = ["display"] }
1415
log = { version = "0.4", default-features = false }

multiboot2-header/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ derive_more.workspace = true
4848

4949
# used for MBI tags
5050
multiboot2 = "0.16.0"
51+
52+
[dev-dependencies]
53+
aligned-vec.workspace = true

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/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ log.workspace = true
4747

4848
uefi-raw = { version = "0.3", default-features = false }
4949
ptr_meta = { version = "0.2", default-features = false }
50+
51+
[dev-dependencies]
52+
aligned-vec.workspace = true

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/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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ impl<'a> Debug for ModuleIter<'a> {
128128
#[cfg(test)]
129129
mod tests {
130130
use crate::{ModuleTag, Tag, TagType};
131+
use aligned_vec::AVec;
131132

132133
const MSG: &str = "hello";
133134

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

154155
/// Tests to parse a string with a terminating null byte from the tag (as the spec defines).
155156
#[test]
157+
#[cfg_attr(miri, ignore)]
156158
fn test_parse_str() {
157159
let tag = get_bytes();
158160
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)