mirror of
https://github.com/gperftools/gperftools
synced 2024-12-22 07:20:01 +00:00
gtestify current_allocated_bytes_test
This commit is contained in:
parent
f9e6c517b8
commit
37b59a206e
@ -428,7 +428,8 @@ markidle_unittest_LDADD = libtcmalloc_minimal.la libgtest.la
|
||||
TESTS += current_allocated_bytes_test
|
||||
current_allocated_bytes_test_SOURCES = src/tests/current_allocated_bytes_test.cc
|
||||
current_allocated_bytes_test_LDFLAGS = $(TCMALLOC_FLAGS) $(AM_LDFLAGS)
|
||||
current_allocated_bytes_test_LDADD = libtcmalloc_minimal.la
|
||||
current_allocated_bytes_test_CPPFLAGS = $(gtest_CPPFLAGS)
|
||||
current_allocated_bytes_test_LDADD = libtcmalloc_minimal.la libgtest.la
|
||||
|
||||
TESTS += malloc_extension_test
|
||||
malloc_extension_test_SOURCES = src/tests/malloc_extension_test.cc
|
||||
|
@ -41,24 +41,18 @@
|
||||
// bytes properly.
|
||||
|
||||
#include "config_for_unittests.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <gperftools/malloc_extension.h>
|
||||
#include "base/logging.h"
|
||||
|
||||
int main() {
|
||||
// We don't do accounting right when using debugallocation.cc, so
|
||||
// turn off the test then. TODO(csilvers): get this working too.
|
||||
#ifdef NDEBUG
|
||||
static const char kCurrent[] = "generic.current_allocated_bytes";
|
||||
#include <gperftools/malloc_extension.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(CurrentAllocatedBytes, Basic) {
|
||||
static constexpr char kCurrent[] = "generic.current_allocated_bytes";
|
||||
|
||||
size_t before_bytes, after_bytes;
|
||||
MallocExtension::instance()->GetNumericProperty(kCurrent, &before_bytes);
|
||||
free(malloc(200));
|
||||
MallocExtension::instance()->GetNumericProperty(kCurrent, &after_bytes);
|
||||
ASSERT_TRUE(MallocExtension::instance()->GetNumericProperty(kCurrent, &before_bytes));
|
||||
(::operator delete)((::operator new)(200));
|
||||
ASSERT_TRUE(MallocExtension::instance()->GetNumericProperty(kCurrent, &after_bytes));
|
||||
|
||||
CHECK_EQ(before_bytes, after_bytes);
|
||||
#endif
|
||||
printf("PASS\n");
|
||||
return 0;
|
||||
ASSERT_EQ(before_bytes, after_bytes);
|
||||
}
|
||||
|
@ -215,6 +215,9 @@
|
||||
<Project>{55e2b3ae-3ca1-4db6-97f7-0a044d6f446f}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\gtest\gtest.vcxproj">
|
||||
<Project>{0496df42-d7ad-46b6-b10c-c57a07e89b0d}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
Loading…
Reference in New Issue
Block a user