diff options
author | Yabin Cui <yabinc@google.com> | 2016-08-19 15:42:39 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-08-24 09:52:27 -0700 |
commit | 4cf37d1583a605785b7677c1935ce316c2097fa2 (patch) | |
tree | 915cea183a64e268dff175079bef0db3a0b74626 /simpleperf/cmd_stat_test.cpp | |
parent | ef99a90b46e1c61e58a42c69f80dcd3943c04a8b (diff) | |
download | extras-4cf37d1583a605785b7677c1935ce316c2097fa2.tar.gz |
simpleperf: notify user for unsupported modifiers.
If there is no need to record samples, u/k modifiers
used in event cpu-clock and task-clock are ignored
by the kernel.
Bug: http://b/29574526
Change-Id: Id45568448888965a3bfa382c4420e395a741f77a
Test: simpleperf_unit_test.
Diffstat (limited to 'simpleperf/cmd_stat_test.cpp')
-rw-r--r-- | simpleperf/cmd_stat_test.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/simpleperf/cmd_stat_test.cpp b/simpleperf/cmd_stat_test.cpp index 810cfd7a..b1f016ca 100644 --- a/simpleperf/cmd_stat_test.cpp +++ b/simpleperf/cmd_stat_test.cpp @@ -85,24 +85,24 @@ TEST(stat_cmd, no_monitored_threads) { ASSERT_FALSE(StatCmd()->Run({""})); } TEST(stat_cmd, group_option) { ASSERT_TRUE( StatCmd()->Run({"--group", "cpu-cycles,cpu-clock", "sleep", "1"})); - ASSERT_TRUE(StatCmd()->Run({"--group", "cpu-cycles,cpu-clock", "--group", - "cpu-cycles:u,cpu-clock:u", "--group", - "cpu-cycles:k,cpu-clock:k", "sleep", "1"})); + ASSERT_TRUE(StatCmd()->Run({"--group", "cpu-cycles,instructions", "--group", + "cpu-cycles:u,instructions:u", "--group", + "cpu-cycles:k,instructions:k", "sleep", "1"})); } TEST(stat_cmd, auto_generated_summary) { TemporaryFile tmp_file; - ASSERT_TRUE(StatCmd()->Run({"--group", "cpu-clock:u,cpu-clock:k", "-o", + ASSERT_TRUE(StatCmd()->Run({"--group", "instructions:u,instructions:k", "-o", tmp_file.path, "sleep", "1"})); std::string s; ASSERT_TRUE(android::base::ReadFileToString(tmp_file.path, &s)); - size_t pos = s.find("cpu-clock:u"); + size_t pos = s.find("instructions:u"); ASSERT_NE(s.npos, pos); - pos = s.find("cpu-clock:k", pos); + pos = s.find("instructions:k", pos); ASSERT_NE(s.npos, pos); - pos += strlen("cpu-clock:k"); - // Check if the summary of cpu-clock is generated. - ASSERT_NE(s.npos, s.find("cpu-clock", pos)); + pos += strlen("instructions:k"); + // Check if the summary of instructions is generated. + ASSERT_NE(s.npos, s.find("instructions", pos)); } TEST(stat_cmd, duration_option) { @@ -110,3 +110,12 @@ TEST(stat_cmd, duration_option) { StatCmd()->Run({"--duration", "1.2", "-p", std::to_string(getpid())})); ASSERT_TRUE(StatCmd()->Run({"--duration", "1", "sleep", "2"})); } + +TEST(stat_cmd, no_modifier_for_clock_events) { + for (const std::string& e : {"cpu-clock", "task-clock"}) { + for (const std::string& m : {"u", "k"}) { + ASSERT_FALSE(StatCmd()->Run({"-e", e + ":" + m, "sleep", "0.1"})) + << "event " << e << ":" << m; + } + } +} |