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

Side by Side Diff: base/security_unittest.cc

Issue 603793003: Disable SecurityTest.NewOverflow as it fails on 10.8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <fcntl.h> 5 #include <fcntl.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 TEST(SecurityTest, TCMALLOC_TEST(MemoryAllocationRestrictionsNewArray)) { 142 TEST(SecurityTest, TCMALLOC_TEST(MemoryAllocationRestrictionsNewArray)) {
143 if (!IsTcMallocBypassed()) { 143 if (!IsTcMallocBypassed()) {
144 scoped_ptr<char[]> ptr( 144 scoped_ptr<char[]> ptr(
145 HideValueFromCompiler(new (nothrow) char[kTooBigAllocSize])); 145 HideValueFromCompiler(new (nothrow) char[kTooBigAllocSize]));
146 ASSERT_TRUE(!ptr); 146 ASSERT_TRUE(!ptr);
147 } 147 }
148 } 148 }
149 149
150 // The tests bellow check for overflows in new[] and calloc(). 150 // The tests bellow check for overflows in new[] and calloc().
151 151
152 #if defined(OS_IOS) || defined(OS_WIN) || defined(THREAD_SANITIZER)
153 #define DISABLE_ON_IOS_AND_WIN_AND_TSAN(function) DISABLED_##function
154 #else
155 #define DISABLE_ON_IOS_AND_WIN_AND_TSAN(function) function
156 #endif
157
158 // There are platforms where these tests are known to fail. We would like to 152 // There are platforms where these tests are known to fail. We would like to
159 // be able to easily check the status on the bots, but marking tests as 153 // be able to easily check the status on the bots, but marking tests as
160 // FAILS_ is too clunky. 154 // FAILS_ is too clunky.
161 void OverflowTestsSoftExpectTrue(bool overflow_detected) { 155 void OverflowTestsSoftExpectTrue(bool overflow_detected) {
162 if (!overflow_detected) { 156 if (!overflow_detected) {
163 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_MACOSX) 157 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_MACOSX)
164 // Sadly, on Linux, Android, and OSX we don't have a good story yet. Don't 158 // Sadly, on Linux, Android, and OSX we don't have a good story yet. Don't
165 // fail the test, but report. 159 // fail the test, but report.
166 printf("Platform has overflow: %s\n", 160 printf("Platform has overflow: %s\n",
167 !overflow_detected ? "yes." : "no."); 161 !overflow_detected ? "yes." : "no.");
168 #else 162 #else
169 // Otherwise, fail the test. (Note: EXPECT are ok in subfunctions, ASSERT 163 // Otherwise, fail the test. (Note: EXPECT are ok in subfunctions, ASSERT
170 // aren't). 164 // aren't).
171 EXPECT_TRUE(overflow_detected); 165 EXPECT_TRUE(overflow_detected);
172 #endif 166 #endif
173 } 167 }
174 } 168 }
175 169
170 #if defined(OS_IOS) || defined(OS_WIN) || defined(THREAD_SANITIZER) || defined(O S_MACOSX)
171 #define MAYBE_NewOverflow DISABLED_NewOverflow
172 #else
173 #define MAYBE_NewOverflow NewOverflow
174 #endif
176 // Test array[TooBig][X] and array[X][TooBig] allocations for int overflows. 175 // Test array[TooBig][X] and array[X][TooBig] allocations for int overflows.
177 // IOS doesn't honor nothrow, so disable the test there. 176 // IOS doesn't honor nothrow, so disable the test there.
178 // Crashes on Windows Dbg builds, disable there as well. 177 // Crashes on Windows Dbg builds, disable there as well.
179 TEST(SecurityTest, DISABLE_ON_IOS_AND_WIN_AND_TSAN(NewOverflow)) { 178 // Fails on Mac 10.8 http://crbug.com/227092
179 TEST(SecurityTest, MAYBE_NewOverflow) {
180 const size_t kArraySize = 4096; 180 const size_t kArraySize = 4096;
181 // We want something "dynamic" here, so that the compiler doesn't 181 // We want something "dynamic" here, so that the compiler doesn't
182 // immediately reject crazy arrays. 182 // immediately reject crazy arrays.
183 const size_t kDynamicArraySize = HideValueFromCompiler(kArraySize); 183 const size_t kDynamicArraySize = HideValueFromCompiler(kArraySize);
184 // numeric_limits are still not constexpr until we switch to C++11, so we 184 // numeric_limits are still not constexpr until we switch to C++11, so we
185 // use an ugly cast. 185 // use an ugly cast.
186 const size_t kMaxSizeT = ~static_cast<size_t>(0); 186 const size_t kMaxSizeT = ~static_cast<size_t>(0);
187 ASSERT_EQ(numeric_limits<size_t>::max(), kMaxSizeT); 187 ASSERT_EQ(numeric_limits<size_t>::max(), kMaxSizeT);
188 const size_t kArraySize2 = kMaxSizeT / kArraySize + 10; 188 const size_t kArraySize2 = kMaxSizeT / kArraySize + 10;
189 const size_t kDynamicArraySize2 = HideValueFromCompiler(kArraySize2); 189 const size_t kDynamicArraySize2 = HideValueFromCompiler(kArraySize2);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // kRandomMask, so we use it as an additional detection mechanism. 283 // kRandomMask, so we use it as an additional detection mechanism.
284 const uintptr_t kRandomMask = 0x3fffffffffffULL; 284 const uintptr_t kRandomMask = 0x3fffffffffffULL;
285 bool impossible_random_address = 285 bool impossible_random_address =
286 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask; 286 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask;
287 EXPECT_FALSE(impossible_random_address); 287 EXPECT_FALSE(impossible_random_address);
288 } 288 }
289 289
290 #endif // defined(OS_LINUX) && defined(__x86_64__) 290 #endif // defined(OS_LINUX) && defined(__x86_64__)
291 291
292 } // namespace 292 } // namespace
OLDNEW
« 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