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