Skip to content

Commit f7072c9

Browse files
authored
Run tests under panic=abort (#749)
1 parent d0a14de commit f7072c9

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

.github/workflows/ci.yml

+10
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ jobs:
8989
- name: Test
9090
run: ci/test-stable.sh test
9191

92+
panic-abort:
93+
name: panic=abort tests
94+
runs-on: ubuntu-latest
95+
steps:
96+
- uses: actions/checkout@v4
97+
- name: Install Rust
98+
run: rustup update $nightly && rustup default $nightly
99+
- name: Run tests with -Cpanic=abort
100+
run: ci/panic-abort.sh
101+
92102
# Run tests on some extra platforms
93103
cross:
94104
name: cross

ci/panic-abort.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test '*'

tests/test_bytes.rs

+2
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ fn split_to_uninitialized() {
291291
}
292292

293293
#[test]
294+
#[cfg_attr(not(panic = "unwind"), ignore)]
294295
fn split_off_to_at_gt_len() {
295296
fn make_bytes() -> Bytes {
296297
let mut bytes = BytesMut::with_capacity(100);
@@ -1618,6 +1619,7 @@ fn owned_to_vec() {
16181619
}
16191620

16201621
#[test]
1622+
#[cfg_attr(not(panic = "unwind"), ignore)]
16211623
fn owned_safe_drop_on_as_ref_panic() {
16221624
let buf: [u8; 10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
16231625
let drop_counter = SharedAtomicCounter::new();

tests/test_bytes_vec_alloc.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bytes::{Buf, Bytes};
77
#[global_allocator]
88
static LEDGER: Ledger = Ledger::new();
99

10-
const LEDGER_LENGTH: usize = 2048;
10+
const LEDGER_LENGTH: usize = 1024 * 1024;
1111

1212
struct Ledger {
1313
alloc_table: [(AtomicPtr<u8>, AtomicUsize); LEDGER_LENGTH],
@@ -31,9 +31,11 @@ impl Ledger {
3131
.is_ok()
3232
{
3333
entry_size.store(size, Ordering::SeqCst);
34-
break;
34+
return;
3535
}
3636
}
37+
38+
panic!("Ledger ran out of space.");
3739
}
3840

3941
fn remove(&self, ptr: *mut u8) -> usize {

0 commit comments

Comments
 (0)