diff options
Diffstat (limited to 'perfprofd/tests')
-rw-r--r-- | perfprofd/tests/Android.bp | 3 | ||||
-rw-r--r-- | perfprofd/tests/perfprofd_test.cc | 39 |
2 files changed, 39 insertions, 3 deletions
diff --git a/perfprofd/tests/Android.bp b/perfprofd/tests/Android.bp index 50d9ca83..742ec556 100644 --- a/perfprofd/tests/Android.bp +++ b/perfprofd/tests/Android.bp @@ -36,9 +36,6 @@ cc_test { "liblog", ], target: { - darwin: { - enabled: false, - }, host: { host_ldlibs: [ "-lncurses", diff --git a/perfprofd/tests/perfprofd_test.cc b/perfprofd/tests/perfprofd_test.cc index 1f5ae82b..6c5c2783 100644 --- a/perfprofd/tests/perfprofd_test.cc +++ b/perfprofd/tests/perfprofd_test.cc @@ -44,6 +44,7 @@ #include "map_utils.h" #include "perfprofdcore.h" #include "perfprofd_cmdline.h" +#include "perfprofd_threaded_handler.h" #include "quipper_helper.h" #include "symbolizer.h" @@ -1296,6 +1297,44 @@ TEST_F(RangeMapTest, TestRangeMap) { EXPECT_STREQ("1#a[1,2,10,]50#c[50,]100#a[100,]199#b[199,200,]", print().c_str()); } +class ThreadedHandlerTest : public PerfProfdTest { + public: + void SetUp() override { + PerfProfdTest::SetUp(); + threaded_handler_.reset(new android::perfprofd::ThreadedHandler()); + } + + void TearDown() override { + threaded_handler_.reset(); + PerfProfdTest::TearDown(); + } + + protected: + std::unique_ptr<android::perfprofd::ThreadedHandler> threaded_handler_; +}; + +TEST_F(ThreadedHandlerTest, Basic) { + std::string error_msg; + EXPECT_FALSE(threaded_handler_->StopProfiling(&error_msg)); +} + +#ifdef __ANDROID__ +#define ThreadedHandlerTestName(x) x +#else +#define ThreadedHandlerTestName(x) DISABLED_ ## x +#endif + +TEST_F(ThreadedHandlerTest, ThreadedHandlerTestName(Live)) { + auto config_fn = [](android::perfprofd::ThreadedConfig& config) { + // Use some values that make it likely that things don't fail quickly. + config.main_loop_iterations = 0; + config.collection_interval_in_s = 1000000; + }; + std::string error_msg; + ASSERT_TRUE(threaded_handler_->StartProfiling(config_fn, &error_msg)) << error_msg; + EXPECT_TRUE(threaded_handler_->StopProfiling(&error_msg)) << error_msg; +} + int main(int argc, char **argv) { // Always log to cerr, so that device failures are visible. android::base::SetLogger(android::base::StderrLogger); |