• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "src/traced/probes/ftrace/cpu_stats_parser.h"
2 
3 #include "gmock/gmock.h"
4 #include "gtest/gtest.h"
5 
6 #include "src/traced/probes/ftrace/ftrace_controller.h"
7 #include "src/traced/probes/ftrace/ftrace_stats.h"
8 
9 namespace perfetto {
10 namespace {
11 
TEST(CpuStatsParserTest,DumpCpu)12 TEST(CpuStatsParserTest, DumpCpu) {
13   std::string text = R"(entries: 1
14 overrun: 2
15 commit overrun: 3
16 bytes: 4
17 oldest event ts:     5123.000
18 now ts:  6123.123
19 dropped events	 	:7
20 read events: 8
21 )";
22 
23   FtraceCpuStats stats{};
24   EXPECT_TRUE(DumpCpuStats(text, &stats));
25 
26   EXPECT_EQ(stats.entries, 1);
27   EXPECT_EQ(stats.overrun, 2);
28   EXPECT_EQ(stats.commit_overrun, 3);
29   EXPECT_EQ(stats.bytes_read, 4);
30   EXPECT_EQ(stats.oldest_event_ts, 5123.000);
31   EXPECT_EQ(stats.now_ts, 6123.123);
32   EXPECT_EQ(stats.dropped_events, 7);
33   EXPECT_EQ(stats.read_events, 8);
34 }
35 
36 }  // namespace
37 }  // namespace perfetto
38