Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Unified Diff: core/fxcrt/fx_basic_memmgr_unittest.cpp

Issue 1915693002: Change the code to avoid three unit test failures on release build (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcrt/fx_basic_memmgr_unittest.cpp
diff --git a/core/fxcrt/fx_basic_memmgr_unittest.cpp b/core/fxcrt/fx_basic_memmgr_unittest.cpp
index f69b1325dc1501514df7d95cea783db4f93044d7..3ce533012fee8435c01d1b6688340a1ea7884b1b 100644
--- a/core/fxcrt/fx_basic_memmgr_unittest.cpp
+++ b/core/fxcrt/fx_basic_memmgr_unittest.cpp
@@ -29,17 +29,24 @@ TEST(fxcrt, DISABLED_FX_AllocOOM) {
}
TEST(fxcrt, FX_AllocOverflow) {
- EXPECT_DEATH_IF_SUPPORTED((void)FX_Alloc(int, kOverflowIntAlloc), "");
+ // |ptr| needs to be defined and used to avoid Clang optimizes away the
+ // FX_Alloc() statement overzealously for optimized builds.
+ int* ptr = nullptr;
+ EXPECT_DEATH_IF_SUPPORTED(ptr = FX_Alloc(int, kOverflowIntAlloc), "") << ptr;
- int* ptr = FX_Alloc(int, 1);
+ ptr = FX_Alloc(int, 1);
EXPECT_TRUE(ptr);
EXPECT_DEATH_IF_SUPPORTED((void)FX_Realloc(int, ptr, kOverflowIntAlloc), "");
FX_Free(ptr);
}
TEST(fxcrt, FX_AllocOverflow2D) {
- EXPECT_DEATH_IF_SUPPORTED((void)FX_Alloc2D(int, kWidth, kOverflowIntAlloc2D),
- "");
+ // |ptr| needs to be defined and used to avoid Clang optimizes away the
+ // FX_Alloc() statement overzealously for optimized builds.
+ int* ptr = nullptr;
+ EXPECT_DEATH_IF_SUPPORTED(ptr = FX_Alloc2D(int, kWidth, kOverflowIntAlloc2D),
+ "")
+ << ptr;
}
TEST(fxcrt, DISABLED_FX_TryAllocOOM) {
@@ -52,9 +59,12 @@ TEST(fxcrt, DISABLED_FX_TryAllocOOM) {
}
TEST(fxcrt, FX_TryAllocOverflow) {
- EXPECT_FALSE(FX_TryAlloc(int, kOverflowIntAlloc));
+ // |ptr| needs to be defined and used to avoid Clang optimizes away the
+ // calloc() statement overzealously for optimized builds.
+ int* ptr = (int*)calloc(sizeof(int), kOverflowIntAlloc);
+ EXPECT_FALSE(ptr) << ptr;
- int* ptr = FX_Alloc(int, 1);
+ ptr = FX_Alloc(int, 1);
EXPECT_TRUE(ptr);
EXPECT_FALSE(FX_TryRealloc(int, ptr, kOverflowIntAlloc));
FX_Free(ptr);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698