From 2781a9f5c4aa85a335bc7cfe41d87aaa6895c77d Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Wed, 4 Dec 2024 17:55:41 +0100 Subject: [PATCH 01/16] Add panic=abort workflow --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0136c47b..01e81e675 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,6 +89,18 @@ 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: Install cargo-hack + uses: taiki-e/install-action@cargo-hack + - name: Test + run: RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" ci/test-stable.sh test + # Run tests on some extra platforms cross: name: cross From 3adf6ff31f4bffac1b1648e7ad5d7707fdc63054 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Wed, 4 Dec 2024 18:04:31 +0100 Subject: [PATCH 02/16] gate two tests to panic=unwind --- tests/test_bytes.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs index fdc36ce8d..94b46642e 100644 --- a/tests/test_bytes.rs +++ b/tests/test_bytes.rs @@ -291,6 +291,7 @@ fn split_to_uninitialized() { } #[test] +#[cfg(panic = "unwind")] fn split_off_to_at_gt_len() { fn make_bytes() -> Bytes { let mut bytes = BytesMut::with_capacity(100); @@ -1618,6 +1619,7 @@ fn owned_to_vec() { } #[test] +#[cfg(panic = "unwind")] 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(); From 2045c717f03e0c0dc9c98134b291fe35d6ce4b6d Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Wed, 4 Dec 2024 21:11:11 +0100 Subject: [PATCH 03/16] Ignore instead of cfg out --- tests/test_bytes.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs index 94b46642e..6ab418329 100644 --- a/tests/test_bytes.rs +++ b/tests/test_bytes.rs @@ -291,7 +291,7 @@ fn split_to_uninitialized() { } #[test] -#[cfg(panic = "unwind")] +#[cfg_attr(not(panic = "unwind"), ignore)] fn split_off_to_at_gt_len() { fn make_bytes() -> Bytes { let mut bytes = BytesMut::with_capacity(100); @@ -1619,7 +1619,7 @@ fn owned_to_vec() { } #[test] -#[cfg(panic = "unwind")] +#[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(); From b2ad89e269b964701111679c42cff0eb8bf712c6 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 16:40:41 +0100 Subject: [PATCH 04/16] temp ignore for ci --- tests/test_bytes_vec_alloc.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_bytes_vec_alloc.rs b/tests/test_bytes_vec_alloc.rs index 107e56e58..0d98ee9a5 100644 --- a/tests/test_bytes_vec_alloc.rs +++ b/tests/test_bytes_vec_alloc.rs @@ -83,6 +83,7 @@ unsafe impl GlobalAlloc for Ledger { } #[test] +#[ignore] fn test_bytes_advance() { let mut bytes = Bytes::from(vec![10, 20, 30]); bytes.advance(1); @@ -90,6 +91,7 @@ fn test_bytes_advance() { } #[test] +#[ignore] fn test_bytes_truncate() { let mut bytes = Bytes::from(vec![10, 20, 30]); bytes.truncate(2); From 14d9dbb4fe67219c3755e57986d375b53916a593 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 16:53:18 +0100 Subject: [PATCH 05/16] Add new script --- .github/workflows/ci.yml | 4 ++-- ci/panic-abort.sh | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100755 ci/panic-abort.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01e81e675..b945b8bc9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,8 +98,8 @@ jobs: run: rustup update $nightly && rustup default $nightly - name: Install cargo-hack uses: taiki-e/install-action@cargo-hack - - name: Test - run: RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" ci/test-stable.sh test + - name: Run tests with -Cpanic=abort + run: ci/panic-abort.sh # Run tests on some extra platforms cross: diff --git a/ci/panic-abort.sh b/ci/panic-abort.sh new file mode 100755 index 000000000..4284791f1 --- /dev/null +++ b/ci/panic-abort.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +set -ex +RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test '*' From b1e8ef70cf1adc7e4a4420631e02d006f0761a61 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 16:55:46 +0100 Subject: [PATCH 06/16] Revert "temp ignore for ci" This reverts commit b2ad89e269b964701111679c42cff0eb8bf712c6. --- tests/test_bytes_vec_alloc.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_bytes_vec_alloc.rs b/tests/test_bytes_vec_alloc.rs index 0d98ee9a5..107e56e58 100644 --- a/tests/test_bytes_vec_alloc.rs +++ b/tests/test_bytes_vec_alloc.rs @@ -83,7 +83,6 @@ unsafe impl GlobalAlloc for Ledger { } #[test] -#[ignore] fn test_bytes_advance() { let mut bytes = Bytes::from(vec![10, 20, 30]); bytes.advance(1); @@ -91,7 +90,6 @@ fn test_bytes_advance() { } #[test] -#[ignore] fn test_bytes_truncate() { let mut bytes = Bytes::from(vec![10, 20, 30]); bytes.truncate(2); From 27a2bf80982bed4a581017119dc746ddb49a2fba Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 16:59:48 +0100 Subject: [PATCH 07/16] add --nocapture --- ci/panic-abort.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/panic-abort.sh b/ci/panic-abort.sh index 4284791f1..61c90c14e 100755 --- a/ci/panic-abort.sh +++ b/ci/panic-abort.sh @@ -1,4 +1,4 @@ #!/bin/bash set -ex -RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test '*' +RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test '*' -- --nocapture From 7c838998382313cd8a41c59cf75dd38dcbb6bba5 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 17:02:26 +0100 Subject: [PATCH 08/16] tmp restrict test --- ci/panic-abort.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/panic-abort.sh b/ci/panic-abort.sh index 61c90c14e..83f4f314a 100755 --- a/ci/panic-abort.sh +++ b/ci/panic-abort.sh @@ -1,4 +1,4 @@ #!/bin/bash set -ex -RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test '*' -- --nocapture +RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test test_bytes_vec_alloc -- --nocapture From 0a919a34c60ca27b139d8d1777a3455a2e2264a1 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 17:06:47 +0100 Subject: [PATCH 09/16] testing --- tests/test_bytes_vec_alloc.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_bytes_vec_alloc.rs b/tests/test_bytes_vec_alloc.rs index 107e56e58..c27bd593b 100644 --- a/tests/test_bytes_vec_alloc.rs +++ b/tests/test_bytes_vec_alloc.rs @@ -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 { @@ -83,6 +85,7 @@ unsafe impl GlobalAlloc for Ledger { } #[test] +#[ignore] fn test_bytes_advance() { let mut bytes = Bytes::from(vec![10, 20, 30]); bytes.advance(1); @@ -97,6 +100,7 @@ fn test_bytes_truncate() { } #[test] +#[ignore] fn test_bytes_truncate_and_advance() { let mut bytes = Bytes::from(vec![10, 20, 30]); bytes.truncate(2); @@ -114,6 +118,7 @@ fn invalid_ptr(addr: usize) -> *mut T { } #[test] +#[ignore] fn test_bytes_into_vec() { let vec = vec![33u8; 1024]; From aea9a30458ae17cc85d7392f0dac834588469f8f Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 17:09:24 +0100 Subject: [PATCH 10/16] advance --- tests/test_bytes_vec_alloc.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_bytes_vec_alloc.rs b/tests/test_bytes_vec_alloc.rs index c27bd593b..c88a62760 100644 --- a/tests/test_bytes_vec_alloc.rs +++ b/tests/test_bytes_vec_alloc.rs @@ -85,7 +85,6 @@ unsafe impl GlobalAlloc for Ledger { } #[test] -#[ignore] fn test_bytes_advance() { let mut bytes = Bytes::from(vec![10, 20, 30]); bytes.advance(1); From 48bb7ae0f557bafb8c7b456ef985b69d5ea599d7 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 17:12:29 +0100 Subject: [PATCH 11/16] into_vec --- tests/test_bytes_vec_alloc.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_bytes_vec_alloc.rs b/tests/test_bytes_vec_alloc.rs index c88a62760..842b0700a 100644 --- a/tests/test_bytes_vec_alloc.rs +++ b/tests/test_bytes_vec_alloc.rs @@ -99,7 +99,6 @@ fn test_bytes_truncate() { } #[test] -#[ignore] fn test_bytes_truncate_and_advance() { let mut bytes = Bytes::from(vec![10, 20, 30]); bytes.truncate(2); From eaefd15e9ebb79be3ce9b2c23134be676060a7ad Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 17:14:23 +0100 Subject: [PATCH 12/16] into_vec 12 --- tests/test_bytes_vec_alloc.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_bytes_vec_alloc.rs b/tests/test_bytes_vec_alloc.rs index 842b0700a..4aed83bb5 100644 --- a/tests/test_bytes_vec_alloc.rs +++ b/tests/test_bytes_vec_alloc.rs @@ -116,7 +116,6 @@ fn invalid_ptr(addr: usize) -> *mut T { } #[test] -#[ignore] fn test_bytes_into_vec() { let vec = vec![33u8; 1024]; From 90abfe9e294603dbcaffb1389eeb8d4602dec70d Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 17:15:50 +0100 Subject: [PATCH 13/16] increase ledger --- tests/test_bytes_vec_alloc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_bytes_vec_alloc.rs b/tests/test_bytes_vec_alloc.rs index 4aed83bb5..2242fcac2 100644 --- a/tests/test_bytes_vec_alloc.rs +++ b/tests/test_bytes_vec_alloc.rs @@ -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, AtomicUsize); LEDGER_LENGTH], From acdeb9686f7c33cc677d3f4bfa3bccfb8503cd68 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 17:16:51 +0100 Subject: [PATCH 14/16] rustfmt --- tests/test_bytes_vec_alloc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_bytes_vec_alloc.rs b/tests/test_bytes_vec_alloc.rs index 2242fcac2..48fea1e9a 100644 --- a/tests/test_bytes_vec_alloc.rs +++ b/tests/test_bytes_vec_alloc.rs @@ -7,7 +7,7 @@ use bytes::{Buf, Bytes}; #[global_allocator] static LEDGER: Ledger = Ledger::new(); -const LEDGER_LENGTH: usize = 1024*1024; +const LEDGER_LENGTH: usize = 1024 * 1024; struct Ledger { alloc_table: [(AtomicPtr, AtomicUsize); LEDGER_LENGTH], From 3dc89042eb166c59137301b80723a0587c4021ac Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 17:17:42 +0100 Subject: [PATCH 15/16] Don't need cargo hack --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b945b8bc9..bc868bbbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,8 +96,6 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust run: rustup update $nightly && rustup default $nightly - - name: Install cargo-hack - uses: taiki-e/install-action@cargo-hack - name: Run tests with -Cpanic=abort run: ci/panic-abort.sh From 7c0316a95f87e3848d42f23d018a7126608f3259 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 10 Dec 2024 17:41:55 +0100 Subject: [PATCH 16/16] undo debugging --- ci/panic-abort.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/panic-abort.sh b/ci/panic-abort.sh index 83f4f314a..4284791f1 100755 --- a/ci/panic-abort.sh +++ b/ci/panic-abort.sh @@ -1,4 +1,4 @@ #!/bin/bash set -ex -RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test test_bytes_vec_alloc -- --nocapture +RUSTFLAGS="$RUSTFLAGS -Cpanic=abort -Zpanic-abort-tests" cargo test --all-features --test '*'