Run tests under panic=abort (#749)

This commit is contained in:
Alice Ryhl
2024-12-10 22:30:27 +01:00
committed by GitHub
parent d0a14deeb5
commit f7072c9267
4 changed files with 20 additions and 2 deletions
+10
View File
@@ -89,6 +89,16 @@ jobs:
- name: Test - name: Test
run: ci/test-stable.sh test run: ci/test-stable.sh test
panic-abort:
name: panic=abort tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update $nightly && rustup default $nightly
- name: Run tests with -Cpanic=abort
run: ci/panic-abort.sh
# Run tests on some extra platforms # Run tests on some extra platforms
cross: cross:
name: cross name: cross
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
set -ex
RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test '*'
+2
View File
@@ -291,6 +291,7 @@ fn split_to_uninitialized() {
} }
#[test] #[test]
#[cfg_attr(not(panic = "unwind"), ignore)]
fn split_off_to_at_gt_len() { fn split_off_to_at_gt_len() {
fn make_bytes() -> Bytes { fn make_bytes() -> Bytes {
let mut bytes = BytesMut::with_capacity(100); let mut bytes = BytesMut::with_capacity(100);
@@ -1618,6 +1619,7 @@ fn owned_to_vec() {
} }
#[test] #[test]
#[cfg_attr(not(panic = "unwind"), ignore)]
fn owned_safe_drop_on_as_ref_panic() { fn owned_safe_drop_on_as_ref_panic() {
let buf: [u8; 10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let buf: [u8; 10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
let drop_counter = SharedAtomicCounter::new(); let drop_counter = SharedAtomicCounter::new();
+4 -2
View File
@@ -7,7 +7,7 @@ use bytes::{Buf, Bytes};
#[global_allocator] #[global_allocator]
static LEDGER: Ledger = Ledger::new(); static LEDGER: Ledger = Ledger::new();
const LEDGER_LENGTH: usize = 2048; const LEDGER_LENGTH: usize = 1024 * 1024;
struct Ledger { struct Ledger {
alloc_table: [(AtomicPtr<u8>, AtomicUsize); LEDGER_LENGTH], alloc_table: [(AtomicPtr<u8>, AtomicUsize); LEDGER_LENGTH],
@@ -31,9 +31,11 @@ impl Ledger {
.is_ok() .is_ok()
{ {
entry_size.store(size, Ordering::SeqCst); entry_size.store(size, Ordering::SeqCst);
break; return;
} }
} }
panic!("Ledger ran out of space.");
} }
fn remove(&self, ptr: *mut u8) -> usize { fn remove(&self, ptr: *mut u8) -> usize {