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

Side by Side Diff: base/profiler/stack_sampling_profiler_unittest.cc

Issue 1346453004: NativeStackSampler implementation for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « base/profiler/native_stack_sampler_mac.cc ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdlib.h>
Mike Wittman 2015/09/15 21:21:02 we no longer need this
sydli 2015/09/15 21:49:43 Done.
6
5 #include "base/bind.h" 7 #include "base/bind.h"
6 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/files/file_util.h"
7 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
8 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 12 #include "base/path_service.h"
10 #include "base/profiler/stack_sampling_profiler.h" 13 #include "base/profiler/stack_sampling_profiler.h"
11 #include "base/run_loop.h" 14 #include "base/run_loop.h"
12 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
13 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
14 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
15 #include "base/time/time.h" 18 #include "base/time/time.h"
16 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
17 20
18 // STACK_SAMPLING_PROFILER_SUPPORTED is used to conditionally enable the tests 21 // STACK_SAMPLING_PROFILER_SUPPORTED is used to conditionally enable the tests
19 // below for supported platforms (currently Win x64). 22 // below for supported platforms (currently Win x64 and Mac).
20 #if defined(_WIN64) 23 #if defined(_WIN64) || defined(OS_MACOSX)
21 #define STACK_SAMPLING_PROFILER_SUPPORTED 1 24 #define STACK_SAMPLING_PROFILER_SUPPORTED 1
22 #endif 25 #endif
23 26
24 namespace base { 27 namespace base {
25 28
26 using SamplingParams = StackSamplingProfiler::SamplingParams; 29 using SamplingParams = StackSamplingProfiler::SamplingParams;
27 using Frame = StackSamplingProfiler::Frame; 30 using Frame = StackSamplingProfiler::Frame;
28 using Module = StackSamplingProfiler::Module; 31 using Module = StackSamplingProfiler::Module;
29 using Sample = StackSamplingProfiler::Sample; 32 using Sample = StackSamplingProfiler::Sample;
30 using CallStackProfile = StackSamplingProfiler::CallStackProfile; 33 using CallStackProfile = StackSamplingProfiler::CallStackProfile;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 100); 252 100);
250 ASSERT_TRUE(loc != sample.end()) 253 ASSERT_TRUE(loc != sample.end())
251 << "Function at " 254 << "Function at "
252 << MaybeFixupFunctionAddressForILT( 255 << MaybeFixupFunctionAddressForILT(
253 reinterpret_cast<const void*>( 256 reinterpret_cast<const void*>(
254 &TargetThread::SignalAndWaitUntilSignaled)) 257 &TargetThread::SignalAndWaitUntilSignaled))
255 << " was not found in stack:\n" 258 << " was not found in stack:\n"
256 << FormatSampleForDiagnosticOutput(sample, profile.modules); 259 << FormatSampleForDiagnosticOutput(sample, profile.modules);
257 FilePath executable_path; 260 FilePath executable_path;
258 EXPECT_TRUE(PathService::Get(FILE_EXE, &executable_path)); 261 EXPECT_TRUE(PathService::Get(FILE_EXE, &executable_path));
259 EXPECT_EQ(executable_path, profile.modules[loc->module_index].filename); 262 EXPECT_EQ(executable_path,
263 MakeAbsoluteFilePath(profile.modules[loc->module_index].filename));
260 } 264 }
261 265
262 // Checks that the fire-and-forget interface works. 266 // Checks that the fire-and-forget interface works.
263 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) 267 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED)
264 #define MAYBE_StartAndRunAsync StartAndRunAsync 268 #define MAYBE_StartAndRunAsync StartAndRunAsync
265 #else 269 #else
266 #define MAYBE_StartAndRunAsync DISABLED_StartAndRunAsync 270 #define MAYBE_StartAndRunAsync DISABLED_StartAndRunAsync
267 #endif 271 #endif
268 TEST(StackSamplingProfilerTest, MAYBE_StartAndRunAsync) { 272 TEST(StackSamplingProfilerTest, MAYBE_StartAndRunAsync) {
269 // StartAndRunAsync requires the caller to have a message loop. 273 // StartAndRunAsync requires the caller to have a message loop.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 sampling_completed[1]->TimedWait(TimeDelta::FromMilliseconds(25))); 455 sampling_completed[1]->TimedWait(TimeDelta::FromMilliseconds(25)));
452 456
453 // Start the second profiler again and it should run. 457 // Start the second profiler again and it should run.
454 profiler[1]->Start(); 458 profiler[1]->Start();
455 sampling_completed[1]->Wait(); 459 sampling_completed[1]->Wait();
456 EXPECT_EQ(1u, profiles[1].size()); 460 EXPECT_EQ(1u, profiles[1].size());
457 }); 461 });
458 } 462 }
459 463
460 } // namespace base 464 } // namespace base
OLDNEW
« no previous file with comments | « base/profiler/native_stack_sampler_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698