From 6c4d2cbc7990f909aef7274f7ba9d2151b354369 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 13 Aug 2023 22:23:53 -0400 Subject: [PATCH] test for proper resource handling in Pool.shutdown --- test/dune | 2 +- test/t_resource.ml | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/t_resource.ml diff --git a/test/dune b/test/dune index 50a73317..a843ee36 100644 --- a/test/dune +++ b/test/dune @@ -1,5 +1,5 @@ (tests - (names t_fib t_bench1 t_fib_rec t_futs1 t_tree_futs t_props t_chan_train) + (names t_fib t_bench1 t_fib_rec t_futs1 t_tree_futs t_props t_chan_train t_resource) (libraries moonpool qcheck-core qcheck-core.runner ;tracy-client.trace trace)) diff --git a/test/t_resource.ml b/test/t_resource.ml new file mode 100644 index 00000000..2cdd7728 --- /dev/null +++ b/test/t_resource.ml @@ -0,0 +1,13 @@ +open! Moonpool + +let ( let@ ) = ( @@ ) + +(* test proper resource handling *) +let () = + let a = Atomic.make 0 in + for _i = 1 to 1_000 do + (* allocate a new pool at each iteration *) + let@ p = Pool.with_ ~min:4 () in + Pool.run_wait_block p (fun () -> Atomic.incr a) + done; + assert (Atomic.get a = 1_000)