Merge "Small test fixes."

This commit is contained in:
Christopher Ferris 2017-05-06 06:30:40 +00:00 committed by Gerrit Code Review
commit 9a4f572a95
2 changed files with 8 additions and 6 deletions

View File

@ -74,7 +74,7 @@ TEST_F(DisableMallocTest, deadlock_new) {
{
alarm(100ms);
ScopedDisableMalloc disable_malloc;
char* ptr = new(char);
char* ptr = new (std::nothrow)(char);
ASSERT_NE(ptr, nullptr);
delete(ptr);
}
@ -89,6 +89,8 @@ TEST_F(DisableMallocTest, deadlock_delete) {
alarm(250ms);
ScopedDisableMalloc disable_malloc;
delete(ptr);
// Force ptr usage or this code gets optimized away by the arm64 compiler.
ASSERT_NE(ptr, nullptr);
}
}, "");
}

View File

@ -23,8 +23,6 @@
#include <memunreachable/memunreachable.h>
void* ptr;
class HiddenPointer {
public:
explicit HiddenPointer(size_t size = 256) {
@ -92,10 +90,12 @@ TEST(MemunreachableTest, stack) {
}
}
void* g_ptr;
TEST(MemunreachableTest, global) {
HiddenPointer hidden_ptr;
ptr = hidden_ptr.Get();
g_ptr = hidden_ptr.Get();
{
UnreachableMemoryInfo info;
@ -104,7 +104,7 @@ TEST(MemunreachableTest, global) {
ASSERT_EQ(0U, info.leaks.size());
}
ptr = NULL;
g_ptr = nullptr;
{
UnreachableMemoryInfo info;
@ -126,7 +126,7 @@ TEST(MemunreachableTest, global) {
TEST(MemunreachableTest, tls) {
HiddenPointer hidden_ptr;
pthread_key_t key;
pthread_key_create(&key, NULL);
pthread_key_create(&key, nullptr);
pthread_setspecific(key, hidden_ptr.Get());