Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests under panic=abort #749

Merged
merged 16 commits into from
Dec 10, 2024
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)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[cfg_attr(not(panic = "unwind"), ignore)]
#[cfg_attr(panic = "abort", ignore)]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be additional panic strategies in the future.

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)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[cfg_attr(not(panic = "unwind"), ignore)]
#[cfg_attr(panic = "abort", 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
Loading