@@ -356,6 +356,65 @@ TEST_F(test, disjointPoolName) {
356356 umfDisjointPoolParamsDestroy (params);
357357}
358358
359+ TEST_F (test, disjointPoolDefaultParams) {
360+ umf_disjoint_pool_params_handle_t params = nullptr ;
361+ umf_memory_pool_handle_t pool = nullptr ;
362+ umf_memory_provider_handle_t provider_handle = nullptr ;
363+
364+ // Create disjoint pool parameters with default settings
365+ umf_result_t res = umfDisjointPoolParamsCreate (¶ms);
366+ EXPECT_EQ (res, UMF_RESULT_SUCCESS);
367+
368+ static int free_counter = 0 ;
369+ struct memory_provider : public umf_test ::provider_base_t {
370+ umf_result_t alloc (size_t size, size_t alignment, void **ptr) noexcept {
371+ printf (" Allocating %zu bytes with alignment %zu\n " , size,
372+ alignment);
373+ *ptr = umf_ba_global_aligned_alloc (size, alignment);
374+ return UMF_RESULT_SUCCESS;
375+ }
376+
377+ umf_result_t free (void *ptr, [[maybe_unused]] size_t size) noexcept {
378+ // do the actual free only when we expect the success
379+ printf (" Freeing memory at %p\n " , ptr);
380+ umf_ba_global_free (ptr);
381+ free_counter++;
382+ return UMF_RESULT_SUCCESS;
383+ }
384+ };
385+
386+ umf_memory_provider_ops_t provider_ops =
387+ umf_test::providerMakeCOps<memory_provider, void >();
388+
389+ auto providerUnique =
390+ wrapProviderUnique (createProviderChecked (&provider_ops, nullptr ));
391+ provider_handle = providerUnique.get ();
392+
393+ umf_result_t ret = umfPoolCreate (umfDisjointPoolOps (), provider_handle,
394+ params, UMF_POOL_CREATE_FLAG_NONE, &pool);
395+ ASSERT_EQ (ret, UMF_RESULT_SUCCESS);
396+
397+ // Test allocation and deallocation
398+ // This will use the default disjoint pool parameters
399+ void *ptr = umfPoolMalloc (pool, 64 );
400+ ASSERT_NE (ptr, nullptr );
401+ ret = umfPoolFree (pool, ptr);
402+ ASSERT_EQ (ret, UMF_RESULT_SUCCESS);
403+ ASSERT_EQ (free_counter, 0 );
404+
405+ // Test allocation and deallocation with a different size
406+ ptr = umfPoolMalloc (pool, 4 * 1024 * 1024 );
407+ ASSERT_NE (ptr, nullptr );
408+ ret = umfPoolFree (pool, ptr);
409+ ASSERT_EQ (ret, UMF_RESULT_SUCCESS);
410+ ASSERT_EQ (free_counter, 1 );
411+
412+ // Cleaning up
413+ umfPoolDestroy (pool);
414+ umfDisjointPoolParamsDestroy (params);
415+ ASSERT_EQ (free_counter, 2 );
416+ }
417+
359418INSTANTIATE_TEST_SUITE_P (disjointPoolTests, umfPoolTest,
360419 ::testing::Values (poolCreateExtParams{
361420 umfDisjointPoolOps (), defaultDisjointPoolConfig,
0 commit comments