Skip to content

Commit

Permalink
Run tests under panic=abort (#749)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn authored Dec 10, 2024
1 parent d0a14de commit f7072c9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ jobs:
- name: 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
cross:
name: cross
Expand Down
4 changes: 4 additions & 0 deletions ci/panic-abort.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

set -ex
RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test '*'
2 changes: 2 additions & 0 deletions tests/test_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ fn split_to_uninitialized() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore)]
fn split_off_to_at_gt_len() {
fn make_bytes() -> Bytes {
let mut bytes = BytesMut::with_capacity(100);
Expand Down Expand Up @@ -1618,6 +1619,7 @@ fn owned_to_vec() {
}

#[test]
#[cfg_attr(not(panic = "unwind"), ignore)]
fn owned_safe_drop_on_as_ref_panic() {
let buf: [u8; 10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
let drop_counter = SharedAtomicCounter::new();
Expand Down
6 changes: 4 additions & 2 deletions tests/test_bytes_vec_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bytes::{Buf, Bytes};
#[global_allocator]
static LEDGER: Ledger = Ledger::new();

const LEDGER_LENGTH: usize = 2048;
const LEDGER_LENGTH: usize = 1024 * 1024;

struct Ledger {
alloc_table: [(AtomicPtr<u8>, AtomicUsize); LEDGER_LENGTH],
Expand All @@ -31,9 +31,11 @@ impl Ledger {
.is_ok()
{
entry_size.store(size, Ordering::SeqCst);
break;
return;
}
}

panic!("Ledger ran out of space.");
}

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

0 comments on commit f7072c9

Please sign in to comment.