Skip to content

Commit 07a6f7d

Browse files
committed
ci: add miri
1 parent 2161c41 commit 07a6f7d

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>() };

0 commit comments

Comments
 (0)