@@ -166,9 +166,10 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic_provider) {
166166
167167TEST_P (CoarseWithMemoryStrategyTest, coarseTest_basic_fixed_memory) {
168168 // preallocate some memory and initialize the vector with zeros
169- const size_t buff_size = 20 * MB;
169+ const size_t buff_size = 20 * MB + coarse_params. page_size ;
170170 std::vector<char > buffer (buff_size, 0 );
171- void *buf = (void *)buffer.data ();
171+ void *buf = (void *)ALIGN_UP_SAFE ((uintptr_t )buffer.data (),
172+ coarse_params.page_size );
172173 ASSERT_NE (buf, nullptr );
173174
174175 coarse_params.cb .alloc = NULL ;
@@ -206,9 +207,10 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic_fixed_memory) {
206207
207208TEST_P (CoarseWithMemoryStrategyTest, coarseTest_fixed_memory_various) {
208209 // preallocate some memory and initialize the vector with zeros
209- const size_t buff_size = 20 * MB;
210+ const size_t buff_size = 20 * MB + coarse_params. page_size ;
210211 std::vector<char > buffer (buff_size, 0 );
211- void *buf = (void *)buffer.data ();
212+ void *buf = (void *)ALIGN_UP_SAFE ((uintptr_t )buffer.data (),
213+ coarse_params.page_size );
212214 ASSERT_NE (buf, nullptr );
213215
214216 coarse_params.cb .alloc = NULL ;
@@ -627,6 +629,15 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic_free_cb_fails) {
627629}
628630
629631TEST_P (CoarseWithMemoryStrategyTest, coarseTest_split_cb_fails) {
632+ if (coarse_params.allocation_strategy ==
633+ UMF_COARSE_MEMORY_STRATEGY_FASTEST) {
634+ // This test is designed for the UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE
635+ // and UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE strategies,
636+ // because the UMF_COARSE_MEMORY_STRATEGY_FASTEST strategy
637+ // looks always for a block of size greater by the page size.
638+ return ;
639+ }
640+
630641 umf_memory_provider_handle_t malloc_memory_provider;
631642 umf_result = umfMemoryProviderCreate (&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL ,
632643 &malloc_memory_provider);
@@ -702,9 +713,10 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_split_cb_fails) {
702713
703714TEST_P (CoarseWithMemoryStrategyTest, coarseTest_merge_cb_fails) {
704715 // preallocate some memory and initialize the vector with zeros
705- const size_t buff_size = 10 * MB;
716+ const size_t buff_size = 10 * MB + coarse_params. page_size ;
706717 std::vector<char > buffer (buff_size, 0 );
707- void *buf = (void *)buffer.data ();
718+ void *buf = (void *)ALIGN_UP_SAFE ((uintptr_t )buffer.data (),
719+ coarse_params.page_size );
708720 ASSERT_NE (buf, nullptr );
709721
710722 coarse_params.cb .alloc = NULL ;
@@ -901,6 +913,15 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_provider_alloc_not_set) {
901913}
902914
903915TEST_P (CoarseWithMemoryStrategyTest, coarseTest_basic) {
916+ if (coarse_params.allocation_strategy ==
917+ UMF_COARSE_MEMORY_STRATEGY_FASTEST) {
918+ // This test is designed for the UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE
919+ // and UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE strategies,
920+ // because the UMF_COARSE_MEMORY_STRATEGY_FASTEST strategy
921+ // looks always for a block of size greater by the page size.
922+ return ;
923+ }
924+
904925 umf_memory_provider_handle_t malloc_memory_provider;
905926 umf_result = umfMemoryProviderCreate (&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL ,
906927 &malloc_memory_provider);
@@ -1065,6 +1086,15 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic) {
10651086}
10661087
10671088TEST_P (CoarseWithMemoryStrategyTest, coarseTest_simple1) {
1089+ if (coarse_params.allocation_strategy ==
1090+ UMF_COARSE_MEMORY_STRATEGY_FASTEST) {
1091+ // This test is designed for the UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE
1092+ // and UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE strategies,
1093+ // because the UMF_COARSE_MEMORY_STRATEGY_FASTEST strategy
1094+ // looks always for a block of size greater by the page size.
1095+ return ;
1096+ }
1097+
10681098 umf_memory_provider_handle_t malloc_memory_provider;
10691099 umf_result = umfMemoryProviderCreate (&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL ,
10701100 &malloc_memory_provider);
@@ -1106,8 +1136,9 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_simple1) {
11061136 ASSERT_NE (t[i], nullptr );
11071137 }
11081138
1109- if (max_alloc_size == 0 ) {
1110- max_alloc_size = coarse_get_stats (ch).alloc_size ;
1139+ size_t alloc_size = coarse_get_stats (ch).alloc_size ;
1140+ if (alloc_size > max_alloc_size) {
1141+ max_alloc_size = alloc_size;
11111142 }
11121143
11131144 for (int i = 0 ; i < nptrs; i++) {
@@ -1253,9 +1284,10 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_alignment_provider) {
12531284
12541285TEST_P (CoarseWithMemoryStrategyTest, coarseTest_alignment_fixed_memory) {
12551286 // preallocate some memory and initialize the vector with zeros
1256- const size_t alloc_size = 40 * MB;
1287+ const size_t alloc_size = 40 * MB + coarse_params. page_size ;
12571288 std::vector<char > buffer (alloc_size, 0 );
1258- void *buf = (void *)buffer.data ();
1289+ void *buf = (void *)ALIGN_UP_SAFE ((uintptr_t )buffer.data (),
1290+ coarse_params.page_size );
12591291 ASSERT_NE (buf, nullptr );
12601292
12611293 coarse_params.cb .alloc = NULL ;
0 commit comments