commit
c2330d95ee
@ -0,0 +1 @@
|
||||
SOURCES/lv2-worker-0.1.1.crate
|
@ -0,0 +1 @@
|
||||
5b38a3c3c2198f7736b7dec820b05f65d42ce415 SOURCES/lv2-worker-0.1.1.crate
|
@ -0,0 +1,3 @@
|
||||
# rust-lv2-worker
|
||||
|
||||
The rust-lv2-worker package
|
@ -0,0 +1,186 @@
|
||||
From 88ba8d3860ee78de617b052086fa9fa5e6fec360 Mon Sep 17 00:00:00 2001
|
||||
From: Hector Martin <marcan@marcan.st>
|
||||
Date: Mon, 14 Oct 2024 01:18:22 +0900
|
||||
Subject: [PATCH] Fix tests on Rust 1.81.0
|
||||
|
||||
Unwinding across functions with the extern "C" ABI is UB, but previously
|
||||
worked. See: https://github.com/rust-lang/rust/issues/74990
|
||||
|
||||
Redo the tests so they don't rely on panics at all, using a
|
||||
reference-counted counter instead.
|
||||
|
||||
Signed-off-by: Hector Martin <marcan@marcan.st>
|
||||
---
|
||||
worker/src/lib.rs | 84 +++++++++++++++--------------------------------
|
||||
1 file changed, 26 insertions(+), 58 deletions(-)
|
||||
|
||||
diff --git a/src/lib.rs b/src/lib.rs
|
||||
index 7b2ef1d3..0895cfc4 100644
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -480,29 +480,23 @@ mod tests {
|
||||
use std::mem;
|
||||
use std::ops;
|
||||
use std::ptr;
|
||||
+ use std::sync::atomic::{AtomicU32, Ordering};
|
||||
+ use std::sync::Arc;
|
||||
|
||||
// structure to test drooping issue
|
||||
struct HasDrop {
|
||||
- drop_count: u32,
|
||||
- drop_limit: u32,
|
||||
+ drop_count: Arc<AtomicU32>,
|
||||
}
|
||||
|
||||
impl HasDrop {
|
||||
- fn new(val: u32) -> Self {
|
||||
- Self {
|
||||
- drop_count: 0,
|
||||
- drop_limit: val,
|
||||
- }
|
||||
+ fn new(val: Arc<AtomicU32>) -> Self {
|
||||
+ Self { drop_count: val }
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Drop for HasDrop {
|
||||
fn drop(&mut self) {
|
||||
- if self.drop_count >= self.drop_limit {
|
||||
- panic!("Dropped more than {} time", self.drop_limit);
|
||||
- } else {
|
||||
- self.drop_count += 1;
|
||||
- }
|
||||
+ self.drop_count.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,7 +582,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn schedule_must_not_drop() {
|
||||
- let hd = HasDrop::new(0);
|
||||
+ let ctr = Arc::new(AtomicU32::new(0));
|
||||
+ let hd = HasDrop::new(ctr.clone());
|
||||
let internal = lv2_sys::LV2_Worker_Schedule {
|
||||
handle: ptr::null_mut(),
|
||||
schedule_work: Some(extern_schedule),
|
||||
@@ -598,12 +593,13 @@ mod tests {
|
||||
phantom: PhantomData::<*const TestDropWorker>,
|
||||
};
|
||||
let _ = schedule.schedule_work(hd);
|
||||
+ assert_eq!(ctr.load(Ordering::Relaxed), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
- #[should_panic(expected = "Dropped")]
|
||||
fn schedule_must_enable_drop_on_error() {
|
||||
- let hd = HasDrop::new(0);
|
||||
+ let ctr = Arc::new(AtomicU32::new(0));
|
||||
+ let hd = HasDrop::new(ctr.clone());
|
||||
let internal = lv2_sys::LV2_Worker_Schedule {
|
||||
handle: ptr::null_mut(),
|
||||
schedule_work: Some(faulty_schedule),
|
||||
@@ -613,35 +609,39 @@ mod tests {
|
||||
phantom: PhantomData::<*const TestDropWorker>,
|
||||
};
|
||||
let _ = schedule.schedule_work(hd);
|
||||
+ assert_eq!(ctr.load(Ordering::Relaxed), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn respond_must_not_drop() {
|
||||
- let hd = HasDrop::new(0);
|
||||
+ let ctr = Arc::new(AtomicU32::new(0));
|
||||
+ let hd = HasDrop::new(ctr.clone());
|
||||
let respond = ResponseHandler {
|
||||
response_function: Some(extern_respond),
|
||||
respond_handle: ptr::null_mut(),
|
||||
phantom: PhantomData::<TestDropWorker>,
|
||||
};
|
||||
let _ = respond.respond(hd);
|
||||
+ assert_eq!(ctr.load(Ordering::Relaxed), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
- #[should_panic(expected = "Dropped")]
|
||||
fn respond_must_enable_drop_on_error() {
|
||||
- let hd = HasDrop::new(0);
|
||||
+ let ctr = Arc::new(AtomicU32::new(0));
|
||||
+ let hd = HasDrop::new(ctr.clone());
|
||||
let respond = ResponseHandler {
|
||||
response_function: Some(faulty_respond),
|
||||
respond_handle: ptr::null_mut(),
|
||||
phantom: PhantomData::<TestDropWorker>,
|
||||
};
|
||||
let _ = respond.respond(hd);
|
||||
+ assert_eq!(ctr.load(Ordering::Relaxed), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
- #[should_panic(expected = "Dropped")]
|
||||
- fn extern_work_should_drop() {
|
||||
- let hd = mem::ManuallyDrop::new(HasDrop::new(0));
|
||||
+ fn extern_work_should_drop_once() {
|
||||
+ let ctr = Arc::new(AtomicU32::new(0));
|
||||
+ let hd = mem::ManuallyDrop::new(HasDrop::new(ctr.clone()));
|
||||
let ptr_hd = &hd as *const _ as *const c_void;
|
||||
let size = mem::size_of_val(&hd) as u32;
|
||||
let mut tdw = TestDropWorker {};
|
||||
@@ -657,46 +657,13 @@ mod tests {
|
||||
ptr_hd,
|
||||
);
|
||||
}
|
||||
+ assert_eq!(ctr.load(Ordering::Relaxed), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
- fn extern_work_should_not_drop_twice() {
|
||||
- let hd = mem::ManuallyDrop::new(HasDrop::new(1));
|
||||
- let ptr_hd = &hd as *const _ as *const c_void;
|
||||
- let size = mem::size_of_val(&hd) as u32;
|
||||
- let mut tdw = TestDropWorker {};
|
||||
-
|
||||
- let ptr_tdw = &mut tdw as *mut _ as *mut c_void;
|
||||
- //trash trick i use Plugin ptr insteas of Pluginstance ptr
|
||||
- unsafe {
|
||||
- WorkerDescriptor::<TestDropWorker>::extern_work(
|
||||
- ptr_tdw,
|
||||
- Some(extern_respond),
|
||||
- ptr::null_mut(),
|
||||
- size,
|
||||
- ptr_hd,
|
||||
- );
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- #[test]
|
||||
- #[should_panic(expected = "Dropped")]
|
||||
- fn extern_work_response_should_drop() {
|
||||
- let hd = mem::ManuallyDrop::new(HasDrop::new(0));
|
||||
- let ptr_hd = &hd as *const _ as *const c_void;
|
||||
- let size = mem::size_of_val(&hd) as u32;
|
||||
- let mut tdw = TestDropWorker {};
|
||||
-
|
||||
- let ptr_tdw = &mut tdw as *mut _ as *mut c_void;
|
||||
- //trash trick i use Plugin ptr insteas of Pluginstance ptr
|
||||
- unsafe {
|
||||
- WorkerDescriptor::<TestDropWorker>::extern_work_response(ptr_tdw, size, ptr_hd);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- #[test]
|
||||
- fn extern_work_response_should_not_drop_twice() {
|
||||
- let hd = mem::ManuallyDrop::new(HasDrop::new(1));
|
||||
+ fn extern_work_response_should_drop_once() {
|
||||
+ let ctr = Arc::new(AtomicU32::new(0));
|
||||
+ let hd = mem::ManuallyDrop::new(HasDrop::new(ctr.clone()));
|
||||
let ptr_hd = &hd as *const _ as *const c_void;
|
||||
let size = mem::size_of_val(&hd) as u32;
|
||||
let mut tdw = TestDropWorker {};
|
||||
@@ -706,5 +673,6 @@ mod tests {
|
||||
unsafe {
|
||||
WorkerDescriptor::<TestDropWorker>::extern_work_response(ptr_tdw, size, ptr_hd);
|
||||
}
|
||||
+ assert_eq!(ctr.load(Ordering::Relaxed), 1);
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
[package]
|
||||
extra-patches = [
|
||||
{ "number" = 2, file = "lv2-worker-fix-tests-rust-1.81.0.patch", comments = ["Fix tests on Rust 1.81.0", "https://github.com/RustAudio/rust-lv2/pull/126"] },
|
||||
]
|
@ -0,0 +1,100 @@
|
||||
## START: Set by rpmautospec
|
||||
## (rpmautospec version 0.7.3)
|
||||
## RPMAUTOSPEC: autorelease, autochangelog
|
||||
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
|
||||
release_number = 4;
|
||||
base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
|
||||
print(release_number + base_release_number - 1);
|
||||
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
|
||||
## END: Set by rpmautospec
|
||||
|
||||
# Generated by rust2rpm 26
|
||||
%bcond_without check
|
||||
%global debug_package %{nil}
|
||||
|
||||
%global crate lv2-worker
|
||||
|
||||
Name: rust-lv2-worker
|
||||
Version: 0.1.1
|
||||
Release: %autorelease
|
||||
Summary: Rust-lv2's work offloading library
|
||||
|
||||
License: MIT OR Apache-2.0
|
||||
URL: https://crates.io/crates/lv2-worker
|
||||
Source: %{crates_source}
|
||||
# * Fix tests on Rust 1.81.0
|
||||
# * https://github.com/RustAudio/rust-lv2/pull/126
|
||||
Patch2: lv2-worker-fix-tests-rust-1.81.0.patch
|
||||
|
||||
BuildRequires: cargo-rpm-macros >= 24
|
||||
|
||||
# Not supported by rust-lv2
|
||||
ExcludeArch: ppc64le s390x
|
||||
|
||||
%global _description %{expand:
|
||||
Rust-lv2's work offloading library.}
|
||||
|
||||
%description %{_description}
|
||||
|
||||
%package devel
|
||||
Summary: %{summary}
|
||||
BuildArch: noarch
|
||||
|
||||
%description devel %{_description}
|
||||
|
||||
This package contains library source intended for building other packages which
|
||||
use the "%{crate}" crate.
|
||||
|
||||
%files devel
|
||||
%license %{crate_instdir}/LICENSE-APACHE
|
||||
%license %{crate_instdir}/LICENSE-MIT
|
||||
%doc %{crate_instdir}/README.md
|
||||
%{crate_instdir}/
|
||||
|
||||
%package -n %{name}+default-devel
|
||||
Summary: %{summary}
|
||||
BuildArch: noarch
|
||||
|
||||
%description -n %{name}+default-devel %{_description}
|
||||
|
||||
This package contains library source intended for building other packages which
|
||||
use the "default" feature of the "%{crate}" crate.
|
||||
|
||||
%files -n %{name}+default-devel
|
||||
%ghost %{crate_instdir}/Cargo.toml
|
||||
|
||||
%prep
|
||||
%autosetup -n %{crate}-%{version} -p1
|
||||
%cargo_prep
|
||||
|
||||
%generate_buildrequires
|
||||
%cargo_generate_buildrequires
|
||||
|
||||
%build
|
||||
%cargo_build
|
||||
|
||||
%install
|
||||
%cargo_install
|
||||
|
||||
%if %{with check}
|
||||
%check
|
||||
%cargo_test
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Dec 20 2024 MSVSphere Packaging Team <packager@msvsphere-os.ru> - 0.1.1-4
|
||||
- Rebuilt for MSVSphere 10
|
||||
|
||||
## START: Generated by rpmautospec
|
||||
* Sun Oct 13 2024 Davide Cavalca <dcavalca@fedoraproject.org> - 0.1.1-4
|
||||
- Fix tests on Rust 1.81.0; Fixes: RHBZ#2314195
|
||||
|
||||
* Sat Jul 20 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.1-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
|
||||
|
||||
* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.1-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||
|
||||
* Sun Jul 23 2023 Davide Cavalca <dcavalca@fedoraproject.org> - 0.1.1-1
|
||||
- Initial import; Fixes: RHBZ#2224771
|
||||
## END: Generated by rpmautospec
|
Loading…
Reference in new issue