Repository: bearcove/loona (language: rust)

Issue:
Run `miri` in CI
For buffet


Discussion / hints:

Fix patch:
diff --git a/Justfile b/Justfile
index 1b70fc2d..88510418 100644
--- a/Justfile
+++ b/Justfile
@@ -86,3 +86,9 @@ samply:
     export TEST_PROTO=h2
     export PORT=8002
     target/profiling/httpwg-loona
+
+miri *args='':
+    #!/usr/bin/env -S bash -eux
+    rustup toolchain install nightly
+    rustup component add --toolchain nightly-x86_64-unknown-linux-gnu miri
+    MIRIFLAGS=-Zmiri-ignore-leaks cargo +nightly miri nextest run -p buffet -F miri "$@"
diff --git a/crates/buffet/src/bufpool.rs b/crates/buffet/src/bufpool.rs
index 2f12a581..e99b17ea 100644
--- a/crates/buffet/src/bufpool.rs
+++ b/crates/buffet/src/bufpool.rs
@@ -13,7 +13,12 @@ pub use privatepool::{initialize_allocator_with_num_bufs, num_free, Error, Resul
 /// allocation function.
 pub fn initialize_allocator() -> Result<()> {
     // 64 * 1024 * 4096 bytes = 256 MiB
+    #[cfg(not(feature = "miri"))]
     let default_num_bufs = 64 * 1024;
+
+    #[cfg(feature = "miri")]
+    let default_num_bufs = 1024;
+
     initialize_allocator_with_num_bufs(default_num_bufs)
 }
 
diff --git a/crates/buffet/src/net/net_uring.rs b/crates/buffet/src/net/net_uring.rs
index f211988d..720f845d 100644
--- a/crates/buffet/src/net/net_uring.rs
+++ b/crates/buffet/src/net/net_uring.rs
@@ -196,7 +196,7 @@ impl CqueueExt for io_uring::cqueue::Entry {
     }
 }
 
-#[cfg(test)]
+#[cfg(all(test, not(feature = "miri")))]
 mod tests {
     use crate::io::{IntoHalves, ReadOwned, WriteOwned};
 


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 17b7887c..56184d24 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -66,6 +66,7 @@ jobs:
           fail_ci_if_error: false
           verbose: true
           file: coverage/lcov.info
+
   test-httpwg-cli:
     env:
       CARGO_TERM_COLOR: always
@@ -96,6 +97,36 @@ jobs:
           cd ${{ github.workspace }}
           just httpwg-over-tcp
 
+  miri:
+    env:
+      CARGO_TERM_COLOR: always
+    runs-on:
+      - namespace-profile-linux-amd64
+    steps:
+      - name: Check out repository code
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 2
+      - name: Setup cargo cache
+        uses: namespacelabs/nscloud-cache-action@v1
+        with:
+          path: |
+            ./target
+            ./target-cov
+            ~/.cargo/git
+            ~/.cargo/registry
+            ~/.rustup
+      - name: Install Rust specified toolchain
+        run: |
+          rustc --version
+      - uses: taiki-e/install-action@v2
+        with:
+          tool: just,cargo-nextest,cargo-llvm-cov
+      - name: Run miri
+        run: |
+          cd ${{ github.workspace }}
+          just miri
+
   doc:
     env:
       CARGO_TERM_COLOR: always