File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -456,4 +456,30 @@ TEST_P(umfPoolTest, allocMaxSize) {
456456 ASSERT_EQ (ptr, nullptr );
457457}
458458
459+ #if defined(__has_feature)
460+ #if __has_feature(address_sanitizer)
461+ #define __SANITIZE_ADDRESS__
462+ #endif
463+ #endif
464+
465+ #ifndef __SANITIZE_ADDRESS__
466+ // Sanitizer replaces malloc_usable_size implementation with it's own,
467+ // what results in a failure.
468+
469+ TEST_P (umfPoolTest, mallocUsableSize) {
470+ for (size_t allocSize : {32 , 48 , 1024 , 8192 }) {
471+ char *ptr = static_cast <char *>(umfPoolMalloc (pool.get (), allocSize));
472+ size_t result = umfPoolMallocUsableSize (pool.get (), ptr);
473+ EXPECT_TRUE (result == 0 or result >= allocSize);
474+
475+ for (size_t i = 0 ; i < result; i++) {
476+ ptr[i] = 123 ;
477+ }
478+
479+ umfPoolFree (pool.get (), ptr);
480+ }
481+ }
482+
483+ #endif
484+
459485#endif /* UMF_TEST_POOL_FIXTURES_HPP */
You can’t perform that action at this time.
0 commit comments