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

Side by Side Diff: base/tools_sanity_unittest.cc

Issue 614103004: replace 'virtual ... OVERRIDE' with '... override' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: process base/ 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file contains intentional memory errors, some of which may lead to 5 // This file contains intentional memory errors, some of which may lead to
6 // crashes if the test is ran without special memory testing tools. We use these 6 // crashes if the test is ran without special memory testing tools. We use these
7 // errors to verify the sanity of the tools. 7 // errors to verify the sanity of the tools.
8 8
9 #include "base/atomicops.h" 9 #include "base/atomicops.h"
10 #include "base/debug/asan_invalid_access.h" 10 #include "base/debug/asan_invalid_access.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 #endif // ADDRESS_SANITIZER || SYZYASAN 232 #endif // ADDRESS_SANITIZER || SYZYASAN
233 233
234 namespace { 234 namespace {
235 235
236 // We use caps here just to ensure that the method name doesn't interfere with 236 // We use caps here just to ensure that the method name doesn't interfere with
237 // the wildcarded suppressions. 237 // the wildcarded suppressions.
238 class TOOLS_SANITY_TEST_CONCURRENT_THREAD : public PlatformThread::Delegate { 238 class TOOLS_SANITY_TEST_CONCURRENT_THREAD : public PlatformThread::Delegate {
239 public: 239 public:
240 explicit TOOLS_SANITY_TEST_CONCURRENT_THREAD(bool *value) : value_(value) {} 240 explicit TOOLS_SANITY_TEST_CONCURRENT_THREAD(bool *value) : value_(value) {}
241 virtual ~TOOLS_SANITY_TEST_CONCURRENT_THREAD() {} 241 virtual ~TOOLS_SANITY_TEST_CONCURRENT_THREAD() {}
242 virtual void ThreadMain() OVERRIDE { 242 void ThreadMain() override {
243 *value_ = true; 243 *value_ = true;
244 244
245 // Sleep for a few milliseconds so the two threads are more likely to live 245 // Sleep for a few milliseconds so the two threads are more likely to live
246 // simultaneously. Otherwise we may miss the report due to mutex 246 // simultaneously. Otherwise we may miss the report due to mutex
247 // lock/unlock's inside thread creation code in pure-happens-before mode... 247 // lock/unlock's inside thread creation code in pure-happens-before mode...
248 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); 248 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
249 } 249 }
250 private: 250 private:
251 bool *value_; 251 bool *value_;
252 }; 252 };
253 253
254 class ReleaseStoreThread : public PlatformThread::Delegate { 254 class ReleaseStoreThread : public PlatformThread::Delegate {
255 public: 255 public:
256 explicit ReleaseStoreThread(base::subtle::Atomic32 *value) : value_(value) {} 256 explicit ReleaseStoreThread(base::subtle::Atomic32 *value) : value_(value) {}
257 virtual ~ReleaseStoreThread() {} 257 virtual ~ReleaseStoreThread() {}
258 virtual void ThreadMain() OVERRIDE { 258 void ThreadMain() override {
259 base::subtle::Release_Store(value_, kMagicValue); 259 base::subtle::Release_Store(value_, kMagicValue);
260 260
261 // Sleep for a few milliseconds so the two threads are more likely to live 261 // Sleep for a few milliseconds so the two threads are more likely to live
262 // simultaneously. Otherwise we may miss the report due to mutex 262 // simultaneously. Otherwise we may miss the report due to mutex
263 // lock/unlock's inside thread creation code in pure-happens-before mode... 263 // lock/unlock's inside thread creation code in pure-happens-before mode...
264 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); 264 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
265 } 265 }
266 private: 266 private:
267 base::subtle::Atomic32 *value_; 267 base::subtle::Atomic32 *value_;
268 }; 268 };
269 269
270 class AcquireLoadThread : public PlatformThread::Delegate { 270 class AcquireLoadThread : public PlatformThread::Delegate {
271 public: 271 public:
272 explicit AcquireLoadThread(base::subtle::Atomic32 *value) : value_(value) {} 272 explicit AcquireLoadThread(base::subtle::Atomic32 *value) : value_(value) {}
273 virtual ~AcquireLoadThread() {} 273 virtual ~AcquireLoadThread() {}
274 virtual void ThreadMain() OVERRIDE { 274 void ThreadMain() override {
275 // Wait for the other thread to make Release_Store 275 // Wait for the other thread to make Release_Store
276 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100)); 276 PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
277 base::subtle::Acquire_Load(value_); 277 base::subtle::Acquire_Load(value_);
278 } 278 }
279 private: 279 private:
280 base::subtle::Atomic32 *value_; 280 base::subtle::Atomic32 *value_;
281 }; 281 };
282 282
283 void RunInParallel(PlatformThread::Delegate *d1, PlatformThread::Delegate *d2) { 283 void RunInParallel(PlatformThread::Delegate *d1, PlatformThread::Delegate *d2) {
284 PlatformThreadHandle a; 284 PlatformThreadHandle a;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 TEST(ToolsSanityTest, AtomicsAreIgnored) { 322 TEST(ToolsSanityTest, AtomicsAreIgnored) {
323 base::subtle::Atomic32 shared = 0; 323 base::subtle::Atomic32 shared = 0;
324 ReleaseStoreThread thread1(&shared); 324 ReleaseStoreThread thread1(&shared);
325 AcquireLoadThread thread2(&shared); 325 AcquireLoadThread thread2(&shared);
326 RunInParallel(&thread1, &thread2); 326 RunInParallel(&thread1, &thread2);
327 EXPECT_EQ(kMagicValue, shared); 327 EXPECT_EQ(kMagicValue, shared);
328 } 328 }
329 329
330 } // namespace base 330 } // namespace base
OLDNEW
« base/i18n/rtl.cc ('K') | « base/timer/mock_timer.h ('k') | base/values.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698