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

Side by Side Diff: base/allocator/allocator_shim_unittest.cc

Issue 1974723002: [Chromecast] Add metric reporting to ConnectivityCheckerImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Initial PS Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/allocator/allocator_shim.h" 5 #include "base/allocator/allocator_shim.h"
6 6
7 #include <malloc.h> 7 #include <malloc.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 uint64_t ignored; 151 uint64_t ignored;
152 uint8_t ignored_3; 152 uint8_t ignored_3;
153 }; 153 };
154 154
155 class ThreadDelegateForNewHandlerTest : public PlatformThread::Delegate { 155 class ThreadDelegateForNewHandlerTest : public PlatformThread::Delegate {
156 public: 156 public:
157 ThreadDelegateForNewHandlerTest(WaitableEvent* event) : event_(event) {} 157 ThreadDelegateForNewHandlerTest(WaitableEvent* event) : event_(event) {}
158 158
159 void ThreadMain() override { 159 void ThreadMain() override {
160 event_->Wait(); 160 event_->Wait();
161 void* res = realloc(reinterpret_cast<void*>(0x42ul), 1); 161
162 // volatile to ensure the compiler doesn't optimize away the equality check
163 void* volatile res = realloc(reinterpret_cast<void*>(0x42ul), 1);
162 EXPECT_EQ(0x42u, reinterpret_cast<uintptr_t>(res)); 164 EXPECT_EQ(0x42u, reinterpret_cast<uintptr_t>(res));
163 } 165 }
164 166
165 private: 167 private:
166 WaitableEvent* event_; 168 WaitableEvent* event_;
167 }; 169 };
168 170
169 AllocatorShimTest* AllocatorShimTest::instance_ = nullptr; 171 AllocatorShimTest* AllocatorShimTest::instance_ = nullptr;
170 172
171 AllocatorDispatch g_mock_dispatch = { 173 AllocatorDispatch g_mock_dispatch = {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 event.Signal(); 317 event.Signal();
316 for (int i = 0; i < kNumThreads; ++i) 318 for (int i = 0; i < kNumThreads; ++i)
317 PlatformThread::Join(threads[i]); 319 PlatformThread::Join(threads[i]);
318 RemoveAllocatorDispatchForTesting(&g_mock_dispatch); 320 RemoveAllocatorDispatchForTesting(&g_mock_dispatch);
319 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls()); 321 ASSERT_EQ(kNumThreads, GetNumberOfNewHandlerCalls());
320 } 322 }
321 323
322 } // namespace 324 } // namespace
323 } // namespace allocator 325 } // namespace allocator
324 } // namespace base 326 } // namespace base
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