| 35 | #if !defined(DM_SANITIZE_ADDRESS) // until we can load the dylibs properly |
| 36 | |
| 37 | TEST(dmMemProfile, TestMalloc) |
| 38 | { |
| 39 | // We assume that the memory (actual size) allocated is 1024 <= x <= 1024 + sizeof(size_t) |
| 40 | // This is by inspection... |
| 41 | |
| 42 | dmMemProfile::Stats stats1, stats2, stats3; |
| 43 | dmMemProfile::GetStats(&stats1); |
| 44 | void* p = malloc(1024); |
| 45 | g_dont_optimize = p; |
| 46 | dmMemProfile::GetStats(&stats2); |
| 47 | |
| 48 | if (g_MemprofileActive) |
| 49 | { |
| 50 | ASSERT_EQ(1, stats2.m_AllocationCount - stats1.m_AllocationCount); |
| 51 | ASSERT_GE(stats2.m_TotalActive - stats1.m_TotalActive, 1024); |
| 52 | ASSERT_LE(stats2.m_TotalActive - stats1.m_TotalActive, 1024 + sizeof(size_t)); |
| 53 | ASSERT_GE(stats2.m_TotalAllocated - stats1.m_TotalAllocated, 1024); |
| 54 | ASSERT_LE(stats2.m_TotalAllocated - stats1.m_TotalAllocated, 1024 + sizeof(size_t)); |
| 55 | } |
| 56 | |
| 57 | free(p); |
| 58 | dmMemProfile::GetStats(&stats3); |
| 59 | |
| 60 | if (g_MemprofileActive) |
| 61 | { |
| 62 | ASSERT_EQ(1, stats3.m_AllocationCount - stats1.m_AllocationCount); |
| 63 | ASSERT_EQ(0, stats3.m_TotalActive - stats1.m_TotalActive); |
| 64 | ASSERT_GE(stats3.m_TotalAllocated - stats1.m_TotalAllocated, 1024); |
| 65 | ASSERT_LE(stats3.m_TotalAllocated - stats1.m_TotalAllocated, 1024 + sizeof(size_t)); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | TEST(dmMemProfile, TestCalloc) |
| 70 | { |
nothing calls this directly
no test coverage detected