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

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: rsesek's comments 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/files/file_util.h"
7 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
8 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
10 #include "base/profiler/stack_sampling_profiler.h" 11 #include "base/profiler/stack_sampling_profiler.h"
11 #include "base/run_loop.h" 12 #include "base/run_loop.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
14 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 // STACK_SAMPLING_PROFILER_SUPPORTED is used to conditionally enable the tests 19 // STACK_SAMPLING_PROFILER_SUPPORTED is used to conditionally enable the tests
19 // below for supported platforms (currently Win x64). 20 // below for supported platforms (currently Win x64 and Mac).
20 #if defined(_WIN64) 21 #if defined(_WIN64) || defined(OS_MACOSX)
21 #define STACK_SAMPLING_PROFILER_SUPPORTED 1 22 #define STACK_SAMPLING_PROFILER_SUPPORTED 1
22 #endif 23 #endif
23 24
24 namespace base { 25 namespace base {
25 26
26 using SamplingParams = StackSamplingProfiler::SamplingParams; 27 using SamplingParams = StackSamplingProfiler::SamplingParams;
27 using Frame = StackSamplingProfiler::Frame; 28 using Frame = StackSamplingProfiler::Frame;
28 using Module = StackSamplingProfiler::Module; 29 using Module = StackSamplingProfiler::Module;
29 using Sample = StackSamplingProfiler::Sample; 30 using Sample = StackSamplingProfiler::Sample;
30 using CallStackProfile = StackSamplingProfiler::CallStackProfile; 31 using CallStackProfile = StackSamplingProfiler::CallStackProfile;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 100); 250 100);
250 ASSERT_TRUE(loc != sample.end()) 251 ASSERT_TRUE(loc != sample.end())
251 << "Function at " 252 << "Function at "
252 << MaybeFixupFunctionAddressForILT( 253 << MaybeFixupFunctionAddressForILT(
253 reinterpret_cast<const void*>( 254 reinterpret_cast<const void*>(
254 &TargetThread::SignalAndWaitUntilSignaled)) 255 &TargetThread::SignalAndWaitUntilSignaled))
255 << " was not found in stack:\n" 256 << " was not found in stack:\n"
256 << FormatSampleForDiagnosticOutput(sample, profile.modules); 257 << FormatSampleForDiagnosticOutput(sample, profile.modules);
257 FilePath executable_path; 258 FilePath executable_path;
258 EXPECT_TRUE(PathService::Get(FILE_EXE, &executable_path)); 259 EXPECT_TRUE(PathService::Get(FILE_EXE, &executable_path));
259 EXPECT_EQ(executable_path, profile.modules[loc->module_index].filename); 260 EXPECT_EQ(executable_path,
261 MakeAbsoluteFilePath(profile.modules[loc->module_index].filename));
260 } 262 }
261 263
262 // Checks that the fire-and-forget interface works. 264 // Checks that the fire-and-forget interface works.
263 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) 265 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED)
264 #define MAYBE_StartAndRunAsync StartAndRunAsync 266 #define MAYBE_StartAndRunAsync StartAndRunAsync
265 #else 267 #else
266 #define MAYBE_StartAndRunAsync DISABLED_StartAndRunAsync 268 #define MAYBE_StartAndRunAsync DISABLED_StartAndRunAsync
267 #endif 269 #endif
268 TEST(StackSamplingProfilerTest, MAYBE_StartAndRunAsync) { 270 TEST(StackSamplingProfilerTest, MAYBE_StartAndRunAsync) {
269 // StartAndRunAsync requires the caller to have a message loop. 271 // 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))); 453 sampling_completed[1]->TimedWait(TimeDelta::FromMilliseconds(25)));
452 454
453 // Start the second profiler again and it should run. 455 // Start the second profiler again and it should run.
454 profiler[1]->Start(); 456 profiler[1]->Start();
455 sampling_completed[1]->Wait(); 457 sampling_completed[1]->Wait();
456 EXPECT_EQ(1u, profiles[1].size()); 458 EXPECT_EQ(1u, profiles[1].size());
457 }); 459 });
458 } 460 }
459 461
460 } // namespace base 462 } // namespace base
OLDNEW
« base/profiler/native_stack_sampler_mac.cc ('K') | « 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