| OLD | NEW |
| 1 // Copyright 2009 Google Inc. All Rights Reserved. | 1 // Copyright 2009 Google Inc. All Rights Reserved. |
| 2 // Author: Nabeel Mian (nabeelmian@google.com) | 2 // Author: Nabeel Mian (nabeelmian@google.com) |
| 3 // Chris Demetriou (cgd@google.com) | 3 // Chris Demetriou (cgd@google.com) |
| 4 // | 4 // |
| 5 // This file contains the unit tests for profile-handler.h interface. | 5 // This file contains the unit tests for profile-handler.h interface. |
| 6 // | 6 // |
| 7 // It is linked into three separate unit tests: | 7 // It is linked into three separate unit tests: |
| 8 // profile-handler_unittest tests basic functionality | 8 // profile-handler_unittest tests basic functionality |
| 9 // profile-handler_disable_test tests that the profiler | 9 // profile-handler_disable_test tests that the profiler |
| 10 // is disabled with --install_signal_handlers=false | 10 // is disabled with --install_signal_handlers=false |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 void Join() { | 52 void Join() { |
| 53 assert(joinable_); | 53 assert(joinable_); |
| 54 pthread_join(thread_, NULL); | 54 pthread_join(thread_, NULL); |
| 55 } | 55 } |
| 56 virtual void Run() = 0; | 56 virtual void Run() = 0; |
| 57 private: | 57 private: |
| 58 static void* DoRun(void* cls) { | 58 static void* DoRun(void* cls) { |
| 59 ProfileHandlerRegisterThread(); | 59 ProfileHandlerRegisterThread(); |
| 60 reinterpret_cast<Thread*>(cls)->Run(); | 60 reinterpret_cast<Thread*>(cls)->Run(); |
| 61 ProfileHandlerUnregisterThread(); |
| 61 return NULL; | 62 return NULL; |
| 62 } | 63 } |
| 63 pthread_t thread_; | 64 pthread_t thread_; |
| 64 bool joinable_; | 65 bool joinable_; |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 // Sleep interval in nano secs. ITIMER_PROF goes off only afer the specified CPU | 68 // Sleep interval in nano secs. ITIMER_PROF goes off only afer the specified CPU |
| 68 // time is consumed. Under heavy load this process may no get scheduled in a | 69 // time is consumed. Under heavy load this process may no get scheduled in a |
| 69 // timely fashion. Therefore, give enough time (20x of ProfileHandle timer | 70 // timely fashion. Therefore, give enough time (20x of ProfileHandle timer |
| 70 // interval 10ms (100Hz)) for this process to accumulate enought CPU time to get | 71 // interval 10ms (100Hz)) for this process to accumulate enought CPU time to get |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 if (FLAGS_test_profiler_signal_handler) { | 498 if (FLAGS_test_profiler_signal_handler) { |
| 498 EXPECT_EQ(FLAGS_test_profiler_enabled, IsSignalEnabled()); | 499 EXPECT_EQ(FLAGS_test_profiler_enabled, IsSignalEnabled()); |
| 499 } | 500 } |
| 500 } | 501 } |
| 501 | 502 |
| 502 } // namespace | 503 } // namespace |
| 503 | 504 |
| 504 int main(int argc, char** argv) { | 505 int main(int argc, char** argv) { |
| 505 return ProfileHandlerTest::RUN_ALL_TESTS(); | 506 return ProfileHandlerTest::RUN_ALL_TESTS(); |
| 506 } | 507 } |
| OLD | NEW |