test(pool): run C pool tests through the Rust implementation

Link poolTests against the multithreaded object set and Rust static archive,
so its C callbacks exercise the migrated pool rather than compiling a private
C implementation. Preserve ZSTD_MULTITHREAD for the test translation unit;
without it, its pthread test helpers become no-ops while the Rust pool runs
concurrently. Add a Rust regression for draining a small queue after reducing
the worker limit.

Test Plan:
- cargo clippy
- cargo clippy --benches
- cargo clippy --tests
- cargo +nightly fmt
- cargo test shrinking_the_limit_keeps_draining_a_small_queue -- --nocapture
- make -B -C tests poolTests && timeout 20s stdbuf -oL ./tests/poolTests

Refs: Rust pool migration 26b5e202
This commit is contained in:
2026-07-10 22:38:07 +02:00
parent 3d679116d8
commit da617508b9
3 changed files with 44 additions and 2 deletions
+40
View File
@@ -664,6 +664,46 @@ mod tests {
assert_eq!(count.load(Ordering::Relaxed), 16);
}
unsafe extern "C" fn delayed_increment(opaque: *mut c_void) {
thread::sleep(Duration::from_millis(10));
unsafe { increment(opaque) };
}
#[test]
fn shrinking_the_limit_keeps_draining_a_small_queue() {
let ctx = POOL_create(4, 2);
assert!(!ctx.is_null());
let count = AtomicUsize::new(0);
for _ in 0..16 {
unsafe {
POOL_add(
ctx,
delayed_increment,
ptr::from_ref(&count).cast_mut().cast(),
)
};
}
unsafe { POOL_joinJobs(ctx) };
assert_eq!(count.load(Ordering::Relaxed), 16);
assert_eq!(unsafe { POOL_resize(ctx, 2) }, 0);
for _ in 0..16 {
unsafe {
POOL_add(
ctx,
delayed_increment,
ptr::from_ref(&count).cast_mut().cast(),
)
};
}
unsafe {
POOL_joinJobs(ctx);
POOL_free(ctx);
}
assert_eq!(count.load(Ordering::Relaxed), 32);
}
struct AllocStats {
allocations: AtomicUsize,
frees: AtomicUsize,